generated from t/malachite
add: socket
This commit is contained in:
parent
8c86dd6cda
commit
c48cf78314
10 changed files with 227 additions and 13 deletions
28
src/model.rs
28
src/model.rs
|
@ -48,7 +48,7 @@ impl Chat {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Message {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
|
@ -75,3 +75,29 @@ impl Message {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum SocketMethod {
|
||||
/// A message creation event.
|
||||
MessageCreate,
|
||||
/// A message deletion event.
|
||||
MessageDelete,
|
||||
/// A message update event.
|
||||
MessageUpdate,
|
||||
/// A chat update event.
|
||||
ChatUpdate,
|
||||
/// Simple ping.
|
||||
Ping,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SocketMessage {
|
||||
pub method: SocketMethod,
|
||||
pub body: String,
|
||||
}
|
||||
|
||||
impl SocketMessage {
|
||||
pub fn to_string(&self) -> String {
|
||||
serde_json::to_string(&self).unwrap()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue