mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Use more precise types in inline query results
This commit is contained in:
parent
efd801bf2d
commit
15c742d90b
10 changed files with 47 additions and 44 deletions
|
@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `Forward::message_id` and `Message::forward_from_message_id` now use `MessageId` instead of `i32` ([#887][pr887])
|
||||
- `Poll::total_voter_count` and `PollOption::voter_count` now use `u32` instead of `i32` ([#887][pr887])
|
||||
- `PollAnswer::option_ids` now use `u8` instead of `i32` ([#887][pr887])
|
||||
- Use `u32` for sizes and `Seconds` for timespans in `InlineQueryResult*` ([#887][pr887])
|
||||
|
||||
[pr852]: https://github.com/teloxide/teloxide/pull/853
|
||||
[pr859]: https://github.com/teloxide/teloxide/pull/859
|
||||
|
|
|
@ -34,10 +34,10 @@ pub struct InlineQueryResultArticle {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultArticle {
|
||||
|
@ -115,13 +115,13 @@ impl InlineQueryResultArticle {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ pub struct InlineQueryResultContact {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultContact {
|
||||
|
@ -128,13 +128,13 @@ impl InlineQueryResultContact {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ pub struct InlineQueryResultDocument {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultDocument {
|
||||
|
@ -140,13 +140,13 @@ impl InlineQueryResultDocument {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to an animated GIF file.
|
||||
///
|
||||
|
@ -19,13 +19,13 @@ pub struct InlineQueryResultGif {
|
|||
pub gif_url: reqwest::Url,
|
||||
|
||||
/// Width of the GIF.
|
||||
pub gif_width: Option<i32>,
|
||||
pub gif_width: Option<u32>,
|
||||
|
||||
/// Height of the GIFv.
|
||||
pub gif_height: Option<i32>,
|
||||
pub gif_height: Option<u32>,
|
||||
|
||||
/// Duration of the GIF.
|
||||
pub gif_duration: Option<i32>,
|
||||
pub gif_duration: Option<Seconds>,
|
||||
|
||||
/// URL of the static thumbnail for the result (jpeg or gif).
|
||||
pub thumb_url: reqwest::Url,
|
||||
|
@ -93,19 +93,19 @@ impl InlineQueryResultGif {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn gif_width(mut self, val: i32) -> Self {
|
||||
pub fn gif_width(mut self, val: u32) -> Self {
|
||||
self.gif_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn gif_height(mut self, val: i32) -> Self {
|
||||
pub fn gif_height(mut self, val: u32) -> Self {
|
||||
self.gif_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn gif_duration(mut self, val: i32) -> Self {
|
||||
pub fn gif_duration(mut self, val: Seconds) -> Self {
|
||||
self.gif_duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to a video animation (H.264/MPEG-4 AVC video without
|
||||
/// sound).
|
||||
|
@ -16,17 +16,19 @@ pub struct InlineQueryResultMpeg4Gif {
|
|||
/// Unique identifier for this result, 1-64 bytes.
|
||||
pub id: String,
|
||||
|
||||
// FIXME: rename everything so that it doesn't have `mpeg4_` (and similarly for other
|
||||
// `InlineQueryResult*`)
|
||||
/// A valid URL for the MP4 file. File size must not exceed 1MB.
|
||||
pub mpeg4_url: reqwest::Url,
|
||||
|
||||
/// Video width.
|
||||
pub mpeg4_width: Option<i32>,
|
||||
pub mpeg4_width: Option<u32>,
|
||||
|
||||
/// Video height.
|
||||
pub mpeg4_height: Option<i32>,
|
||||
pub mpeg4_height: Option<u32>,
|
||||
|
||||
/// Video duration.
|
||||
pub mpeg4_duration: Option<i32>,
|
||||
pub mpeg4_duration: Option<Seconds>,
|
||||
|
||||
/// URL of the static thumbnail (jpeg or gif) for the result.
|
||||
pub thumb_url: reqwest::Url,
|
||||
|
@ -94,19 +96,19 @@ impl InlineQueryResultMpeg4Gif {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn mpeg4_width(mut self, val: i32) -> Self {
|
||||
pub fn mpeg4_width(mut self, val: u32) -> Self {
|
||||
self.mpeg4_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn mpeg4_height(mut self, val: i32) -> Self {
|
||||
pub fn mpeg4_height(mut self, val: u32) -> Self {
|
||||
self.mpeg4_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn mpeg4_duration(mut self, val: i32) -> Self {
|
||||
pub fn mpeg4_duration(mut self, val: Seconds) -> Self {
|
||||
self.mpeg4_duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ pub struct InlineQueryResultPhoto {
|
|||
pub thumb_url: reqwest::Url,
|
||||
|
||||
/// Width of the photo.
|
||||
pub photo_width: Option<i32>,
|
||||
pub photo_width: Option<u32>,
|
||||
|
||||
/// Height of the photo.
|
||||
pub photo_height: Option<i32>,
|
||||
pub photo_height: Option<u32>,
|
||||
|
||||
/// Title for the result.
|
||||
pub title: Option<String>,
|
||||
|
@ -100,13 +100,13 @@ impl InlineQueryResultPhoto {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn photo_width(mut self, val: i32) -> Self {
|
||||
pub fn photo_width(mut self, val: u32) -> Self {
|
||||
self.photo_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn photo_height(mut self, val: i32) -> Self {
|
||||
pub fn photo_height(mut self, val: u32) -> Self {
|
||||
self.photo_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ pub struct InlineQueryResultVenue {
|
|||
pub thumb_url: Option<reqwest::Url>,
|
||||
|
||||
/// Thumbnail width.
|
||||
pub thumb_width: Option<i32>,
|
||||
pub thumb_width: Option<u32>,
|
||||
|
||||
/// Thumbnail height.
|
||||
pub thumb_height: Option<i32>,
|
||||
pub thumb_height: Option<u32>,
|
||||
}
|
||||
|
||||
impl InlineQueryResultVenue {
|
||||
|
@ -173,13 +173,13 @@ impl InlineQueryResultVenue {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_width(mut self, val: i32) -> Self {
|
||||
pub fn thumb_width(mut self, val: u32) -> Self {
|
||||
self.thumb_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn thumb_height(mut self, val: i32) -> Self {
|
||||
pub fn thumb_height(mut self, val: u32) -> Self {
|
||||
self.thumb_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use mime::Mime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to a page containing an embedded video player or a video
|
||||
/// file.
|
||||
|
@ -46,13 +46,13 @@ pub struct InlineQueryResultVideo {
|
|||
pub caption_entities: Option<Vec<MessageEntity>>,
|
||||
|
||||
/// Video width.
|
||||
pub video_width: Option<i32>,
|
||||
pub video_width: Option<u32>,
|
||||
|
||||
/// Video height.
|
||||
pub video_height: Option<i32>,
|
||||
pub video_height: Option<u32>,
|
||||
|
||||
/// Video duration in seconds.
|
||||
pub video_duration: Option<i32>,
|
||||
pub video_duration: Option<Seconds>,
|
||||
|
||||
/// Short description of the result.
|
||||
pub description: Option<String>,
|
||||
|
@ -158,19 +158,19 @@ impl InlineQueryResultVideo {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn video_width(mut self, val: i32) -> Self {
|
||||
pub fn video_width(mut self, val: u32) -> Self {
|
||||
self.video_width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn video_height(mut self, val: i32) -> Self {
|
||||
pub fn video_height(mut self, val: u32) -> Self {
|
||||
self.video_height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn video_duration(mut self, val: i32) -> Self {
|
||||
pub fn video_duration(mut self, val: Seconds) -> Self {
|
||||
self.video_duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode};
|
||||
use crate::types::{InlineKeyboardMarkup, InputMessageContent, MessageEntity, ParseMode, Seconds};
|
||||
|
||||
/// Represents a link to a voice recording in an .ogg container encoded with
|
||||
/// OPUS.
|
||||
|
@ -38,7 +38,7 @@ pub struct InlineQueryResultVoice {
|
|||
pub caption_entities: Option<Vec<MessageEntity>>,
|
||||
|
||||
/// Recording duration in seconds.
|
||||
pub voice_duration: Option<i32>,
|
||||
pub voice_duration: Option<Seconds>,
|
||||
|
||||
/// [Inline keyboard] attached to the message.
|
||||
///
|
||||
|
@ -113,7 +113,7 @@ impl InlineQueryResultVoice {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn voice_duration(mut self, value: i32) -> Self {
|
||||
pub fn voice_duration(mut self, value: Seconds) -> Self {
|
||||
self.voice_duration = Some(value);
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue