Change UpdateMessage<T> to write into RwLock
This commit is contained in:
parent
8ca4ba6e50
commit
9ce575944c
|
@ -1,3 +1,5 @@
|
||||||
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use crate::types::events::WebSocketEvent;
|
use crate::types::events::WebSocketEvent;
|
||||||
use crate::types::{entities::Channel, Snowflake};
|
use crate::types::{entities::Channel, Snowflake};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
@ -34,8 +36,9 @@ pub struct ChannelUpdate {
|
||||||
impl WebSocketEvent for ChannelUpdate {}
|
impl WebSocketEvent for ChannelUpdate {}
|
||||||
|
|
||||||
impl UpdateMessage<Channel> for ChannelUpdate {
|
impl UpdateMessage<Channel> for ChannelUpdate {
|
||||||
fn update(&self, object_to_update: &mut Channel) {
|
fn update(&self, object_to_update: Arc<RwLock<Channel>>) {
|
||||||
*object_to_update = self.channel.clone();
|
let mut write = object_to_update.write().unwrap();
|
||||||
|
*write = self.channel.clone();
|
||||||
}
|
}
|
||||||
fn id(&self) -> Snowflake {
|
fn id(&self) -> Snowflake {
|
||||||
self.channel.id
|
self.channel.id
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub use application::*;
|
pub use application::*;
|
||||||
|
@ -113,6 +115,6 @@ pub(crate) trait UpdateMessage<T>: Clone
|
||||||
where
|
where
|
||||||
T: Updateable,
|
T: Updateable,
|
||||||
{
|
{
|
||||||
fn update(&self, object_to_update: &mut T);
|
fn update(&self, object_to_update: Arc<RwLock<T>>);
|
||||||
fn id(&self) -> Snowflake;
|
fn id(&self) -> Snowflake;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue