From 6dd730030df51438fd970e38194fa0cba4f58ab9 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 12 Jan 2021 09:27:55 +0900 Subject: [PATCH] Wrap Post in PostEvent with Arc See https://github.com/riker-rs/riker/issues/153 --- plume-models/src/posts.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 2f95a81a..fbb03261 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -21,6 +21,7 @@ use plume_common::{ }; use riker::actors::{Publish, Tell}; use std::collections::HashSet; +use std::sync::Arc; pub type LicensedArticle = CustomObject; @@ -556,7 +557,7 @@ impl Post { fn publish_published(&self) { POST_CHAN.tell( Publish { - msg: PostPublished(self.clone()), + msg: PostPublished(Arc::new(self.clone())), topic: "post.published".into(), }, None, @@ -566,7 +567,7 @@ impl Post { fn publish_updated(&self) { POST_CHAN.tell( Publish { - msg: PostUpdated(self.clone()), + msg: PostUpdated(Arc::new(self.clone())), topic: "post.updated".into(), }, None, @@ -576,7 +577,7 @@ impl Post { fn publish_deleted(&self) { POST_CHAN.tell( Publish { - msg: PostDeleted(self.clone()), + msg: PostDeleted(Arc::new(self.clone())), topic: "post.deleted".into(), }, None, @@ -836,12 +837,12 @@ impl IntoId for Post { #[derive(Clone, Debug)] pub enum PostEvent { - PostPublished(Post), - PostUpdated(Post), - PostDeleted(Post), + PostPublished(Arc), + PostUpdated(Arc), + PostDeleted(Arc), } -impl From for Post { +impl From for Arc { fn from(event: PostEvent) -> Self { use PostEvent::*;