Add logic for requesting reviews

This commit is contained in:
Manuel Thalmann 2025-04-12 09:35:46 +02:00
parent c88e85f5ff
commit 733659f8ce
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c

View file

@ -18,10 +18,30 @@ impl Post {
pub fn content(&self) -> &str { pub fn content(&self) -> &str {
"" ""
} }
pub fn request_review(&mut self) {
if let Some(s) = self.state.take() {
self.state = Some(s.request_review())
}
}
} }
trait State {} trait State {
fn request_review(self: Box<Self>) -> Box<dyn State>;
}
struct Draft {} struct Draft {}
impl State for Draft {} impl State for Draft {
fn request_review(self: Box<Self>) -> Box<dyn State> {
Box::new(PendingReview {})
}
}
struct PendingReview {}
impl State for PendingReview {
fn request_review(self: Box<Self>) -> Box<dyn State> {
self
}
}