diff --git a/src/types/events/channel.rs b/src/types/events/channel.rs index 002230c..000bc17 100644 --- a/src/types/events/channel.rs +++ b/src/types/events/channel.rs @@ -1,3 +1,5 @@ +use std::sync::{Arc, RwLock}; + use crate::types::events::WebSocketEvent; use crate::types::{entities::Channel, Snowflake}; use chrono::{DateTime, Utc}; @@ -34,8 +36,9 @@ pub struct ChannelUpdate { impl WebSocketEvent for ChannelUpdate {} impl UpdateMessage for ChannelUpdate { - fn update(&self, object_to_update: &mut Channel) { - *object_to_update = self.channel.clone(); + fn update(&self, object_to_update: Arc>) { + let mut write = object_to_update.write().unwrap(); + *write = self.channel.clone(); } fn id(&self) -> Snowflake { self.channel.id diff --git a/src/types/events/mod.rs b/src/types/events/mod.rs index d477800..0413ac9 100644 --- a/src/types/events/mod.rs +++ b/src/types/events/mod.rs @@ -1,3 +1,5 @@ +use std::sync::{Arc, RwLock}; + use serde::{Deserialize, Serialize}; pub use application::*; @@ -113,6 +115,6 @@ pub(crate) trait UpdateMessage: Clone where T: Updateable, { - fn update(&self, object_to_update: &mut T); + fn update(&self, object_to_update: Arc>); fn id(&self) -> Snowflake; }