Define PostEvent

This commit is contained in:
Kitaiti Makoto 2021-01-07 03:39:49 +09:00
parent 578768d7df
commit cfe097edf4

View File

@ -23,7 +23,7 @@ use std::collections::HashSet;
pub type LicensedArticle = CustomObject<Licensed, Article>; pub type LicensedArticle = CustomObject<Licensed, Article>;
#[derive(Queryable, Identifiable, Clone, AsChangeset)] #[derive(Queryable, Identifiable, Clone, AsChangeset, Debug)]
#[changeset_options(treat_none_as_null = "true")] #[changeset_options(treat_none_as_null = "true")]
pub struct Post { pub struct Post {
pub id: i32, 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)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;