diff --git a/src/types/message_id.rs b/src/types/message_id.rs index 27e1f91c..31cbd20c 100644 --- a/src/types/message_id.rs +++ b/src/types/message_id.rs @@ -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 for MessageId { + fn from(MessageIdRaw { message_id }: MessageIdRaw) -> Self { + MessageId(message_id) + } +} + +impl From for MessageIdRaw { + fn from(MessageId(message_id): MessageId) -> Self { + MessageIdRaw { message_id } + } +} #[cfg(test)] mod tests {