mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 03:43:22 +01:00
Cleanup setters in types::*
- Remove useless setters for types which are only returned from telegam - Add `const` on setters (where possible) - Make `Poll::{open_period,close_date}` public
This commit is contained in:
parent
d663879423
commit
393f6ee7a4
45 changed files with 98 additions and 3095 deletions
|
@ -41,86 +41,6 @@ pub struct Animation {
|
|||
pub file_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl Animation {
|
||||
pub fn new<S1, S2>(
|
||||
file_id: S1,
|
||||
file_unique_id: S2,
|
||||
width: u32,
|
||||
height: u32,
|
||||
duration: u32,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
width,
|
||||
height,
|
||||
duration,
|
||||
thumb: None,
|
||||
file_name: None,
|
||||
mime_type: None,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, val: u32) -> Self {
|
||||
self.width = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(mut self, val: u32) -> Self {
|
||||
self.height = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u32) -> Self {
|
||||
self.duration = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: PhotoSize) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||
self.mime_type = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -38,77 +38,6 @@ pub struct Audio {
|
|||
pub thumb: Option<PhotoSize>,
|
||||
}
|
||||
|
||||
impl Audio {
|
||||
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, duration: u32) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
duration,
|
||||
performer: None,
|
||||
title: None,
|
||||
mime_type: None,
|
||||
file_size: None,
|
||||
thumb: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u32) -> Self {
|
||||
self.duration = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn performer<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.performer = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.title = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||
self.mime_type = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: PhotoSize) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -49,74 +49,6 @@ pub struct CallbackQuery {
|
|||
pub game_short_name: Option<String>,
|
||||
}
|
||||
|
||||
impl CallbackQuery {
|
||||
pub fn new<S1, S2>(id: S1, from: User, chat_instance: S2) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
id: id.into(),
|
||||
from,
|
||||
message: None,
|
||||
inline_message_id: None,
|
||||
chat_instance: chat_instance.into(),
|
||||
data: None,
|
||||
game_short_name: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id<S>(mut self, id: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.id = id.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn from(mut self, val: User) -> Self {
|
||||
self.from = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn message(mut self, val: Message) -> Self {
|
||||
self.message = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn inline_message_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.inline_message_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn chat_instance<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.chat_instance = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn game_short_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.game_short_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -24,31 +24,6 @@ pub struct Chat {
|
|||
pub photo: Option<ChatPhoto>,
|
||||
}
|
||||
|
||||
impl Chat {
|
||||
pub fn new(id: i64, kind: ChatKind) -> Self {
|
||||
Self {
|
||||
id,
|
||||
kind,
|
||||
photo: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(mut self, val: i64) -> Self {
|
||||
self.id = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn kind(mut self, val: ChatKind) -> Self {
|
||||
self.kind = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn photo(mut self, val: ChatPhoto) -> Self {
|
||||
self.photo = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
|
@ -91,47 +66,6 @@ pub struct ChatPublic {
|
|||
pub pinned_message: Option<Box<Message>>,
|
||||
}
|
||||
|
||||
impl ChatPublic {
|
||||
pub fn new(kind: PublicChatKind) -> Self {
|
||||
Self {
|
||||
title: None,
|
||||
kind,
|
||||
description: None,
|
||||
invite_link: None,
|
||||
pinned_message: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.title = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn description<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.description = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn invite_link<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.invite_link = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pinned_message(mut self, val: Message) -> Self {
|
||||
self.pinned_message = Some(Box::new(val));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ChatPrivate {
|
||||
|
@ -152,36 +86,6 @@ pub struct ChatPrivate {
|
|||
pub last_name: Option<String>,
|
||||
}
|
||||
|
||||
impl ChatPrivate {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn username<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.username = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn first_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.first_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.last_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
@ -199,12 +103,6 @@ pub struct PublicChatChannel {
|
|||
pub username: Option<String>,
|
||||
}
|
||||
|
||||
impl PublicChatChannel {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PublicChatGroup {
|
||||
|
@ -215,12 +113,6 @@ pub struct PublicChatGroup {
|
|||
pub permissions: Option<ChatPermissions>,
|
||||
}
|
||||
|
||||
impl PublicChatGroup {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PublicChatSupergroup {
|
||||
|
@ -253,12 +145,6 @@ pub struct PublicChatSupergroup {
|
|||
pub slow_mode_delay: Option<i32>,
|
||||
}
|
||||
|
||||
impl PublicChatSupergroup {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
struct PrivateChatKindVisitor;
|
||||
|
||||
impl<'de> serde::de::Visitor<'de> for PrivateChatKindVisitor {
|
||||
|
|
|
@ -41,7 +41,56 @@ pub struct ChatPermissions {
|
|||
}
|
||||
|
||||
impl ChatPermissions {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
can_send_messages: None,
|
||||
can_send_media_messages: None,
|
||||
can_send_polls: None,
|
||||
can_send_other_messages: None,
|
||||
can_add_web_page_previews: None,
|
||||
can_change_info: None,
|
||||
can_invite_users: None,
|
||||
can_pin_messages: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn can_send_messages(mut self, val: bool) -> Self {
|
||||
self.can_send_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_send_media_messages(mut self, val: bool) -> Self {
|
||||
self.can_send_media_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_send_polls(mut self, val: bool) -> Self {
|
||||
self.can_send_polls = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_send_other_messages(mut self, val: bool) -> Self {
|
||||
self.can_send_other_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_add_web_page_previews(mut self, val: bool) -> Self {
|
||||
self.can_add_web_page_previews = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_change_info(mut self, val: bool) -> Self {
|
||||
self.can_change_info = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_invite_users(mut self, val: bool) -> Self {
|
||||
self.can_invite_users = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub const fn can_pin_messages(mut self, val: bool) -> Self {
|
||||
self.can_pin_messages = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,57 +25,3 @@ pub struct ChatPhoto {
|
|||
/// download or reuse the file.
|
||||
pub big_file_unique_id: String,
|
||||
}
|
||||
|
||||
impl ChatPhoto {
|
||||
pub fn new<S1, S2, S3, S4>(
|
||||
small_file_id: S1,
|
||||
small_file_unique_id: S2,
|
||||
big_file_id: S3,
|
||||
big_file_unique_id: S4,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
S4: Into<String>,
|
||||
{
|
||||
Self {
|
||||
small_file_id: small_file_id.into(),
|
||||
small_file_unique_id: small_file_unique_id.into(),
|
||||
big_file_id: big_file_id.into(),
|
||||
big_file_unique_id: big_file_unique_id.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn small_file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.small_file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn small_file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.small_file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn big_file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.big_file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn big_file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.big_file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,53 +32,3 @@ pub struct ChosenInlineResult {
|
|||
/// The query that was used to obtain the result.
|
||||
pub query: String,
|
||||
}
|
||||
|
||||
impl ChosenInlineResult {
|
||||
pub fn new<S1, S2>(result_id: S1, from: User, query: S2) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
result_id: result_id.into(),
|
||||
from,
|
||||
location: None,
|
||||
inline_message_id: None,
|
||||
query: query.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn result_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.result_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn from(mut self, val: User) -> Self {
|
||||
self.from = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn location<S>(mut self, val: Location) -> Self {
|
||||
self.location = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn inline_message_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.inline_message_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn query<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.query = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,56 +23,3 @@ pub struct Contact {
|
|||
/// [vCard]: https://en.wikipedia.org/wiki/VCard
|
||||
pub vcard: Option<String>,
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn new<S1, S2>(phone_number: S1, first_name: S2) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
phone_number: phone_number.into(),
|
||||
first_name: first_name.into(),
|
||||
last_name: None,
|
||||
user_id: None,
|
||||
vcard: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn phone_number<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.phone_number = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn first_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.first_name = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.last_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn user_id(mut self, val: i32) -> Self {
|
||||
self.user_id = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn vcard<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.vcard = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,3 @@ pub struct Dice {
|
|||
/// [`DiceEmoji::Basketball`]:crate::types::DiceEmoji::Basketball
|
||||
value: i32,
|
||||
}
|
||||
|
||||
impl Dice {
|
||||
pub fn new(emoji: DiceEmoji, value: i32) -> Self {
|
||||
Self { emoji, value }
|
||||
}
|
||||
|
||||
pub fn emoji(mut self, val: DiceEmoji) -> Self {
|
||||
self.emoji = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn value<S>(mut self, val: i32) -> Self {
|
||||
self.value = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,59 +35,3 @@ pub struct Document {
|
|||
/// A size of a file.
|
||||
pub file_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl Document {
|
||||
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
thumb: None,
|
||||
file_name: None,
|
||||
mime_type: None,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: PhotoSize) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||
self.mime_type = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,45 +30,6 @@ pub struct EncryptedCredentials {
|
|||
pub secret: String,
|
||||
}
|
||||
|
||||
impl EncryptedCredentials {
|
||||
pub fn new<S1, S2, S3>(data: S1, hash: S2, secret: S3) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
{
|
||||
Self {
|
||||
data: data.into(),
|
||||
hash: hash.into(),
|
||||
secret: secret.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn hash<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.hash = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn secret<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.secret = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -19,31 +19,6 @@ pub struct EncryptedPassportElement {
|
|||
pub kind: EncryptedPassportElementKind,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElement {
|
||||
pub fn new<S>(hash: S, kind: EncryptedPassportElementKind) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
hash: hash.into(),
|
||||
kind,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.hash = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn kind(mut self, val: EncryptedPassportElementKind) -> Self {
|
||||
self.kind = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
|
@ -77,23 +52,6 @@ pub struct EncryptedPassportElementPersonalDetails {
|
|||
pub data: String,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementPersonalDetails {
|
||||
pub fn new<S>(data: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self { data: data.into() }
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementPassport {
|
||||
|
@ -138,46 +96,6 @@ pub struct EncryptedPassportElementPassport {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementPassport {
|
||||
pub fn new<S>(data: S, front_side: PassportFile, selfie: PassportFile) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
data: data.into(),
|
||||
front_side,
|
||||
selfie,
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn front_side(mut self, val: PassportFile) -> Self {
|
||||
self.front_side = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn selfie(mut self, val: PassportFile) -> Self {
|
||||
self.selfie = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementDriverLicense {
|
||||
|
@ -231,56 +149,6 @@ pub struct EncryptedPassportElementDriverLicense {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementDriverLicense {
|
||||
pub fn new<S>(
|
||||
data: S,
|
||||
front_side: PassportFile,
|
||||
reverse_side: PassportFile,
|
||||
selfie: PassportFile,
|
||||
) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
data: data.into(),
|
||||
front_side,
|
||||
reverse_side,
|
||||
selfie,
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn front_side(mut self, val: PassportFile) -> Self {
|
||||
self.front_side = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reverse_side(mut self, val: PassportFile) -> Self {
|
||||
self.reverse_side = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn selfie(mut self, val: PassportFile) -> Self {
|
||||
self.selfie = val;
|
||||
self
|
||||
}
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementIdentityCard {
|
||||
|
@ -334,56 +202,6 @@ pub struct EncryptedPassportElementIdentityCard {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementIdentityCard {
|
||||
pub fn new<S>(
|
||||
data: S,
|
||||
front_side: PassportFile,
|
||||
reverse_side: PassportFile,
|
||||
selfie: PassportFile,
|
||||
) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
data: data.into(),
|
||||
front_side,
|
||||
reverse_side,
|
||||
selfie,
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn front_side(mut self, val: PassportFile) -> Self {
|
||||
self.front_side = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reverse_side(mut self, val: PassportFile) -> Self {
|
||||
self.reverse_side = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn selfie(mut self, val: PassportFile) -> Self {
|
||||
self.selfie = val;
|
||||
self
|
||||
}
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementInternalPassport {
|
||||
|
@ -428,46 +246,6 @@ pub struct EncryptedPassportElementInternalPassport {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementInternalPassport {
|
||||
pub fn new<S>(data: S, front_side: PassportFile, selfie: PassportFile) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
data: data.into(),
|
||||
front_side,
|
||||
selfie,
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn front_side(mut self, val: PassportFile) -> Self {
|
||||
self.front_side = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn selfie(mut self, val: PassportFile) -> Self {
|
||||
self.selfie = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementAddress {
|
||||
|
@ -482,23 +260,6 @@ pub struct EncryptedPassportElementAddress {
|
|||
pub data: String,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementAddress {
|
||||
pub fn new<S>(data: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self { data: data.into() }
|
||||
}
|
||||
|
||||
pub fn data<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementUtilityBill {
|
||||
|
@ -525,34 +286,6 @@ pub struct EncryptedPassportElementUtilityBill {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementUtilityBill {
|
||||
pub fn new<F>(files: F) -> Self
|
||||
where
|
||||
F: Into<Vec<PassportFile>>,
|
||||
{
|
||||
Self {
|
||||
files: files.into(),
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn files<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.files = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementBankStatement {
|
||||
|
@ -579,34 +312,6 @@ pub struct EncryptedPassportElementBankStatement {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementBankStatement {
|
||||
pub fn new<F>(files: F) -> Self
|
||||
where
|
||||
F: Into<Vec<PassportFile>>,
|
||||
{
|
||||
Self {
|
||||
files: files.into(),
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn files<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.files = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementRentalAgreement {
|
||||
|
@ -633,34 +338,6 @@ pub struct EncryptedPassportElementRentalAgreement {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementRentalAgreement {
|
||||
pub fn new<F>(files: F) -> Self
|
||||
where
|
||||
F: Into<Vec<PassportFile>>,
|
||||
{
|
||||
Self {
|
||||
files: files.into(),
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn files<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.files = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementPassportRegistration {
|
||||
|
@ -687,34 +364,6 @@ pub struct EncryptedPassportElementPassportRegistration {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementPassportRegistration {
|
||||
pub fn new<F>(files: F) -> Self
|
||||
where
|
||||
F: Into<Vec<PassportFile>>,
|
||||
{
|
||||
Self {
|
||||
files: files.into(),
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn files<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.files = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementTemporaryRegistration {
|
||||
|
@ -741,34 +390,6 @@ pub struct EncryptedPassportElementTemporaryRegistration {
|
|||
pub translation: Option<Vec<PassportFile>>,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementTemporaryRegistration {
|
||||
pub fn new<F>(files: F) -> Self
|
||||
where
|
||||
F: Into<Vec<PassportFile>>,
|
||||
{
|
||||
Self {
|
||||
files: files.into(),
|
||||
translation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn files<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.files = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn translation<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PassportFile>>,
|
||||
{
|
||||
self.translation = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementPhoneNumber {
|
||||
|
@ -777,47 +398,9 @@ pub struct EncryptedPassportElementPhoneNumber {
|
|||
pub phone_number: String,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementPhoneNumber {
|
||||
pub fn new<S>(phone_number: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
phone_number: phone_number.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn phone_number<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.phone_number = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct EncryptedPassportElementEmail {
|
||||
/// User's verified email address, available only for `email` type.
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
impl EncryptedPassportElementEmail {
|
||||
pub fn new<S>(email: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
email: email.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn email<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.email = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,48 +30,3 @@ pub struct File {
|
|||
/// crate::net::Download::download_file
|
||||
pub file_path: String,
|
||||
}
|
||||
|
||||
impl File {
|
||||
pub fn new<S1, S2, S3>(file_id: S1, file_unique_id: S2, file_size: u32, file_path: S3) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
file_size,
|
||||
file_path: file_path.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_path<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,14 @@ pub struct ForceReply {
|
|||
}
|
||||
|
||||
impl ForceReply {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
force_reply: True,
|
||||
selective: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn selective(mut self, val: bool) -> Self {
|
||||
pub const fn selective(mut self, val: bool) -> Self {
|
||||
self.selective = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -39,66 +39,3 @@ pub struct Game {
|
|||
/// [@Botfather]: https://t.me/botfather
|
||||
pub animation: Option<Animation>,
|
||||
}
|
||||
|
||||
impl Game {
|
||||
pub fn new<S1, S2, P>(title: S1, description: S2, photo: P) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
P: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
Self {
|
||||
title: title.into(),
|
||||
description: description.into(),
|
||||
photo: photo.into(),
|
||||
text: None,
|
||||
text_entities: None,
|
||||
animation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.title = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn description<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.description = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn photo<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
self.photo = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn text<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.text = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn text_entities<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.text_entities = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn animation(mut self, val: Animation) -> Self {
|
||||
self.animation = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,28 +16,3 @@ pub struct GameHighScore {
|
|||
/// Score.
|
||||
pub score: u32,
|
||||
}
|
||||
|
||||
impl GameHighScore {
|
||||
pub fn new(position: u32, user: User, score: u32) -> Self {
|
||||
Self {
|
||||
position,
|
||||
user,
|
||||
score,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn position(mut self, val: u32) -> Self {
|
||||
self.position = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn user(mut self, val: User) -> Self {
|
||||
self.user = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn score(mut self, val: u32) -> Self {
|
||||
self.score = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub struct InputMediaPhoto {
|
|||
}
|
||||
|
||||
impl InputMediaPhoto {
|
||||
pub fn new(media: InputFile) -> Self {
|
||||
pub const fn new(media: InputFile) -> Self {
|
||||
Self {
|
||||
media,
|
||||
caption: None,
|
||||
|
@ -59,7 +59,7 @@ impl InputMediaPhoto {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
pub const fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
self.parse_mode = Some(val);
|
||||
self
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ pub struct InputMediaVideo {
|
|||
}
|
||||
|
||||
impl InputMediaVideo {
|
||||
pub fn new(media: InputFile) -> Self {
|
||||
pub const fn new(media: InputFile) -> Self {
|
||||
Self {
|
||||
media,
|
||||
thumb: None,
|
||||
|
@ -137,27 +137,27 @@ impl InputMediaVideo {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
pub const fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
self.parse_mode = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, val: u16) -> Self {
|
||||
pub const fn width(mut self, val: u16) -> Self {
|
||||
self.width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(mut self, val: u16) -> Self {
|
||||
pub const fn height(mut self, val: u16) -> Self {
|
||||
self.height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u16) -> Self {
|
||||
pub const fn duration(mut self, val: u16) -> Self {
|
||||
self.duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn supports_streaming(mut self, val: bool) -> Self {
|
||||
pub const fn supports_streaming(mut self, val: bool) -> Self {
|
||||
self.supports_streaming = Some(val);
|
||||
self
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ pub struct InputMediaAnimation {
|
|||
}
|
||||
|
||||
impl InputMediaAnimation {
|
||||
pub fn new(media: InputFile) -> Self {
|
||||
pub const fn new(media: InputFile) -> Self {
|
||||
Self {
|
||||
media,
|
||||
thumb: None,
|
||||
|
@ -232,22 +232,22 @@ impl InputMediaAnimation {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
pub const fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
self.parse_mode = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, val: u16) -> Self {
|
||||
pub const fn width(mut self, val: u16) -> Self {
|
||||
self.width = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(mut self, val: u16) -> Self {
|
||||
pub const fn height(mut self, val: u16) -> Self {
|
||||
self.height = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u16) -> Self {
|
||||
pub const fn duration(mut self, val: u16) -> Self {
|
||||
self.duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ pub struct InputMediaAudio {
|
|||
}
|
||||
|
||||
impl InputMediaAudio {
|
||||
pub fn new(media: InputFile) -> Self {
|
||||
pub const fn new(media: InputFile) -> Self {
|
||||
Self {
|
||||
media,
|
||||
thumb: None,
|
||||
|
@ -321,12 +321,12 @@ impl InputMediaAudio {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
pub const fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
self.parse_mode = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u16) -> Self {
|
||||
pub const fn duration(mut self, val: u16) -> Self {
|
||||
self.duration = Some(val);
|
||||
self
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ pub struct InputMediaDocument {
|
|||
}
|
||||
|
||||
impl InputMediaDocument {
|
||||
pub fn new(media: InputFile) -> Self {
|
||||
pub const fn new(media: InputFile) -> Self {
|
||||
Self {
|
||||
media,
|
||||
thumb: None,
|
||||
|
@ -386,6 +386,11 @@ impl InputMediaDocument {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn media(mut self, val: InputFile) -> Self {
|
||||
self.media = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: InputFile) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
|
@ -399,7 +404,7 @@ impl InputMediaDocument {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
pub const fn parse_mode(mut self, val: ParseMode) -> Self {
|
||||
self.parse_mode = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ pub struct InputMessageContentLocation {
|
|||
}
|
||||
|
||||
impl InputMessageContentLocation {
|
||||
pub fn new(latitude: f64, longitude: f64) -> Self {
|
||||
pub const fn new(latitude: f64, longitude: f64) -> Self {
|
||||
Self {
|
||||
latitude,
|
||||
longitude,
|
||||
|
@ -90,17 +90,17 @@ impl InputMessageContentLocation {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn latitude(mut self, val: f64) -> Self {
|
||||
pub const fn latitude(mut self, val: f64) -> Self {
|
||||
self.latitude = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn longitude(mut self, val: f64) -> Self {
|
||||
pub const fn longitude(mut self, val: f64) -> Self {
|
||||
self.longitude = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn live_period(mut self, val: u32) -> Self {
|
||||
pub const fn live_period(mut self, val: u32) -> Self {
|
||||
self.live_period = Some(val);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -27,64 +27,3 @@ pub struct Invoice {
|
|||
/// [`currencies.json`]: https://core.telegram.org/bots/payments/currencies.json
|
||||
pub total_amount: i32,
|
||||
}
|
||||
|
||||
impl Invoice {
|
||||
pub fn new<S1, S2, S3, S4>(
|
||||
title: S1,
|
||||
description: S2,
|
||||
start_parameter: S3,
|
||||
currency: S4,
|
||||
total_amount: i32,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
S4: Into<String>,
|
||||
{
|
||||
Self {
|
||||
title: title.into(),
|
||||
description: description.into(),
|
||||
start_parameter: start_parameter.into(),
|
||||
currency: currency.into(),
|
||||
total_amount,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.title = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn description<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.description = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn start_parameter<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.start_parameter = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn currency<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.currency = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn total_amount(mut self, val: i32) -> Self {
|
||||
self.total_amount = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ impl KeyboardButton {
|
|||
|
||||
pub fn request<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<Option<ButtonRequest>>,
|
||||
T: Into<ButtonRequest>,
|
||||
{
|
||||
self.request = val.into();
|
||||
self.request = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,22 +9,3 @@ pub struct Location {
|
|||
/// Latitude as defined by sender.
|
||||
pub latitude: f64,
|
||||
}
|
||||
|
||||
impl Location {
|
||||
pub fn new(longitude: f64, latitude: f64) -> Self {
|
||||
Self {
|
||||
longitude,
|
||||
latitude,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn latitude(mut self, val: f64) -> Self {
|
||||
self.latitude = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn longitude(mut self, val: f64) -> Self {
|
||||
self.longitude = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,42 +20,3 @@ pub struct Me {
|
|||
/// `true`, if the bot supports inline queries.
|
||||
pub supports_inline_queries: bool,
|
||||
}
|
||||
|
||||
impl Me {
|
||||
pub fn new(
|
||||
user: User,
|
||||
can_join_groups: bool,
|
||||
can_read_all_group_messages: bool,
|
||||
supports_inline_queries: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
user,
|
||||
can_join_groups,
|
||||
can_read_all_group_messages,
|
||||
supports_inline_queries,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn user(mut self, val: User) -> Self {
|
||||
self.user = val;
|
||||
self
|
||||
}
|
||||
|
||||
#[warn(clippy::wrong_self_convention)]
|
||||
pub fn can_join_groups<S>(mut self, val: bool) -> Self {
|
||||
self.can_join_groups = val;
|
||||
self
|
||||
}
|
||||
|
||||
#[warn(clippy::wrong_self_convention)]
|
||||
pub fn can_read_all_group_messages<S>(mut self, val: bool) -> Self {
|
||||
self.can_read_all_group_messages = val;
|
||||
self
|
||||
}
|
||||
|
||||
#[warn(clippy::wrong_self_convention)]
|
||||
pub fn supports_inline_queries<S>(mut self, val: bool) -> Self {
|
||||
self.supports_inline_queries = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,43 +31,6 @@ pub struct Message {
|
|||
pub kind: MessageKind,
|
||||
}
|
||||
|
||||
impl Message {
|
||||
pub fn new(id: i32, date: i32, chat: Chat, kind: MessageKind) -> Self {
|
||||
Self {
|
||||
id,
|
||||
date,
|
||||
chat,
|
||||
kind,
|
||||
via_bot: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id(mut self, val: i32) -> Self {
|
||||
self.id = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn date(mut self, val: i32) -> Self {
|
||||
self.date = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn chat(mut self, val: Chat) -> Self {
|
||||
self.chat = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn kind(mut self, val: MessageKind) -> Self {
|
||||
self.kind = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn via_bot(mut self, val: User) -> Self {
|
||||
self.via_bot = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum MessageKind {
|
||||
|
@ -109,43 +72,6 @@ pub struct MessageCommon {
|
|||
pub reply_markup: Option<InlineKeyboardMarkup>,
|
||||
}
|
||||
|
||||
impl MessageCommon {
|
||||
pub fn new(forward_kind: ForwardKind, media_kind: MediaKind) -> Self {
|
||||
Self {
|
||||
from: None,
|
||||
forward_kind,
|
||||
edit_date: None,
|
||||
media_kind,
|
||||
reply_markup: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from(mut self, val: User) -> Self {
|
||||
self.from = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn forward_kind(mut self, val: ForwardKind) -> Self {
|
||||
self.forward_kind = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn edit_date(mut self, val: i32) -> Self {
|
||||
self.edit_date = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn media_kind(mut self, val: MediaKind) -> Self {
|
||||
self.media_kind = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reply_markup(mut self, val: InlineKeyboardMarkup) -> Self {
|
||||
self.reply_markup = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageNewChatMembers {
|
||||
/// New members that were added to the group or supergroup and
|
||||
|
@ -154,25 +80,6 @@ pub struct MessageNewChatMembers {
|
|||
pub new_chat_members: Vec<User>,
|
||||
}
|
||||
|
||||
impl MessageNewChatMembers {
|
||||
pub fn new<N>(new_chat_members: N) -> Self
|
||||
where
|
||||
N: Into<Vec<User>>,
|
||||
{
|
||||
Self {
|
||||
new_chat_members: new_chat_members.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_chat_members<N>(mut self, val: N) -> Self
|
||||
where
|
||||
N: Into<Vec<User>>,
|
||||
{
|
||||
self.new_chat_members = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageLeftChatMember {
|
||||
/// A member was removed from the group, information about them (this
|
||||
|
@ -180,99 +87,30 @@ pub struct MessageLeftChatMember {
|
|||
pub left_chat_member: User,
|
||||
}
|
||||
|
||||
impl MessageLeftChatMember {
|
||||
pub fn new<N>(left_chat_member: N) -> Self
|
||||
where
|
||||
N: Into<User>,
|
||||
{
|
||||
Self {
|
||||
left_chat_member: left_chat_member.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn left_chat_member<N>(mut self, val: N) -> Self
|
||||
where
|
||||
N: Into<User>,
|
||||
{
|
||||
self.left_chat_member = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageNewChatTitle {
|
||||
/// A chat title was changed to this value.
|
||||
pub new_chat_title: String,
|
||||
}
|
||||
|
||||
impl MessageNewChatTitle {
|
||||
pub fn new<N>(new_chat_title: N) -> Self
|
||||
where
|
||||
N: Into<String>,
|
||||
{
|
||||
Self {
|
||||
new_chat_title: new_chat_title.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_chat_title<N>(mut self, val: N) -> Self
|
||||
where
|
||||
N: Into<String>,
|
||||
{
|
||||
self.new_chat_title = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageNewChatPhoto {
|
||||
/// A chat photo was change to this value.
|
||||
pub new_chat_photo: Vec<PhotoSize>,
|
||||
}
|
||||
|
||||
impl MessageNewChatPhoto {
|
||||
pub fn new<N>(new_chat_photo: N) -> Self
|
||||
where
|
||||
N: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
Self {
|
||||
new_chat_photo: new_chat_photo.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_chat_photo<N>(mut self, val: N) -> Self
|
||||
where
|
||||
N: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
self.new_chat_photo = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageDeleteChatPhoto {
|
||||
/// Service message: the chat photo was deleted.
|
||||
pub delete_chat_photo: True,
|
||||
}
|
||||
|
||||
impl MessageDeleteChatPhoto {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageGroupChatCreated {
|
||||
/// Service message: the group has been created.
|
||||
pub group_chat_created: True,
|
||||
}
|
||||
|
||||
impl MessageGroupChatCreated {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageSupergroupChatCreated {
|
||||
/// Service message: the supergroup has been created. This field can‘t
|
||||
|
@ -283,12 +121,6 @@ pub struct MessageSupergroupChatCreated {
|
|||
pub supergroup_chat_created: True,
|
||||
}
|
||||
|
||||
impl MessageSupergroupChatCreated {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageChannelChatCreated {
|
||||
/// Service message: the channel has been created. This field can‘t be
|
||||
|
@ -299,12 +131,6 @@ pub struct MessageChannelChatCreated {
|
|||
pub channel_chat_created: True,
|
||||
}
|
||||
|
||||
impl MessageChannelChatCreated {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageMigrate {
|
||||
/// The group has been migrated to a supergroup with the specified
|
||||
|
@ -324,25 +150,6 @@ pub struct MessageMigrate {
|
|||
pub migrate_from_chat_id: i64,
|
||||
}
|
||||
|
||||
impl MessageMigrate {
|
||||
pub fn new(migrate_to_chat_id: i64, migrate_from_chat_id: i64) -> Self {
|
||||
Self {
|
||||
migrate_to_chat_id,
|
||||
migrate_from_chat_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn migrate_to_chat_id(mut self, val: i64) -> Self {
|
||||
self.migrate_to_chat_id = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn migrate_from_chat_id(mut self, val: i64) -> Self {
|
||||
self.migrate_from_chat_id = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessagePinned {
|
||||
/// Specified message was pinned. Note that the Message object in this
|
||||
|
@ -352,19 +159,6 @@ pub struct MessagePinned {
|
|||
pub pinned: Box<Message>,
|
||||
}
|
||||
|
||||
impl MessagePinned {
|
||||
pub fn new(pinned: Message) -> Self {
|
||||
Self {
|
||||
pinned: Box::new(pinned),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pinned(mut self, val: Message) -> Self {
|
||||
self.pinned = Box::new(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageInvoice {
|
||||
/// Message is an invoice for a [payment], information about the
|
||||
|
@ -375,17 +169,6 @@ pub struct MessageInvoice {
|
|||
pub invoice: Invoice,
|
||||
}
|
||||
|
||||
impl MessageInvoice {
|
||||
pub fn new(invoice: Invoice) -> Self {
|
||||
Self { invoice }
|
||||
}
|
||||
|
||||
pub fn invoice(mut self, val: Invoice) -> Self {
|
||||
self.invoice = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageSuccessfulPayment {
|
||||
/// Message is a service message about a successful payment,
|
||||
|
@ -395,17 +178,6 @@ pub struct MessageSuccessfulPayment {
|
|||
pub successful_payment: SuccessfulPayment,
|
||||
}
|
||||
|
||||
impl MessageSuccessfulPayment {
|
||||
pub fn new(successful_payment: SuccessfulPayment) -> Self {
|
||||
Self { successful_payment }
|
||||
}
|
||||
|
||||
pub fn successful_payment(mut self, val: SuccessfulPayment) -> Self {
|
||||
self.successful_payment = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageConnectedWebsite {
|
||||
/// The domain name of the website on which the user has logged in.
|
||||
|
@ -415,42 +187,12 @@ pub struct MessageConnectedWebsite {
|
|||
pub connected_website: String,
|
||||
}
|
||||
|
||||
impl MessageConnectedWebsite {
|
||||
pub fn new<S>(connected_website: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
connected_website: connected_website.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn connected_website<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.connected_website = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessagePassportData {
|
||||
/// Telegram Passport data.
|
||||
pub passport_data: PassportData,
|
||||
}
|
||||
|
||||
impl MessagePassportData {
|
||||
pub fn new(passport_data: PassportData) -> Self {
|
||||
Self { passport_data }
|
||||
}
|
||||
|
||||
pub fn passport_data(mut self, val: PassportData) -> Self {
|
||||
self.passport_data = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub enum ForwardedFrom {
|
||||
#[serde(rename = "forward_from")]
|
||||
|
@ -482,40 +224,6 @@ pub struct ForwardChannel {
|
|||
pub signature: Option<String>,
|
||||
}
|
||||
|
||||
impl ForwardChannel {
|
||||
pub fn new(date: i32, chat: Chat, message_id: i32) -> Self {
|
||||
Self {
|
||||
date,
|
||||
chat,
|
||||
message_id,
|
||||
signature: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn date(mut self, val: i32) -> Self {
|
||||
self.date = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn chat(mut self, val: Chat) -> Self {
|
||||
self.chat = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn message_id(mut self, val: i32) -> Self {
|
||||
self.message_id = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn signature<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.signature = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ForwardNonChannel {
|
||||
#[serde(rename = "forward_date")]
|
||||
|
@ -525,38 +233,11 @@ pub struct ForwardNonChannel {
|
|||
pub from: ForwardedFrom,
|
||||
}
|
||||
|
||||
impl ForwardNonChannel {
|
||||
pub fn new(date: i32, from: ForwardedFrom) -> Self {
|
||||
Self { date, from }
|
||||
}
|
||||
|
||||
pub fn date(mut self, val: i32) -> Self {
|
||||
self.date = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn from(mut self, val: ForwardedFrom) -> Self {
|
||||
self.from = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ForwardOrigin {
|
||||
pub reply_to_message: Option<Box<Message>>,
|
||||
}
|
||||
|
||||
impl ForwardOrigin {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn reply_to_message(mut self, val: Message) -> Self {
|
||||
self.reply_to_message = Some(Box::new(val));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum MediaKind {
|
||||
|
@ -597,41 +278,6 @@ pub struct MediaAnimation {
|
|||
pub caption_entities: Vec<MessageEntity>,
|
||||
}
|
||||
|
||||
impl MediaAnimation {
|
||||
pub fn new<CE>(animation: Animation, caption_entities: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
animation,
|
||||
document: (),
|
||||
caption: None,
|
||||
caption_entities: caption_entities.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn animation(mut self, val: Animation) -> Self {
|
||||
self.animation = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.caption = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption_entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.caption_entities = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaAudio {
|
||||
|
@ -647,57 +293,12 @@ pub struct MediaAudio {
|
|||
pub caption_entities: Vec<MessageEntity>,
|
||||
}
|
||||
|
||||
impl MediaAudio {
|
||||
pub fn new<CE>(audio: Audio, caption_entities: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
audio,
|
||||
caption: None,
|
||||
caption_entities: caption_entities.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn audio(mut self, val: Audio) -> Self {
|
||||
self.audio = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.caption = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption_entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.caption_entities = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaContact {
|
||||
/// Message is a shared contact, information about the contact.
|
||||
contact: Contact,
|
||||
}
|
||||
|
||||
impl MediaContact {
|
||||
pub fn new(contact: Contact) -> Self {
|
||||
Self { contact }
|
||||
}
|
||||
|
||||
pub fn contact(mut self, val: Contact) -> Self {
|
||||
self.contact = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaDocument {
|
||||
|
@ -713,40 +314,6 @@ pub struct MediaDocument {
|
|||
pub caption_entities: Vec<MessageEntity>,
|
||||
}
|
||||
|
||||
impl MediaDocument {
|
||||
pub fn new<CE>(document: Document, caption_entities: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
document,
|
||||
caption: None,
|
||||
caption_entities: caption_entities.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn document(mut self, val: Document) -> Self {
|
||||
self.document = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.caption = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption_entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.caption_entities = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaGame {
|
||||
/// Message is a game, information about the game. [More
|
||||
|
@ -756,34 +323,12 @@ pub struct MediaGame {
|
|||
pub game: Game,
|
||||
}
|
||||
|
||||
impl MediaGame {
|
||||
pub fn new(game: Game) -> Self {
|
||||
Self { game }
|
||||
}
|
||||
|
||||
pub fn game(mut self, val: Game) -> Self {
|
||||
self.game = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaLocation {
|
||||
/// Message is a shared location, information about the location.
|
||||
pub location: Location,
|
||||
}
|
||||
|
||||
impl MediaLocation {
|
||||
pub fn new(location: Location) -> Self {
|
||||
Self { location }
|
||||
}
|
||||
|
||||
pub fn location(mut self, val: Location) -> Self {
|
||||
self.location = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaPhoto {
|
||||
|
@ -803,87 +348,18 @@ pub struct MediaPhoto {
|
|||
pub media_group_id: Option<String>,
|
||||
}
|
||||
|
||||
impl MediaPhoto {
|
||||
pub fn new<P, CE>(photo: P, caption_entities: CE) -> Self
|
||||
where
|
||||
P: Into<Vec<PhotoSize>>,
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
photo: photo.into(),
|
||||
caption: None,
|
||||
caption_entities: caption_entities.into(),
|
||||
media_group_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn photo<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
self.photo = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.caption = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption_entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.caption_entities = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn media_group_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.media_group_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaPoll {
|
||||
/// Message is a native poll, information about the poll.
|
||||
pub poll: Poll,
|
||||
}
|
||||
|
||||
impl MediaPoll {
|
||||
pub fn new(poll: Poll) -> Self {
|
||||
Self { poll }
|
||||
}
|
||||
|
||||
pub fn poll(mut self, val: Poll) -> Self {
|
||||
self.poll = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaSticker {
|
||||
/// Message is a sticker, information about the sticker.
|
||||
pub sticker: Sticker,
|
||||
}
|
||||
|
||||
impl MediaSticker {
|
||||
pub fn new(sticker: Sticker) -> Self {
|
||||
Self { sticker }
|
||||
}
|
||||
|
||||
pub fn poll(mut self, val: Sticker) -> Self {
|
||||
self.sticker = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaText {
|
||||
/// For text messages, the actual UTF-8 text of the message, 0-4096
|
||||
|
@ -896,35 +372,6 @@ pub struct MediaText {
|
|||
pub entities: Vec<MessageEntity>,
|
||||
}
|
||||
|
||||
impl MediaText {
|
||||
pub fn new<S, E>(text: S, entities: E) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
E: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
text: text.into(),
|
||||
entities: entities.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.text = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.entities = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaVideo {
|
||||
|
@ -944,49 +391,6 @@ pub struct MediaVideo {
|
|||
pub media_group_id: Option<String>,
|
||||
}
|
||||
|
||||
impl MediaVideo {
|
||||
pub fn new<CE>(video: Video, caption_entities: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
video,
|
||||
caption: None,
|
||||
caption_entities: caption_entities.into(),
|
||||
media_group_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn video(mut self, val: Video) -> Self {
|
||||
self.video = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.caption = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption_entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.caption_entities = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn media_group_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.media_group_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaVideoNote {
|
||||
/// Message is a [video note], information about the video message.
|
||||
|
@ -995,17 +399,6 @@ pub struct MediaVideoNote {
|
|||
pub video_note: VideoNote,
|
||||
}
|
||||
|
||||
impl MediaVideoNote {
|
||||
pub fn new(video_note: VideoNote) -> Self {
|
||||
Self { video_note }
|
||||
}
|
||||
|
||||
pub fn video_note(mut self, val: VideoNote) -> Self {
|
||||
self.video_note = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaVoice {
|
||||
|
@ -1021,57 +414,12 @@ pub struct MediaVoice {
|
|||
pub caption_entities: Vec<MessageEntity>,
|
||||
}
|
||||
|
||||
impl MediaVoice {
|
||||
pub fn new<CE>(voice: Voice, caption_entities: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
Self {
|
||||
voice,
|
||||
caption: None,
|
||||
caption_entities: caption_entities.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn voice(mut self, val: Voice) -> Self {
|
||||
self.voice = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.caption = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn caption_entities<CE>(mut self, val: CE) -> Self
|
||||
where
|
||||
CE: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.caption_entities = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MediaVenue {
|
||||
/// Message is a venue, information about the venue.
|
||||
pub venue: Venue,
|
||||
}
|
||||
|
||||
impl MediaVenue {
|
||||
pub fn new(venue: Venue) -> Self {
|
||||
Self { venue }
|
||||
}
|
||||
|
||||
pub fn venue(mut self, val: Venue) -> Self {
|
||||
self.venue = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessageDice {
|
||||
/// Message is a dice with random value from 1 to 6.
|
||||
|
|
|
@ -20,7 +20,7 @@ pub struct MessageEntity {
|
|||
}
|
||||
|
||||
impl MessageEntity {
|
||||
pub fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self {
|
||||
pub const fn new(kind: MessageEntityKind, offset: usize, length: usize) -> Self {
|
||||
Self {
|
||||
kind,
|
||||
offset,
|
||||
|
@ -33,12 +33,12 @@ impl MessageEntity {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn offset(mut self, val: usize) -> Self {
|
||||
pub const fn offset(mut self, val: usize) -> Self {
|
||||
self.offset = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn length(mut self, val: usize) -> Self {
|
||||
pub const fn length(mut self, val: usize) -> Self {
|
||||
self.length = val;
|
||||
self
|
||||
}
|
||||
|
|
|
@ -19,53 +19,3 @@ pub struct OrderInfo {
|
|||
/// User's shipping address.
|
||||
pub shipping_address: ShippingAddress,
|
||||
}
|
||||
|
||||
impl OrderInfo {
|
||||
pub fn new<S1, S2, S3>(
|
||||
name: S1,
|
||||
phone_number: S2,
|
||||
email: S3,
|
||||
shipping_address: ShippingAddress,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
{
|
||||
Self {
|
||||
name: name.into(),
|
||||
phone_number: phone_number.into(),
|
||||
email: email.into(),
|
||||
shipping_address,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.name = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn phone_number<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.phone_number = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn email<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.email = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn shipping_address(mut self, val: ShippingAddress) -> Self {
|
||||
self.shipping_address = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,28 +15,3 @@ pub struct PassportData {
|
|||
/// Encrypted credentials required to decrypt the data.
|
||||
pub credentials: EncryptedCredentials,
|
||||
}
|
||||
|
||||
impl PassportData {
|
||||
pub fn new<E>(data: E, credentials: EncryptedCredentials) -> Self
|
||||
where
|
||||
E: Into<Vec<EncryptedPassportElement>>,
|
||||
{
|
||||
Self {
|
||||
data: data.into(),
|
||||
credentials,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn data<E>(mut self, val: E) -> Self
|
||||
where
|
||||
E: Into<Vec<EncryptedPassportElement>>,
|
||||
{
|
||||
self.data = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn credentials(mut self, val: EncryptedCredentials) -> Self {
|
||||
self.credentials = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,44 +22,3 @@ pub struct PassportFile {
|
|||
/// Unix time when the file was uploaded.
|
||||
pub file_date: u64,
|
||||
}
|
||||
|
||||
impl PassportFile {
|
||||
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, file_size: u64, file_date: u64) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
file_size,
|
||||
file_date,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u64) -> Self {
|
||||
self.file_size = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_date(mut self, val: u64) -> Self {
|
||||
self.file_date = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,53 +25,6 @@ pub struct PhotoSize {
|
|||
pub file_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl PhotoSize {
|
||||
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, width: i32, height: i32) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
width,
|
||||
height,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, val: i32) -> Self {
|
||||
self.width = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(mut self, val: i32) -> Self {
|
||||
self.height = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -46,128 +46,11 @@ pub struct Poll {
|
|||
pub explanation_entities: Option<Vec<MessageEntity>>,
|
||||
|
||||
/// Amount of time in seconds the poll will be active after creation.
|
||||
open_period: Option<i32>,
|
||||
pub open_period: Option<i32>,
|
||||
|
||||
/// Point in time (Unix timestamp) when the poll will be automatically
|
||||
/// closed.
|
||||
close_date: Option<i32>,
|
||||
}
|
||||
|
||||
impl Poll {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new<S1, S2, O>(
|
||||
id: S1,
|
||||
question: S2,
|
||||
options: O,
|
||||
is_closed: bool,
|
||||
total_voter_count: i32,
|
||||
is_anonymous: bool,
|
||||
poll_type: PollType,
|
||||
allows_multiple_answers: bool,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
O: Into<Vec<PollOption>>,
|
||||
{
|
||||
Self {
|
||||
id: id.into(),
|
||||
question: question.into(),
|
||||
options: options.into(),
|
||||
is_closed,
|
||||
total_voter_count,
|
||||
is_anonymous,
|
||||
poll_type,
|
||||
allows_multiple_answers,
|
||||
correct_option_id: None,
|
||||
explanation: None,
|
||||
explanation_entities: None,
|
||||
open_period: None,
|
||||
close_date: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn question<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.question = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn options<P>(mut self, val: P) -> Self
|
||||
where
|
||||
P: Into<Vec<PollOption>>,
|
||||
{
|
||||
self.options = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
pub fn is_closed(mut self, val: bool) -> Self {
|
||||
self.is_closed = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn total_voter_count(mut self, val: i32) -> Self {
|
||||
self.total_voter_count = val;
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
pub fn is_anonymous(mut self, val: bool) -> Self {
|
||||
self.is_anonymous = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn poll_type(mut self, val: PollType) -> Self {
|
||||
self.poll_type = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn allows_multiple_answers(mut self, val: bool) -> Self {
|
||||
self.allows_multiple_answers = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn correct_option_id(mut self, val: i32) -> Self {
|
||||
self.correct_option_id = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn explanation<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.explanation = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn explanation_entities<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<Vec<MessageEntity>>,
|
||||
{
|
||||
self.explanation_entities = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn open_period(mut self, val: i32) -> Self {
|
||||
self.open_period = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn close_date(mut self, val: i32) -> Self {
|
||||
self.close_date = Some(val);
|
||||
self
|
||||
}
|
||||
pub close_date: Option<i32>,
|
||||
}
|
||||
|
||||
/// This object contains information about one answer option in a poll.
|
||||
|
@ -182,31 +65,6 @@ pub struct PollOption {
|
|||
pub voter_count: i32,
|
||||
}
|
||||
|
||||
impl PollOption {
|
||||
pub fn new<S>(text: S, voter_count: i32) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
text: text.into(),
|
||||
voter_count,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.text = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn voter_count(mut self, val: i32) -> Self {
|
||||
self.voter_count = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -14,38 +14,3 @@ pub struct PollAnswer {
|
|||
/// May be empty if the user retracted their vote.
|
||||
pub option_ids: Vec<i32>,
|
||||
}
|
||||
|
||||
impl PollAnswer {
|
||||
pub fn new<S, O>(poll_id: S, user: User, option_ids: O) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
O: Into<Vec<i32>>,
|
||||
{
|
||||
Self {
|
||||
poll_id: poll_id.into(),
|
||||
user,
|
||||
option_ids: option_ids.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn poll_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.poll_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn user(mut self, val: User) -> Self {
|
||||
self.user = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn option_ids<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<Vec<i32>>,
|
||||
{
|
||||
self.option_ids = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,71 +37,3 @@ pub struct PreCheckoutQuery {
|
|||
/// Order info provided by the user.
|
||||
pub order_info: Option<OrderInfo>,
|
||||
}
|
||||
|
||||
impl PreCheckoutQuery {
|
||||
pub fn new<S1, S2>(
|
||||
id: S1,
|
||||
from: User,
|
||||
currency: Currency,
|
||||
total_amount: i32,
|
||||
invoice_payload: S2,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
id: id.into(),
|
||||
from,
|
||||
currency,
|
||||
total_amount,
|
||||
invoice_payload: invoice_payload.into(),
|
||||
shipping_option_id: None,
|
||||
order_info: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn from(mut self, val: User) -> Self {
|
||||
self.from = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn currency<S>(mut self, val: Currency) -> Self {
|
||||
self.currency = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn total_amount(mut self, val: i32) -> Self {
|
||||
self.total_amount = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn invoice_payload<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.invoice_payload = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn shipping_option_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.shipping_option_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn order_info(mut self, val: OrderInfo) -> Self {
|
||||
self.order_info = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,15 +37,15 @@ pub struct ReplyKeyboardRemove {
|
|||
}
|
||||
|
||||
impl ReplyKeyboardRemove {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
remove_keyboard: True,
|
||||
selective: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn selective<T>(mut self, val: T) -> Self
|
||||
where
|
||||
T: Into<bool>,
|
||||
{
|
||||
self.selective = Some(val.into());
|
||||
pub const fn selective(mut self, val: bool) -> Self {
|
||||
self.selective = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,76 +24,3 @@ pub struct ShippingAddress {
|
|||
/// Address post code.
|
||||
pub post_code: String,
|
||||
}
|
||||
|
||||
impl ShippingAddress {
|
||||
pub fn new<S1, S2, S3, S4, S5>(
|
||||
country_code: CountryCode,
|
||||
|
||||
state: S1,
|
||||
city: S2,
|
||||
street_line1: S3,
|
||||
street_line2: S4,
|
||||
post_code: S5,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
S4: Into<String>,
|
||||
S5: Into<String>,
|
||||
{
|
||||
Self {
|
||||
country_code,
|
||||
state: state.into(),
|
||||
city: city.into(),
|
||||
street_line1: street_line1.into(),
|
||||
street_line2: street_line2.into(),
|
||||
post_code: post_code.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn country_code(mut self, val: CountryCode) -> Self {
|
||||
self.country_code = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn state<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.state = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn city<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.city = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn street_line1<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.street_line1 = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn street_line2<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.street_line2 = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn post_code<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.post_code = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,49 +19,3 @@ pub struct ShippingQuery {
|
|||
/// User specified shipping address.
|
||||
pub shipping_address: ShippingAddress,
|
||||
}
|
||||
|
||||
impl ShippingQuery {
|
||||
pub fn new<S1, S2>(
|
||||
id: S1,
|
||||
from: User,
|
||||
invoice_payload: S2,
|
||||
shipping_address: ShippingAddress,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
id: id.into(),
|
||||
from,
|
||||
invoice_payload: invoice_payload.into(),
|
||||
shipping_address,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn from<S>(mut self, val: User) -> Self {
|
||||
self.from = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn invoice_payload<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.invoice_payload = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn shipping_address<S>(mut self, val: ShippingAddress) -> Self {
|
||||
self.shipping_address = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,93 +42,3 @@ pub struct Sticker {
|
|||
/// File size.
|
||||
pub file_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl Sticker {
|
||||
pub fn new<S1, S2>(
|
||||
file_id: S1,
|
||||
file_unique_id: S2,
|
||||
width: u16,
|
||||
height: u16,
|
||||
is_animated: bool,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
width,
|
||||
height,
|
||||
is_animated,
|
||||
thumb: None,
|
||||
emoji: None,
|
||||
set_name: None,
|
||||
mask_position: None,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(mut self, val: u16) -> Self {
|
||||
self.height = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, val: u16) -> Self {
|
||||
self.width = val;
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
pub fn is_animated(mut self, val: bool) -> Self {
|
||||
self.is_animated = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: PhotoSize) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn emoji<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.emoji = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.set_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mask_position(mut self, val: MaskPosition) -> Self {
|
||||
self.mask_position = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,62 +27,3 @@ pub struct StickerSet {
|
|||
/// Sticker set thumbnail in the .WEBP or .TGS format.
|
||||
thumb: Option<PhotoSize>,
|
||||
}
|
||||
|
||||
impl StickerSet {
|
||||
pub fn new<S1, S2, St>(
|
||||
name: S1,
|
||||
title: S2,
|
||||
is_animated: bool,
|
||||
contains_masks: bool,
|
||||
stickers: St,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
St: Into<Vec<Sticker>>,
|
||||
{
|
||||
Self {
|
||||
name: name.into(),
|
||||
title: title.into(),
|
||||
is_animated,
|
||||
contains_masks,
|
||||
stickers: stickers.into(),
|
||||
thumb: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.name = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.title = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
pub fn is_animated(mut self, val: bool) -> Self {
|
||||
self.is_animated = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn contains_masks(mut self, val: bool) -> Self {
|
||||
self.contains_masks = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn stickers<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<Vec<Sticker>>,
|
||||
{
|
||||
self.stickers = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,75 +37,3 @@ pub struct SuccessfulPayment {
|
|||
/// Provider payment identifier.
|
||||
pub provider_payment_charge_id: String,
|
||||
}
|
||||
|
||||
impl SuccessfulPayment {
|
||||
pub fn new<S1, S2, S3>(
|
||||
currency: Currency,
|
||||
total_amount: i32,
|
||||
invoice_payload: S1,
|
||||
telegram_payment_charge_id: S2,
|
||||
provider_payment_charge_id: S3,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
S3: Into<String>,
|
||||
{
|
||||
Self {
|
||||
currency,
|
||||
total_amount,
|
||||
invoice_payload: invoice_payload.into(),
|
||||
shipping_option_id: None,
|
||||
order_info: None,
|
||||
telegram_payment_charge_id: telegram_payment_charge_id.into(),
|
||||
provider_payment_charge_id: provider_payment_charge_id.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn currency<S>(mut self, val: Currency) -> Self {
|
||||
self.currency = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn total_amount(mut self, val: i32) -> Self {
|
||||
self.total_amount = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn invoice_payload<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.invoice_payload = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn shipping_option_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.shipping_option_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn order_info(mut self, val: OrderInfo) -> Self {
|
||||
self.order_info = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn telegram_payment_charge_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.telegram_payment_charge_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn provider_payment_charge_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.provider_payment_charge_id = val.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,22 +28,6 @@ pub struct Update {
|
|||
pub kind: UpdateKind,
|
||||
}
|
||||
|
||||
impl Update {
|
||||
pub fn new(id: i32, kind: UpdateKind) -> Self {
|
||||
Self { id, kind }
|
||||
}
|
||||
|
||||
pub fn id<S>(mut self, val: i32) -> Self {
|
||||
self.id = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn kind<S>(mut self, val: UpdateKind) -> Self {
|
||||
self.kind = val;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum UpdateKind {
|
||||
|
|
|
@ -27,65 +27,6 @@ pub struct User {
|
|||
pub language_code: Option<String>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn new<S>(id: i32, is_bot: bool, first_name: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
id,
|
||||
is_bot,
|
||||
first_name: first_name.into(),
|
||||
last_name: None,
|
||||
username: None,
|
||||
language_code: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id<S>(mut self, val: i32) -> Self {
|
||||
self.id = val;
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
pub fn is_bot<S>(mut self, val: bool) -> Self {
|
||||
self.is_bot = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn first_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.first_name = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_name<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.last_name = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn username<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.username = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn language_code<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.language_code = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn full_name(&self) -> String {
|
||||
match &self.last_name {
|
||||
|
|
|
@ -13,30 +13,3 @@ pub struct UserProfilePhotos {
|
|||
/// Requested profile pictures (in up to 4 sizes each).
|
||||
pub photos: Vec<Vec<PhotoSize>>,
|
||||
}
|
||||
|
||||
impl UserProfilePhotos {
|
||||
pub fn new<P1, P2>(total_count: u32, photos: P1) -> Self
|
||||
where
|
||||
P1: Into<Vec<P2>>,
|
||||
P2: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
Self {
|
||||
total_count,
|
||||
photos: photos.into().into_iter().map(Into::into).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn total_count(mut self, val: u32) -> Self {
|
||||
self.total_count = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn photos<P1, P2>(mut self, val: P1) -> Self
|
||||
where
|
||||
P1: Into<Vec<P2>>,
|
||||
P2: Into<Vec<PhotoSize>>,
|
||||
{
|
||||
self.photos = val.into().into_iter().map(Into::into).collect();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,51 +23,3 @@ pub struct Venue {
|
|||
/// `food/icecream`.)
|
||||
pub foursquare_type: Option<String>,
|
||||
}
|
||||
|
||||
impl Venue {
|
||||
pub fn new<S1, S2>(location: Location, title: S1, address: S2) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
location,
|
||||
title: title.into(),
|
||||
address: address.into(),
|
||||
foursquare_id: None,
|
||||
foursquare_type: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.title = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn address<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.address = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn foursquare_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.foursquare_id = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn foursquare_type<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.foursquare_type = Some(val.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,74 +36,3 @@ pub struct Video {
|
|||
/// File size.
|
||||
pub file_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl Video {
|
||||
pub fn new<S1, S2>(
|
||||
file_id: S1,
|
||||
file_unique_id: S2,
|
||||
width: u32,
|
||||
height: u32,
|
||||
duration: u32,
|
||||
) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
width,
|
||||
height,
|
||||
duration,
|
||||
thumb: None,
|
||||
mime_type: None,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn width(mut self, val: u32) -> Self {
|
||||
self.width = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn height(mut self, val: u32) -> Self {
|
||||
self.height = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u32) -> Self {
|
||||
self.duration = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: PhotoSize) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||
self.mime_type = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,56 +33,3 @@ pub struct VideoNote {
|
|||
/// File size.
|
||||
pub file_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl VideoNote {
|
||||
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, length: u32, duration: u32) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
length,
|
||||
duration,
|
||||
thumb: None,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn length(mut self, val: u32) -> Self {
|
||||
self.length = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u32) -> Self {
|
||||
self.duration = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn thumb(mut self, val: PhotoSize) -> Self {
|
||||
self.thumb = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u32) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,50 +25,3 @@ pub struct Voice {
|
|||
/// File size.
|
||||
pub file_size: Option<u64>,
|
||||
}
|
||||
|
||||
impl Voice {
|
||||
pub fn new<S1, S2>(file_id: S1, file_unique_id: S2, duration: u32) -> Self
|
||||
where
|
||||
S1: Into<String>,
|
||||
S2: Into<String>,
|
||||
{
|
||||
Self {
|
||||
file_id: file_id.into(),
|
||||
file_unique_id: file_unique_id.into(),
|
||||
duration,
|
||||
mime_type: None,
|
||||
file_size: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_unique_id<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.file_unique_id = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn duration(mut self, val: u32) -> Self {
|
||||
self.duration = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn mime_type(mut self, val: Mime) -> Self {
|
||||
self.mime_type = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn file_size(mut self, val: u64) -> Self {
|
||||
self.file_size = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,66 +32,3 @@ pub struct WebhookInfo {
|
|||
/// types.
|
||||
pub allowed_updates: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl WebhookInfo {
|
||||
pub fn new<S>(url: S, has_custom_certificate: bool, pending_update_count: u32) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Self {
|
||||
url: url.into(),
|
||||
has_custom_certificate,
|
||||
pending_update_count,
|
||||
last_error_date: None,
|
||||
|
||||
last_error_message: None,
|
||||
max_connections: None,
|
||||
allowed_updates: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn url<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.url = val.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn has_custom_certificate(mut self, val: bool) -> Self {
|
||||
self.has_custom_certificate = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn pending_update_count(mut self, val: u32) -> Self {
|
||||
self.pending_update_count = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_error_date(mut self, val: u64) -> Self {
|
||||
self.last_error_date = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn last_error_message<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.last_error_message = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn max_connections(mut self, val: u32) -> Self {
|
||||
self.max_connections = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn allowed_updates<A, S>(mut self, val: A) -> Self
|
||||
where
|
||||
A: Into<Vec<S>>,
|
||||
S: Into<String>,
|
||||
{
|
||||
self.allowed_updates = Some(val.into().into_iter().map(Into::into).collect());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue