Change UpdateMessage<T> to write into RwLock
This commit is contained in:
parent
33357db291
commit
0f00d5d283
|
@ -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<Channel> for ChannelUpdate {
|
||||
fn update(&self, object_to_update: &mut Channel) {
|
||||
*object_to_update = self.channel.clone();
|
||||
fn update(&self, object_to_update: Arc<RwLock<Channel>>) {
|
||||
let mut write = object_to_update.write().unwrap();
|
||||
*write = self.channel.clone();
|
||||
}
|
||||
fn id(&self) -> Snowflake {
|
||||
self.channel.id
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use application::*;
|
||||
|
@ -113,6 +115,6 @@ pub(crate) trait UpdateMessage<T>: Clone
|
|||
where
|
||||
T: Updateable,
|
||||
{
|
||||
fn update(&self, object_to_update: &mut T);
|
||||
fn update(&self, object_to_update: Arc<RwLock<T>>);
|
||||
fn id(&self) -> Snowflake;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue