mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
Merge pull request #133 from teloxide/derive_from_for_reply_markup
Derive From for reply markup
This commit is contained in:
commit
1d352d9f56
1 changed files with 17 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue