mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Merge pull request #17 from async-telegram-bot/bug/fmt
cargo fmt for all project files
This commit is contained in:
commit
a8f04a8d4c
28 changed files with 266 additions and 245 deletions
|
@ -4,16 +4,12 @@ use crate::core::{
|
|||
};
|
||||
|
||||
use apply::Apply;
|
||||
use serde_json::Value;
|
||||
use serde::{
|
||||
Serialize,
|
||||
de::DeserializeOwned
|
||||
};
|
||||
use reqwest::{
|
||||
r#async::{multipart::Form, Client},
|
||||
StatusCode,
|
||||
r#async::{Client, multipart::Form},
|
||||
};
|
||||
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
const TELEGRAM_API_URL: &str = "https://api.telegram.org";
|
||||
|
||||
|
@ -58,12 +54,9 @@ pub async fn request_multipart<T: DeserializeOwned>(
|
|||
.map_err(RequestError::NetworkError)?;
|
||||
|
||||
let response = serde_json::from_str::<TelegramResponse<T>>(
|
||||
&response
|
||||
.text()
|
||||
.await
|
||||
.map_err(RequestError::NetworkError)?,
|
||||
&response.text().await.map_err(RequestError::NetworkError)?,
|
||||
)
|
||||
.map_err(RequestError::InvalidJson)?;
|
||||
.map_err(RequestError::InvalidJson)?;
|
||||
|
||||
match response {
|
||||
TelegramResponse::Ok { result, .. } => Ok(result),
|
||||
|
@ -72,7 +65,10 @@ pub async fn request_multipart<T: DeserializeOwned>(
|
|||
error_code,
|
||||
response_parameters,
|
||||
..
|
||||
} => Err(RequestError::ApiError { description, status_code: StatusCode::from_u16(error_code).unwrap() })
|
||||
} => Err(RequestError::ApiError {
|
||||
description,
|
||||
status_code: StatusCode::from_u16(error_code).unwrap(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,10 +86,7 @@ pub async fn request_json<T: DeserializeOwned, P: Serialize>(
|
|||
.map_err(RequestError::NetworkError)?;
|
||||
|
||||
let response = serde_json::from_str::<TelegramResponse<T>>(
|
||||
&response
|
||||
.text()
|
||||
.await
|
||||
.map_err(RequestError::NetworkError)?,
|
||||
&response.text().await.map_err(RequestError::NetworkError)?,
|
||||
)
|
||||
.map_err(RequestError::InvalidJson)?;
|
||||
|
||||
|
@ -104,7 +97,10 @@ pub async fn request_json<T: DeserializeOwned, P: Serialize>(
|
|||
error_code,
|
||||
response_parameters,
|
||||
..
|
||||
} => Err(RequestError::ApiError { description, status_code: StatusCode::from_u16(error_code).unwrap() })
|
||||
} => Err(RequestError::ApiError {
|
||||
description,
|
||||
status_code: StatusCode::from_u16(error_code).unwrap(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use serde::Serialize;
|
||||
use crate::core::requests::{RequestContext, ChatId, Request, RequestFuture, ResponseResult};
|
||||
use crate::core::types::{Message, ReplyMarkup};
|
||||
use crate::core::network;
|
||||
use crate::core::requests::{
|
||||
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
|
||||
};
|
||||
use crate::core::types::{Message, ReplyMarkup};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
/// Use this method to edit live location messages. A location can be edited
|
||||
|
@ -13,16 +15,16 @@ pub struct EditMessageLiveLocation<'a> {
|
|||
#[serde(skip_serializing)]
|
||||
ctx: RequestContext<'a>,
|
||||
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Required if inline_message_id is not specified. Unique identifier for
|
||||
/// the target chat or username of the target channel (in the format
|
||||
/// @channelusername)
|
||||
chat_id: Option<ChatId>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Required if inline_message_id is not specified. Identifier of the
|
||||
/// message to edit
|
||||
message_id: Option<i64>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Required if chat_id and message_id are not specified. Identifier of
|
||||
/// the inline message
|
||||
inline_message_id: Option<String>,
|
||||
|
@ -30,9 +32,9 @@ pub struct EditMessageLiveLocation<'a> {
|
|||
latitude: f64,
|
||||
/// Longitude of new location
|
||||
longitude: f64,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// A JSON-serialized object for a new inline keyboard.
|
||||
reply_markup: Option<ReplyMarkup>
|
||||
reply_markup: Option<ReplyMarkup>,
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> for EditMessageLiveLocation<'a> {
|
||||
|
@ -44,14 +46,15 @@ impl<'a> Request<'a> for EditMessageLiveLocation<'a> {
|
|||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"editMessageLiveLocation",
|
||||
&self
|
||||
).await
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EditMessageLiveLocation<'a> {
|
||||
pub(crate) fn new (
|
||||
pub(crate) fn new(
|
||||
ctx: RequestContext<'a>,
|
||||
latitude: f64,
|
||||
longitude: f64,
|
||||
|
@ -63,7 +66,7 @@ impl<'a> EditMessageLiveLocation<'a> {
|
|||
inline_message_id: None,
|
||||
latitude,
|
||||
longitude,
|
||||
reply_markup: None
|
||||
reply_markup: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,8 @@ impl<'a> EditMessageLiveLocation<'a> {
|
|||
}
|
||||
|
||||
pub fn inline_message_id<T>(mut self, inline_message_id: T) -> Self
|
||||
where T: Into<String>
|
||||
where
|
||||
T: Into<String>,
|
||||
{
|
||||
self.inline_message_id = Some(inline_message_id.into());
|
||||
self
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use crate::core::{
|
||||
types::{ParseMode, InputMedia},
|
||||
requests::{ChatId, utils},
|
||||
requests::{utils, ChatId},
|
||||
types::{InputMedia, ParseMode},
|
||||
};
|
||||
|
||||
use reqwest::r#async::multipart::Form;
|
||||
use serde::Serialize;
|
||||
|
||||
|
||||
/// This is a convenient struct that builds `reqwest::r#async::multipart::Form`
|
||||
/// from scratch.
|
||||
pub struct FormBuilder {
|
||||
|
@ -22,20 +21,19 @@ impl FormBuilder {
|
|||
|
||||
/// Add the supplied key-value pair to this `FormBuilder`.
|
||||
pub fn add<T>(self, name: &str, value: &T) -> Self
|
||||
where T: ToFormValue + ?Sized
|
||||
where
|
||||
T: ToFormValue + ?Sized,
|
||||
{
|
||||
Self {
|
||||
form: self.form.text(
|
||||
name.to_owned(),
|
||||
value.to_form_value()
|
||||
)
|
||||
form: self.form.text(name.to_owned(), value.to_form_value()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds a key-value pair to the supplied `FormBuilder` if `value` is some.
|
||||
/// Don't forget to implement `serde::Serialize` for `T`!
|
||||
pub fn add_if_some<T>(self, name: &str, value: Option<&T>) -> Self
|
||||
where T: ToFormValue + ?Sized
|
||||
where
|
||||
T: ToFormValue + ?Sized,
|
||||
{
|
||||
match value {
|
||||
None => Self { form: self.form },
|
||||
|
@ -45,7 +43,9 @@ impl FormBuilder {
|
|||
|
||||
pub fn add_file(self, name: &str, path_to_file: &PathBuf) -> Self {
|
||||
Self {
|
||||
form: self.form.part(name.to_owned(), utils::file_to_part(path_to_file))
|
||||
form: self
|
||||
.form
|
||||
.part(name.to_owned(), utils::file_to_part(path_to_file)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,9 +70,7 @@ macro_rules! impl_for_struct {
|
|||
};
|
||||
}
|
||||
|
||||
impl_for_struct!(
|
||||
bool, i32, i64, Vec<InputMedia>
|
||||
);
|
||||
impl_for_struct!(bool, i32, i64, Vec<InputMedia>);
|
||||
|
||||
impl ToFormValue for str {
|
||||
fn to_form_value(&self) -> String {
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
use crate::core::{
|
||||
network,
|
||||
types::Message,
|
||||
requests::{
|
||||
ChatId,
|
||||
Request,
|
||||
RequestFuture,
|
||||
RequestContext,
|
||||
ResponseResult,
|
||||
form_builder::FormBuilder,
|
||||
form_builder::FormBuilder, ChatId, Request, RequestContext,
|
||||
RequestFuture, ResponseResult,
|
||||
},
|
||||
types::Message,
|
||||
};
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
/// Use this method to forward messages of any kind. On success, the sent
|
||||
/// [`Message`] is returned.
|
||||
|
@ -28,8 +23,9 @@ pub struct ForwardMessage<'a> {
|
|||
/// Message identifier in the chat specified in from_chat_id
|
||||
pub message_id: i64,
|
||||
|
||||
/// Sends the message silently. Users will receive a notification with no sound.
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
/// Sends the message silently. Users will receive a notification with no
|
||||
/// sound.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub disable_notification: Option<bool>,
|
||||
}
|
||||
|
||||
|
@ -43,22 +39,25 @@ impl<'a> Request<'a> for ForwardMessage<'a> {
|
|||
self.ctx.token,
|
||||
"forwardMessage",
|
||||
&self,
|
||||
).await
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ForwardMessage<'a> {
|
||||
pub(crate) fn new(ctx: RequestContext<'a>,
|
||||
chat_id: ChatId,
|
||||
from_chat_id: ChatId,
|
||||
message_id: i64) -> Self {
|
||||
pub(crate) fn new(
|
||||
ctx: RequestContext<'a>,
|
||||
chat_id: ChatId,
|
||||
from_chat_id: ChatId,
|
||||
message_id: i64,
|
||||
) -> Self {
|
||||
Self {
|
||||
ctx,
|
||||
chat_id,
|
||||
from_chat_id,
|
||||
message_id,
|
||||
disable_notification: None
|
||||
disable_notification: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
use crate::core::{
|
||||
network,
|
||||
requests::{Request, RequestContext, RequestFuture, ResponseResult},
|
||||
types::User,
|
||||
requests::{
|
||||
Request,
|
||||
RequestFuture,
|
||||
RequestContext,
|
||||
ResponseResult
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// A simple method for testing your bot's auth token. Requires no parameters.
|
||||
/// Returns basic information about the bot in form of a [`User`] object.
|
||||
|
@ -21,14 +15,12 @@ impl<'a> Request<'a> for GetMe<'a> {
|
|||
type ReturnValue = User;
|
||||
|
||||
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
|
||||
Box::pin(
|
||||
network::request_multipart(
|
||||
self.ctx.client,
|
||||
self.ctx.token,
|
||||
"getMe",
|
||||
None
|
||||
)
|
||||
)
|
||||
Box::pin(network::request_multipart(
|
||||
self.ctx.client,
|
||||
self.ctx.token,
|
||||
"getMe",
|
||||
None,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
use std::pin::Pin;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
use reqwest::{
|
||||
r#async::Client, StatusCode
|
||||
};
|
||||
use reqwest::{r#async::Client, StatusCode};
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
|
||||
mod form_builder;
|
||||
mod utils;
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
pub enum RequestError {
|
||||
#[display(fmt = "Telegram error #{}: {}", status_code, description)]
|
||||
ApiError { // TODO: add response parameters
|
||||
ApiError {
|
||||
// TODO: add response parameters
|
||||
status_code: StatusCode,
|
||||
description: String,
|
||||
},
|
||||
|
@ -82,20 +80,23 @@ mod tests {
|
|||
#[test]
|
||||
fn chat_id_channel_username_serialization() {
|
||||
let expected_json = String::from(r#""@username""#);
|
||||
let actual_json = serde_json::to_string(&ChatId::ChannelUsername(String::from("@username"))).unwrap();
|
||||
let actual_json = serde_json::to_string(&ChatId::ChannelUsername(
|
||||
String::from("@username"),
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(expected_json, actual_json)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod get_me;
|
||||
pub mod send_message;
|
||||
pub mod edit_message_live_location;
|
||||
pub mod forward_message;
|
||||
pub mod send_photo;
|
||||
pub mod send_media_group;
|
||||
pub mod get_me;
|
||||
pub mod send_audio;
|
||||
pub mod send_location;
|
||||
pub mod edit_message_live_location;
|
||||
pub mod send_media_group;
|
||||
pub mod send_message;
|
||||
pub mod send_photo;
|
||||
pub mod stop_message_live_location;
|
||||
pub mod send_venue;
|
||||
pub mod send_contact;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use crate::core::{
|
||||
network,
|
||||
requests::{ChatId, Request, RequestFuture, ResponseResult, RequestContext},
|
||||
requests::form_builder::FormBuilder,
|
||||
types::{InputFile, ParseMode, Message, ReplyMarkup},
|
||||
requests::{
|
||||
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
|
||||
},
|
||||
types::{InputFile, Message, ParseMode, ReplyMarkup},
|
||||
};
|
||||
|
||||
/// Use this method to send audio files, if you want Telegram clients to display
|
||||
|
@ -71,11 +73,11 @@ impl<'a> Request<'a> for SendAudio<'a> {
|
|||
.add_if_some("title", self.title.as_ref())
|
||||
.add_if_some(
|
||||
"disable_notification",
|
||||
self.disable_notification.as_ref()
|
||||
self.disable_notification.as_ref(),
|
||||
)
|
||||
.add_if_some(
|
||||
"reply_to_message_id",
|
||||
self.reply_to_message_id.as_ref()
|
||||
self.reply_to_message_id.as_ref(),
|
||||
);
|
||||
params = match self.audio {
|
||||
InputFile::File(file) => params.add_file("audio", &file),
|
||||
|
@ -95,8 +97,9 @@ impl<'a> Request<'a> for SendAudio<'a> {
|
|||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"sendAudio",
|
||||
Some(params)
|
||||
).await
|
||||
Some(params),
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +122,7 @@ impl<'a> SendAudio<'a> {
|
|||
thumb: None,
|
||||
disable_notification: None,
|
||||
reply_to_message_id: None,
|
||||
reply_markup: None
|
||||
reply_markup: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,12 +166,18 @@ impl<'a> SendAudio<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn disable_notification<T: Into<bool>>(mut self, disable_notification: T) -> Self {
|
||||
pub fn disable_notification<T: Into<bool>>(
|
||||
mut self,
|
||||
disable_notification: T,
|
||||
) -> Self {
|
||||
self.disable_notification = Some(disable_notification.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reply_to_message_id<T: Into<i64>>(mut self, reply_to_message_id: T) -> Self {
|
||||
pub fn reply_to_message_id<T: Into<i64>>(
|
||||
mut self,
|
||||
reply_to_message_id: T,
|
||||
) -> Self {
|
||||
self.reply_to_message_id = Some(reply_to_message_id.into());
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use crate::core::{
|
||||
requests::{RequestContext, ChatId, Request, RequestFuture, ResponseResult},
|
||||
types::{Message, ReplyMarkup},
|
||||
network,
|
||||
requests::{
|
||||
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
|
||||
},
|
||||
types::{Message, ReplyMarkup},
|
||||
};
|
||||
|
||||
use serde::Serialize;
|
||||
|
@ -20,19 +22,19 @@ pub struct SendLocation<'a> {
|
|||
latitude: f64,
|
||||
/// Longitude of the location
|
||||
longitude: f64,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Period in seconds for which the location will be updated
|
||||
/// (see [Live Locations](https://telegram.org/blog/live-locations)),
|
||||
/// should be between 60 and 86400.
|
||||
live_period: Option<i32>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Sends the message silently. Users will receive a notification with
|
||||
/// no sound.
|
||||
disable_notification: Option<bool>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// If the message is a reply, ID of the original message
|
||||
reply_to_message_id: Option<i64>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
reply_markup: Option<ReplyMarkup>,
|
||||
}
|
||||
|
||||
|
@ -45,8 +47,9 @@ impl<'a> Request<'a> for SendLocation<'a> {
|
|||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"sendLocation",
|
||||
&self
|
||||
).await
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +69,7 @@ impl<'a> SendLocation<'a> {
|
|||
live_period: None,
|
||||
disable_notification: None,
|
||||
reply_to_message_id: None,
|
||||
reply_markup: None
|
||||
reply_markup: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
use crate::core::{
|
||||
network::request_multipart,
|
||||
types::{Message, InputMedia, InputFile},
|
||||
requests::{
|
||||
ChatId,
|
||||
Request,
|
||||
RequestFuture,
|
||||
RequestContext,
|
||||
ResponseResult,
|
||||
form_builder::FormBuilder,
|
||||
}
|
||||
form_builder::FormBuilder, ChatId, Request, RequestContext,
|
||||
RequestFuture, ResponseResult,
|
||||
},
|
||||
types::{InputFile, InputMedia, Message},
|
||||
};
|
||||
use apply::Apply;
|
||||
|
||||
|
@ -32,28 +28,40 @@ impl<'a> Request<'a> for SendMediaGroup<'a> {
|
|||
let params = FormBuilder::new()
|
||||
.add("chat_id", &self.chat_id)
|
||||
.apply(|form| {
|
||||
self.media
|
||||
.iter()
|
||||
.map(|e| e.media())
|
||||
.fold(form, |acc, file| {
|
||||
self.media.iter().map(|e| e.media()).fold(
|
||||
form,
|
||||
|acc, file| {
|
||||
if let InputFile::File(path) = file {
|
||||
acc.add_file(
|
||||
&path
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy(),
|
||||
path
|
||||
&path
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy(),
|
||||
path,
|
||||
)
|
||||
} else {
|
||||
acc
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
})
|
||||
.add("media", &self.media)
|
||||
.add_if_some("disable_notification", self.disable_notification.as_ref())
|
||||
.add_if_some("reply_to_message_id", self.reply_to_message_id.as_ref())
|
||||
.add_if_some(
|
||||
"disable_notification",
|
||||
self.disable_notification.as_ref(),
|
||||
)
|
||||
.add_if_some(
|
||||
"reply_to_message_id",
|
||||
self.reply_to_message_id.as_ref(),
|
||||
)
|
||||
.build();
|
||||
request_multipart(&self.ctx.client, &self.ctx.token, "sendMediaGroup", Some(params)).await
|
||||
request_multipart(
|
||||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"sendMediaGroup",
|
||||
Some(params),
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
use crate::core::{
|
||||
network,
|
||||
types::{Message, ParseMode, ReplyMarkup},
|
||||
requests::{
|
||||
form_builder::FormBuilder,
|
||||
ChatId,
|
||||
Request,
|
||||
RequestFuture,
|
||||
RequestContext,
|
||||
ResponseResult,
|
||||
form_builder::FormBuilder, ChatId, Request, RequestContext,
|
||||
RequestFuture, ResponseResult,
|
||||
},
|
||||
types::{Message, ParseMode, ReplyMarkup},
|
||||
};
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
/// Use this method to send text messages. On success, the sent [`Message`] is returned.
|
||||
/// Use this method to send text messages. On success, the sent [`Message`] is
|
||||
/// returned.
|
||||
pub struct SendMessage<'a> {
|
||||
#[serde(skip_serializing)]
|
||||
ctx: RequestContext<'a>,
|
||||
|
@ -32,18 +28,19 @@ pub struct SendMessage<'a> {
|
|||
/// [Html]: crate::core::types::ParseMode::Html
|
||||
/// [bold, italic, fixed-width text or inline URLs]:
|
||||
/// crate::core::types::ParseMode
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub parse_mode: Option<ParseMode>,
|
||||
/// Disables link previews for links in this message
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub disable_web_page_preview: Option<bool>,
|
||||
/// Sends the message silently. Users will receive a notification with no sound.
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
/// Sends the message silently. Users will receive a notification with no
|
||||
/// sound.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub disable_notification: Option<bool>,
|
||||
/// If the message is a reply, ID of the original message
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reply_to_message_id: Option<i64>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reply_markup: Option<ReplyMarkup>,
|
||||
}
|
||||
|
||||
|
@ -57,7 +54,8 @@ impl<'a> Request<'a> for SendMessage<'a> {
|
|||
self.ctx.token,
|
||||
"sendMessage",
|
||||
&self,
|
||||
).await
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,16 @@ use std::path::Path;
|
|||
|
||||
use crate::core::{
|
||||
network,
|
||||
types::{ParseMode, Message, InputFile, ReplyMarkup},
|
||||
requests::{
|
||||
ChatId,
|
||||
Request,
|
||||
RequestFuture,
|
||||
RequestContext,
|
||||
ResponseResult,
|
||||
form_builder::FormBuilder,
|
||||
form_builder::FormBuilder, ChatId, Request, RequestContext,
|
||||
RequestFuture, ResponseResult,
|
||||
},
|
||||
types::{InputFile, Message, ParseMode, ReplyMarkup},
|
||||
};
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// Use this method to send photos. On success, the sent [`Message`] is returned.
|
||||
/// Use this method to send photos. On success, the sent [`Message`] is
|
||||
/// returned.
|
||||
pub struct SendPhoto<'a> {
|
||||
ctx: RequestContext<'a>,
|
||||
|
||||
|
@ -23,13 +19,14 @@ pub struct SendPhoto<'a> {
|
|||
/// (in the format @channelusername)
|
||||
pub chat_id: ChatId,
|
||||
/// Photo to send.
|
||||
/// [`InputFile::FileId`] - Pass a file_id as String to send a photo that exists on the
|
||||
/// Telegram servers (recommended)
|
||||
/// [`InputFile::FileId`] - Pass a file_id as String to send a photo that
|
||||
/// exists on the Telegram servers (recommended)
|
||||
/// [`InputFile::Url`] - Pass an HTTP URL as a String for Telegram
|
||||
/// to get a photo from the Internet
|
||||
/// [`InputFile::File`] - Upload a new photo.
|
||||
pub photo: InputFile,
|
||||
/// Photo caption (may also be used when resending photos by file_id), 0-1024 characters
|
||||
/// Photo caption (may also be used when resending photos by file_id),
|
||||
/// 0-1024 characters
|
||||
pub caption: Option<String>,
|
||||
/// Send [Markdown] or [HTML],
|
||||
/// if you want Telegram apps to show [bold, italic, fixed-width text
|
||||
|
@ -40,7 +37,8 @@ pub struct SendPhoto<'a> {
|
|||
/// [bold, italic, fixed-width text or inline URLs]:
|
||||
/// crate::core::types::ParseMode
|
||||
pub parse_mode: Option<ParseMode>,
|
||||
/// Sends the message silently. Users will receive a notification with no sound.
|
||||
/// Sends the message silently. Users will receive a notification with no
|
||||
/// sound.
|
||||
pub disable_notification: Option<bool>,
|
||||
/// If the message is a reply, ID of the original message
|
||||
pub reply_to_message_id: Option<i64>,
|
||||
|
@ -58,11 +56,11 @@ impl<'a> Request<'a> for SendPhoto<'a> {
|
|||
.add_if_some("parse_mode", self.parse_mode.as_ref())
|
||||
.add_if_some(
|
||||
"disable_notification",
|
||||
self.disable_notification.as_ref()
|
||||
self.disable_notification.as_ref(),
|
||||
)
|
||||
.add_if_some(
|
||||
"reply_to_message_id",
|
||||
self.reply_to_message_id.as_ref()
|
||||
self.reply_to_message_id.as_ref(),
|
||||
);
|
||||
|
||||
params = match self.photo {
|
||||
|
@ -76,8 +74,9 @@ impl<'a> Request<'a> for SendPhoto<'a> {
|
|||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"sendPhoto",
|
||||
Some(params)
|
||||
).await
|
||||
Some(params),
|
||||
)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ impl<'a> SendPhoto<'a> {
|
|||
pub(crate) fn new(
|
||||
ctx: RequestContext<'a>,
|
||||
chat_id: ChatId,
|
||||
photo: InputFile
|
||||
photo: InputFile,
|
||||
) -> Self {
|
||||
Self {
|
||||
ctx,
|
||||
|
@ -96,7 +95,7 @@ impl<'a> SendPhoto<'a> {
|
|||
parse_mode: None,
|
||||
disable_notification: None,
|
||||
reply_to_message_id: None,
|
||||
reply_markup: None
|
||||
reply_markup: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,12 +119,18 @@ impl<'a> SendPhoto<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn disable_notification<T: Into<bool>>(mut self, disable_notification: T) -> Self {
|
||||
pub fn disable_notification<T: Into<bool>>(
|
||||
mut self,
|
||||
disable_notification: T,
|
||||
) -> Self {
|
||||
self.disable_notification = Some(disable_notification.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reply_to_message_id<T: Into<i64>>(mut self, reply_to_message_id: T) -> Self {
|
||||
pub fn reply_to_message_id<T: Into<i64>>(
|
||||
mut self,
|
||||
reply_to_message_id: T,
|
||||
) -> Self {
|
||||
self.reply_to_message_id = Some(reply_to_message_id.into());
|
||||
self
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::path::Path;
|
|||
use crate::core::{
|
||||
network,
|
||||
requests::{
|
||||
ChatId, form_builder::FormBuilder, Request, RequestContext,
|
||||
form_builder::FormBuilder, ChatId, Request, RequestContext,
|
||||
RequestFuture, ResponseResult,
|
||||
},
|
||||
types::{InlineKeyboardMarkup, Message, ParseMode},
|
||||
|
@ -18,19 +18,19 @@ struct StopMessageLiveLocation<'a> {
|
|||
/// Required if inline_message_id is not specified. Unique identifier for
|
||||
/// the target chat or username of the target channel (in the format
|
||||
/// @channelusername)
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub chat_id: Option<ChatId>,
|
||||
/// Required if inline_message_id is not specified. Identifier of the
|
||||
/// message with live location to stop
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub message_id: Option<i32>,
|
||||
/// Required if chat_id and message_id are not specified. Identifier of the
|
||||
/// inline message
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub inline_message_id: Option<String>,
|
||||
/// A JSON-serialized object InlineKeyboardMarkup for a new inline
|
||||
/// keyboard.
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reply_markup: Option<InlineKeyboardMarkup>,
|
||||
}
|
||||
|
||||
|
@ -51,9 +51,7 @@ impl<'a> Request<'a> for StopMessageLiveLocation<'a> {
|
|||
}
|
||||
|
||||
impl<'a> StopMessageLiveLocation<'a> {
|
||||
fn new(
|
||||
ctx: RequestContext<'a>,
|
||||
) -> Self {
|
||||
fn new(ctx: RequestContext<'a>) -> Self {
|
||||
Self {
|
||||
ctx,
|
||||
chat_id: None,
|
||||
|
@ -64,28 +62,32 @@ impl<'a> StopMessageLiveLocation<'a> {
|
|||
}
|
||||
|
||||
pub fn chat_id<T>(mut self, chat_id: T) -> Self
|
||||
where T: Into<ChatId>
|
||||
where
|
||||
T: Into<ChatId>,
|
||||
{
|
||||
self.chat_id = chat_id.into();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn message_id<T>(mut self, message_id: T) -> Self
|
||||
where T: Into<i32>
|
||||
where
|
||||
T: Into<i32>,
|
||||
{
|
||||
self.message_id = Some(message_id.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn inline_message_id<T>(mut self, inline_message_id: T) -> Self
|
||||
where T: Into<String>
|
||||
where
|
||||
T: Into<String>,
|
||||
{
|
||||
self.inline_message_id = Some(inline_message_id.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn reply_markup<T>(mut self, reply_markup: T) -> Self
|
||||
where T: Into<InlineKeyboardMarkup>
|
||||
where
|
||||
T: Into<InlineKeyboardMarkup>,
|
||||
{
|
||||
self.inline_message_id = Some(reply_markup.into());
|
||||
self
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use tokio::codec::FramedRead;
|
||||
use std::fs::File;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use tokio::prelude::*;
|
||||
use reqwest::r#async::multipart::Part;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use tokio::codec::FramedRead;
|
||||
use tokio::prelude::*;
|
||||
|
||||
struct FileDecoder;
|
||||
|
||||
|
@ -11,9 +11,12 @@ impl tokio::codec::Decoder for FileDecoder {
|
|||
type Item = Bytes;
|
||||
type Error = std::io::Error;
|
||||
|
||||
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
|
||||
fn decode(
|
||||
&mut self,
|
||||
src: &mut BytesMut,
|
||||
) -> Result<Option<Self::Item>, Self::Error> {
|
||||
if src.is_empty() {
|
||||
return Ok(None)
|
||||
return Ok(None);
|
||||
}
|
||||
Ok(Some(src.take().freeze()))
|
||||
}
|
||||
|
@ -21,9 +24,19 @@ impl tokio::codec::Decoder for FileDecoder {
|
|||
|
||||
pub fn file_to_part(path_to_file: &PathBuf) -> Part {
|
||||
let file = tokio::fs::File::open(path_to_file.clone())
|
||||
.map(|file| FramedRead::new(file.unwrap() /* TODO: this can cause panics */, FileDecoder))
|
||||
.map(|file| {
|
||||
FramedRead::new(
|
||||
file.unwrap(), /* TODO: this can cause panics */
|
||||
FileDecoder,
|
||||
)
|
||||
})
|
||||
.flatten_stream();
|
||||
let part = Part::stream(file)
|
||||
.file_name(path_to_file.file_name().unwrap().to_string_lossy().into_owned());
|
||||
let part = Part::stream(file).file_name(
|
||||
path_to_file
|
||||
.file_name()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
);
|
||||
part
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone )]
|
||||
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)]
|
||||
pub struct AnswerPreCheckoutQuery {
|
||||
pub pre_checkout_query_id: String,
|
||||
pub ok: bool,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::core::types::{ChatPermissions, ChatPhoto, Message};
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)]
|
||||
pub struct Chat {
|
||||
pub id: i64,
|
||||
|
@ -9,7 +8,6 @@ pub struct Chat {
|
|||
pub photo: Option<ChatPhoto>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum ChatKind {
|
||||
|
@ -32,7 +30,6 @@ pub enum ChatKind {
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Clone, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(tag = "type")]
|
||||
|
@ -101,10 +98,9 @@ mod tests {
|
|||
},
|
||||
photo: None,
|
||||
};
|
||||
let actual = from_str(
|
||||
r#"{"id":-1,"type":"channel","username":"channelname"}"#,
|
||||
)
|
||||
.unwrap();
|
||||
let actual =
|
||||
from_str(r#"{"id":-1,"type":"channel","username":"channelname"}"#)
|
||||
.unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ pub struct InlineKeyboardButton {
|
|||
pub kind: InlineKeyboardButtonKind,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Eq, Hash, Deserialize)]
|
||||
#[derive(
|
||||
Debug, Clone, PartialEq, PartialOrd, Serialize, Eq, Hash, Deserialize,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum InlineKeyboardButtonKind {
|
||||
/// HTTP or tg:// url to be opened when button is pressed
|
||||
|
@ -27,13 +29,14 @@ pub enum InlineKeyboardButtonKind {
|
|||
/// the user will be automatically returned to the chat they switched from,
|
||||
/// skipping the chat selection screen.
|
||||
SwitchInlineQuery(String),
|
||||
/// Optional. If set, pressing the button will insert the bot‘s username and
|
||||
/// the specified inline query in the current chat's input field. Can be
|
||||
/// empty, in which case only the bot’s username will be inserted.
|
||||
/// Optional. If set, pressing the button will insert the bot‘s username
|
||||
/// and the specified inline query in the current chat's input field.
|
||||
/// Can be empty, in which case only the bot’s username will be
|
||||
/// inserted.
|
||||
///
|
||||
///This offers a quick way for the user to open your bot in inline mode in
|
||||
/// the same chat – good for selecting something from multiple options.
|
||||
SwitchInlineQueryCurrentChat(String),
|
||||
// CallbackGame(CallbackGame), TODO: разобраться, что с этим делать
|
||||
// TODO: add LoginUrl, pay
|
||||
/* CallbackGame(CallbackGame), TODO: разобраться, что с этим делать
|
||||
* TODO: add LoginUrl, pay */
|
||||
}
|
|
@ -168,11 +168,11 @@ pub enum InputMedia {
|
|||
impl InputMedia {
|
||||
pub fn media(&self) -> &InputFile {
|
||||
match self {
|
||||
InputMedia::Photo { media, .. } |
|
||||
InputMedia::Document { media, .. } |
|
||||
InputMedia::Audio { media, .. } |
|
||||
InputMedia::Animation { media, .. } |
|
||||
InputMedia::Video { media, .. } => media,
|
||||
InputMedia::Photo { media, .. }
|
||||
| InputMedia::Document { media, .. }
|
||||
| InputMedia::Audio { media, .. }
|
||||
| InputMedia::Animation { media, .. }
|
||||
| InputMedia::Video { media, .. } => media,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,13 +125,13 @@ pub enum MediaKind {
|
|||
document: (),
|
||||
caption: Option<String>,
|
||||
#[serde(default = "Vec::new")]
|
||||
caption_entities: Vec<MessageEntity>
|
||||
caption_entities: Vec<MessageEntity>,
|
||||
},
|
||||
Audio {
|
||||
audio: Audio,
|
||||
caption: Option<String>,
|
||||
#[serde(default = "Vec::new")]
|
||||
caption_entities: Vec<MessageEntity>
|
||||
caption_entities: Vec<MessageEntity>,
|
||||
},
|
||||
Contact {
|
||||
contact: Contact,
|
||||
|
@ -140,7 +140,7 @@ pub enum MediaKind {
|
|||
document: Document,
|
||||
caption: Option<String>,
|
||||
#[serde(default = "Vec::new")]
|
||||
caption_entities: Vec<MessageEntity>
|
||||
caption_entities: Vec<MessageEntity>,
|
||||
},
|
||||
Game {
|
||||
game: Game,
|
||||
|
|
|
@ -8,9 +8,13 @@ pub use self::{
|
|||
chat_permissions::ChatPermissions,
|
||||
chat_photo::ChatPhoto,
|
||||
document::Document,
|
||||
force_reply::ForceReply,
|
||||
inline_keyboard_button::InlineKeyboardButton,
|
||||
inline_keyboard_markup::InlineKeyboardMarkup,
|
||||
input_file::InputFile,
|
||||
input_media::InputMedia,
|
||||
invoice::Invoice,
|
||||
keyboard_button::KeyboardButton,
|
||||
label_price::LabeledPrice,
|
||||
message::{
|
||||
ForwardKind, ForwardedFrom, MediaKind, Message, MessageKind, Sender,
|
||||
|
@ -21,6 +25,9 @@ pub use self::{
|
|||
photo_size::PhotoSize,
|
||||
poll::{Poll, PollOption},
|
||||
pre_checkout_query::PreCheckoutQuery,
|
||||
reply_keyboard_markup::ReplyKeyboardMarkup,
|
||||
reply_keyboard_remove::ReplyKeyboardRemove,
|
||||
reply_markup::ReplyMarkup,
|
||||
response_parameters::ResponseParameters,
|
||||
send_invoice::SendInvoice,
|
||||
shipping_address::ShippingAddress,
|
||||
|
@ -30,13 +37,6 @@ pub use self::{
|
|||
successful_payment::SuccessfulPayment,
|
||||
user::User,
|
||||
video::Video,
|
||||
reply_markup::ReplyMarkup,
|
||||
force_reply::ForceReply,
|
||||
inline_keyboard_button::InlineKeyboardButton,
|
||||
inline_keyboard_markup::InlineKeyboardMarkup,
|
||||
reply_keyboard_remove::ReplyKeyboardRemove,
|
||||
reply_keyboard_markup::ReplyKeyboardMarkup,
|
||||
keyboard_button::KeyboardButton,
|
||||
};
|
||||
|
||||
mod answer_pre_checkout_query;
|
||||
|
@ -48,8 +48,8 @@ mod chat_permissions;
|
|||
mod chat_photo;
|
||||
mod document;
|
||||
mod force_reply;
|
||||
mod inline_keyboard_markup;
|
||||
mod inline_keyboard_button;
|
||||
mod inline_keyboard_markup;
|
||||
mod input_file;
|
||||
mod input_media;
|
||||
mod invoice;
|
||||
|
@ -63,10 +63,10 @@ mod parse_mode;
|
|||
mod photo_size;
|
||||
mod poll;
|
||||
mod pre_checkout_query;
|
||||
mod response_parameters;
|
||||
mod reply_markup;
|
||||
mod reply_keyboard_markup;
|
||||
mod reply_keyboard_remove;
|
||||
mod reply_markup;
|
||||
mod response_parameters;
|
||||
mod send_invoice;
|
||||
mod shipping_address;
|
||||
mod shipping_option;
|
||||
|
|
|
@ -69,7 +69,6 @@ pub enum ParseMode {
|
|||
Markdown,
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -3,11 +3,11 @@ pub struct Poll {
|
|||
pub id: String,
|
||||
pub question: String,
|
||||
pub options: Vec<PollOption>,
|
||||
pub is_closed: bool
|
||||
pub is_closed: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
||||
pub struct PollOption {
|
||||
pub text: String,
|
||||
pub voter_count: i32
|
||||
pub voter_count: i32,
|
||||
}
|
||||
|
|
|
@ -3,23 +3,24 @@ use crate::core::types::KeyboardButton;
|
|||
/// This object represents a custom keyboard with reply options.
|
||||
#[derive(Debug, Serialize, Deserialize, Hash, PartialEq, Eq, Clone)]
|
||||
pub struct ReplyKeyboardMarkup {
|
||||
/// Array of button rows, each represented by an Array of [`KeyboardButton`]
|
||||
/// objects
|
||||
/// Array of button rows, each represented by an Array of
|
||||
/// [`KeyboardButton`] objects
|
||||
pub keyboard: Vec<Vec<KeyboardButton>>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Optional. Requests clients to resize the keyboard vertically for optimal
|
||||
/// fit (e.g., make the keyboard smaller if there are just two rows of
|
||||
/// buttons). Defaults to false, in which case the custom keyboard is always
|
||||
/// of the same height as the app's standard keyboard.
|
||||
/// Optional. Requests clients to resize the keyboard vertically for
|
||||
/// optimal fit (e.g., make the keyboard smaller if there are just two
|
||||
/// rows of buttons). Defaults to false, in which case the custom
|
||||
/// keyboard is always of the same height as the app's standard
|
||||
/// keyboard.
|
||||
pub resize_keyboard: Option<bool>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
/// Optional. Requests clients to hide the keyboard as soon as it's been
|
||||
/// used. The keyboard will still be available, but clients will
|
||||
/// automatically display the usual letter-keyboard in the chat – the user
|
||||
/// can press a special button in the input field to see the custom keyboard
|
||||
/// again. Defaults to false.
|
||||
/// can press a special button in the input field to see the custom
|
||||
/// keyboard again. Defaults to false.
|
||||
pub one_time_keyboard: Option<bool>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
use crate::core::types::{
|
||||
InlineKeyboardMarkup,
|
||||
ReplyKeyboardMarkup,
|
||||
ReplyKeyboardRemove,
|
||||
ForceReply,
|
||||
ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
|
@ -12,9 +12,8 @@ mod tests {
|
|||
#[test]
|
||||
fn migrate_to_chat_id_deserialization() {
|
||||
let expected = ResponseParameters::MigrateToChatId(123456);
|
||||
let actual: ResponseParameters = serde_json::from_str(
|
||||
r#"{"migrate_to_chat_id":123456}"#
|
||||
).unwrap();
|
||||
let actual: ResponseParameters =
|
||||
serde_json::from_str(r#"{"migrate_to_chat_id":123456}"#).unwrap();
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
@ -22,9 +21,8 @@ mod tests {
|
|||
#[test]
|
||||
fn retry_after_deserialization() {
|
||||
let expected = ResponseParameters::RetryAfter(123456);
|
||||
let actual: ResponseParameters = serde_json::from_str(
|
||||
r#"{"retry_after":123456}"#
|
||||
).unwrap();
|
||||
let actual: ResponseParameters =
|
||||
serde_json::from_str(r#"{"retry_after":123456}"#).unwrap();
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::core::types::PhotoSize;
|
||||
|
||||
|
||||
/// This object represents a video file.
|
||||
#[derive(Debug, Deserialize, Eq, Hash, PartialEq, Serialize, Clone)]
|
||||
pub struct Video {
|
||||
|
|
Loading…
Reference in a new issue