Clean InlineQueryResult* structs

This commit is contained in:
Waffle 2019-09-19 00:16:44 +03:00
parent 04d31cd785
commit 59f419f947
24 changed files with 79 additions and 92 deletions

View file

@ -1,6 +1,6 @@
use crate::core::types::{User, Location};
#[derive(Debug, Serialize, Hash, PartialEq, Eq, Clone)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQuery {
/// Unique identifier for this query
pub id: String,

View file

@ -1,15 +1,47 @@
use super::inline_query_result_cached_audio::InlineQueryResultCachedAudio;
use crate::core::types::{
InlineQueryResultCachedAudio,
InlineQueryResultCachedDocument,
InlineQueryResultCachedGif,
InlineQueryResultCachedMpeg4Gif,
InlineQueryResultCachedPhoto,
InlineQueryResultCachedSticker,
InlineQueryResultCachedVideo,
InlineQueryResultCachedVoice,
InlineQueryResultArticle,
InlineQueryResultAudio,
InlineQueryResultContact,
InlineQueryResultGame,
InlineQueryResultDocument,
InlineQueryResultGif,
InlineQueryResultLocation,
InlineQueryResultMpeg4Gif,
InlineQueryResultPhoto,
InlineQueryResultVenue,
InlineQueryResultVideo,
InlineQueryResultVoice
};
#[derive(Debug, Deserialize, Serialize, Eq, Clone, PartialEq, Hash)]
#[derive(Debug, Serialize, PartialEq, Clone)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum InlineQueryResult {
#[serde(rename = "audio")]
CachedAudio(InlineQueryResultCachedAudio),
#[serde(rename = "document")]
CachedDocument(InlineQueryResultCachedDocument),
#[serde(rename = "gif")]
CachedGif(InlineQueryResultCachedGif),
#[serde(rename = "mpeg4_gif")]
CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif),
#[serde(rename = "photo")]
CachedPhoto(InlineQueryResultCachedPhoto),
#[serde(rename = "sticker")]
CachedSticker(InlineQueryResultCachedSticker),
#[serde(rename = "video")]
CachedVideo(InlineQueryResultCachedVideo),
#[serde(rename = "voice")]
CachedVoice(InlineQueryResultCachedVoice),
Article(InlineQueryResultArticle),
Audio(InlineQueryResultAudio),
Contact(InlineQueryResultContact),
@ -17,6 +49,7 @@ pub enum InlineQueryResult {
Document(InlineQueryResultDocument),
Gif(InlineQueryResultGif),
Location(InlineQueryResultLocation),
#[serde(rename = "mpeg4_gif")]
Mpeg4Gif(InlineQueryResultMpeg4Gif),
Photo(InlineQueryResultPhoto),
Venue(InlineQueryResultVenue),

View file

@ -1,11 +1,7 @@
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Serialize, Hash, PartialEq, Eq, Clone)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultArticle {
// Type of the result, must be article
#[serde(rename = "type")]
pub query_type: String,
/// Unique identifier for this result, 1-64 Bytes
pub id: String,
/// Title of the result

View file

@ -1,8 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::parse_mode::ParseMode;
use crate::core::types::{ParseMode, InlineKeyboardMarkup, InputMessageContent};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultAudio {
pub id: String,
pub audio_url: String,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedAudio {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub audio_file_id: String,
pub caption: Option<String>,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedDocument {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub title: String,
pub document_file_id: String,

View file

@ -1,7 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedGif {
pub id: String,
pub gif_file_id: String,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedMpeg4Gif {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub mpeg4_file_id: String,
pub title: Option<String>,

View file

@ -1,8 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::parse_mode::ParseMode;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedPhoto {
pub id: String,
pub photo_file_id: String,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedSticker {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub sticker_file_id: String,
pub reply_markup: Option<InlineKeyboardMarkup>,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedVideo {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub video_file_id: String,
pub title: String,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultCachedVoice {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub voice_file_id: String,
pub title: String,

View file

@ -1,8 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::parse_mode::ParseMode;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultContact {
pub id: String,
pub phone_number: String,

View file

@ -1,7 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultDocument {
pub id: String,
pub title: String,

View file

@ -1,8 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::parse_mode::ParseMode;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, Hash, PartialEq, Eq, Clone)]
pub struct InlineQueryResultGame {
pub id: String,
pub game_short_name: String,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultGif {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub gif_url: String,
pub gif_width: Option<i32>,

View file

@ -1,8 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::parse_mode::ParseMode;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultLocation {
pub id: String,
pub latitude: f64,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultMpeg4Gif {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub mpeg4_url: String,
pub mpeg4_width: Option<i32>,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultPhoto {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub photo_url: String,
pub thumb_url: String,

View file

@ -1,8 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::parse_mode::ParseMode;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup, ParseMode};
#[derive(Debug, Serialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultVenue {
pub id: String,
pub latitude: f64,

View file

@ -1,10 +1,7 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultVideo {
#[serde(rename = "type")]
pub query_type: String,
pub id: String,
pub video_url: String,
pub mime_type: String,

View file

@ -1,7 +1,6 @@
use super::inline_keyboard_markup::InlineKeyboardMarkup;
use super::input_message_content::InputMessageContent;
use crate::core::types::{InputMessageContent, InlineKeyboardMarkup};
#[derive(Debug, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct InlineQueryResultVoice {
pub id: String,
pub voice_url: String,

View file

@ -2,7 +2,7 @@ use serde::Serialize;
use crate::core::types::ParseMode;
#[derive(Debug, Serialize, Clone)]
#[derive(Debug, Serialize, Clone, PartialEq)]
#[serde(untagged)]
/// This object represents the content of a message to be sent as
/// a result of an inline query.

View file

@ -47,6 +47,8 @@ pub use self::{
video_note::VideoNote,
voice::Voice,
file::File,
input_message_content::InputMessageContent,
inline_query::InlineQuery,
inline_query_result::InlineQueryResult,
inline_query_result_cached_audio::InlineQueryResultCachedAudio,
@ -117,6 +119,7 @@ mod video;
mod video_note;
mod voice;
mod file;
mod input_message_content;
mod inline_query;
mod inline_query_result;