mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-24 17:22:43 +01:00
derive_more
This commit is contained in:
parent
c7fb8da774
commit
1a8f012de4
1 changed files with 12 additions and 22 deletions
|
@ -1,10 +1,11 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use derive_more::From;
|
||||||
|
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove,
|
ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, From)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum ReplyMarkup {
|
pub enum ReplyMarkup {
|
||||||
InlineKeyboardMarkup(InlineKeyboardMarkup),
|
InlineKeyboardMarkup(InlineKeyboardMarkup),
|
||||||
|
@ -13,26 +14,15 @@ pub enum ReplyMarkup {
|
||||||
ForceReply(ForceReply),
|
ForceReply(ForceReply),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<InlineKeyboardMarkup> for ReplyMarkup {
|
#[cfg(test)]
|
||||||
fn from(markup: InlineKeyboardMarkup) -> Self {
|
mod tests {
|
||||||
ReplyMarkup::InlineKeyboardMarkup(markup)
|
use super::*;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ForceReply> for ReplyMarkup {
|
#[test]
|
||||||
fn from(markup: ForceReply) -> Self {
|
fn inline_keyboard_markup() {
|
||||||
ReplyMarkup::ForceReply(markup)
|
let data = InlineKeyboardMarkup::new();
|
||||||
|
let expected = ReplyMarkup::InlineKeyboardMarkup(data.clone());
|
||||||
|
let actual: ReplyMarkup = data.into();
|
||||||
|
assert_eq!(actual, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ReplyKeyboardMarkup> for ReplyMarkup {
|
|
||||||
fn from(markup: ReplyKeyboardMarkup) -> Self {
|
|
||||||
ReplyMarkup::ReplyKeyboardMarkup(markup)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ReplyKeyboardRemove> for ReplyMarkup {
|
|
||||||
fn from(markup: ReplyKeyboardRemove) -> Self {
|
|
||||||
ReplyMarkup::ReplyKeyboardRemove(markup)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue