Define PostEvent
This commit is contained in:
parent
578768d7df
commit
cfe097edf4
@ -23,7 +23,7 @@ use std::collections::HashSet;
|
||||
|
||||
pub type LicensedArticle = CustomObject<Licensed, Article>;
|
||||
|
||||
#[derive(Queryable, Identifiable, Clone, AsChangeset)]
|
||||
#[derive(Queryable, Identifiable, Clone, AsChangeset, Debug)]
|
||||
#[changeset_options(treat_none_as_null = "true")]
|
||||
pub struct Post {
|
||||
pub id: i32,
|
||||
@ -800,6 +800,25 @@ impl IntoId for Post {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PostEvent {
|
||||
PostPublished(Post),
|
||||
PostUpdated(Post),
|
||||
PostDeleted(Post),
|
||||
}
|
||||
|
||||
impl From<PostEvent> for Post {
|
||||
fn from(event: PostEvent) -> Self {
|
||||
use PostEvent::*;
|
||||
|
||||
match event {
|
||||
PostPublished(post) => post,
|
||||
PostUpdated(post) => post,
|
||||
PostDeleted(post) => post,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user