Merge pull request #133 from teloxide/derive_from_for_reply_markup

Derive From for reply markup
This commit is contained in:
Temirkhan Myrzamadi 2020-01-10 19:32:40 +06:00 committed by GitHub
commit 1d352d9f56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,14 +1,28 @@
use serde::{Deserialize, Serialize};
use derive_more::From;
use crate::types::{
ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove,
};
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, From)]
#[serde(untagged)]
pub enum ReplyMarkup {
Inline(InlineKeyboardMarkup),
Reply(ReplyKeyboardMarkup),
InlineKeyboardMarkup(InlineKeyboardMarkup),
ReplyKeyboardMarkup(ReplyKeyboardMarkup),
ReplyKeyboardRemove(ReplyKeyboardRemove),
ForceReply(ForceReply),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn inline_keyboard_markup() {
let data = InlineKeyboardMarkup::new();
let expected = ReplyMarkup::InlineKeyboardMarkup(data.clone());
let actual: ReplyMarkup = data.into();
assert_eq!(actual, expected)
}
}