mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 17:52:12 +01:00
Fix MessageId
deserialization
This commit is contained in:
parent
f5a3b55435
commit
13e5ed8fb4
1 changed files with 19 additions and 1 deletions
|
@ -2,7 +2,25 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
/// A unique message identifier.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct MessageId(#[serde(rename = "message_id")] pub i32);
|
||||
#[serde(from = "MessageIdRaw", into = "MessageIdRaw")]
|
||||
pub struct MessageId(pub i32);
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct MessageIdRaw {
|
||||
message_id: i32,
|
||||
}
|
||||
|
||||
impl From<MessageIdRaw> for MessageId {
|
||||
fn from(MessageIdRaw { message_id }: MessageIdRaw) -> Self {
|
||||
MessageId(message_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MessageId> for MessageIdRaw {
|
||||
fn from(MessageId(message_id): MessageId) -> Self {
|
||||
MessageIdRaw { message_id }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
Loading…
Reference in a new issue