implemented notifications and messages

This commit is contained in:
mb 2022-08-22 15:54:36 +03:00
parent 28a3812812
commit 695ac6daa2
12 changed files with 1023 additions and 315 deletions

View file

@ -22,6 +22,10 @@ impl Channel {
pub fn get_name(&self) -> &str {
&self.name
}
pub fn set_name(&mut self, name: String) {
self.name = name;
}
}
#[derive(Debug, Serialize, Deserialize)]
@ -31,11 +35,28 @@ pub struct User {
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Msg {
pub struct Message {
id: Id,
content: String,
}
impl Message {
pub fn new(content: String) -> Self {
let id = Id::from_now();
Self { id, content }
}
pub fn get_id(&self) -> Id {
self.id
}
pub fn get_content(&self) -> &str {
&self.content
}
pub fn set_content(&mut self, content: String) {
self.content = content;
}
}
pub trait SerDeser: Serialize + DeserializeOwned {
fn ser(&self) -> Vec<u8>;
fn deser(input: &[u8]) -> Option<Self>;