2019-02-06 14:54:11 -05:00
|
|
|
pub struct Post {
|
2019-02-06 15:02:36 -05:00
|
|
|
content: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct DraftPost {
|
2019-02-06 14:54:11 -05:00
|
|
|
content: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Post {
|
2019-02-06 15:02:36 -05:00
|
|
|
pub fn new() -> DraftPost {
|
|
|
|
DraftPost {
|
2019-02-06 14:54:11 -05:00
|
|
|
content: String::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn content(&self) -> &str {
|
2019-02-06 15:02:36 -05:00
|
|
|
&self.content
|
2019-02-06 14:54:11 -05:00
|
|
|
}
|
2019-02-06 15:02:36 -05:00
|
|
|
}
|
2019-02-06 14:54:11 -05:00
|
|
|
|
2019-02-06 15:02:36 -05:00
|
|
|
impl DraftPost {
|
|
|
|
pub fn add_text(&mut self, text: &str) {
|
|
|
|
self.content.push_str(text);
|
2019-02-06 14:54:11 -05:00
|
|
|
}
|
|
|
|
|
2019-02-06 15:02:36 -05:00
|
|
|
pub fn request_review(self) -> PendingReviewPost {
|
|
|
|
PendingReviewPost {
|
|
|
|
content: self.content,
|
2019-02-06 14:54:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-06 15:02:36 -05:00
|
|
|
pub struct PendingReviewPost {
|
|
|
|
content: String,
|
2019-02-06 14:54:11 -05:00
|
|
|
}
|
|
|
|
|
2019-02-06 15:02:36 -05:00
|
|
|
impl PendingReviewPost {
|
|
|
|
pub fn approve(self) -> Post {
|
|
|
|
Post {
|
|
|
|
content: self.content,
|
|
|
|
}
|
2019-02-06 14:54:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|