Add setters to Message

This commit is contained in:
Temirkhan Myrzamadi 2020-07-28 01:17:38 +06:00
parent 7f92bd999a
commit fee9cb680d

View file

@ -29,6 +29,32 @@ pub struct Message {
pub kind: MessageKind,
}
impl Message {
pub fn new(id: i32, date: i32, chat: Chat, kind: MessageKind) -> Self {
Self { id, date, chat, kind }
}
pub fn id(mut self, val: i32) -> Self {
self.id = val;
self
}
pub fn date(mut self, val: i32) -> Self {
self.date = val;
self
}
pub fn chat(mut self, val: Chat) -> Self {
self.chat = val;
self
}
pub fn kind(mut self, val: MessageKind) -> Self {
self.kind = val;
self
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[non_exhaustive]