Prettify requests/mod.rs
-use reqwest::Client;
-use serde::de::DeserializeOwned;
+mod form_builder;
+mod utils;
+
+mod answer_pre_checkout_query;
+mod answer_shipping_query;
+mod edit_message_live_location;
+mod forward_message;
+mod get_chat;
+mod get_file;
+mod get_me;
+mod get_updates;
+mod get_user_profile_photos;
+mod kick_chat_member;
+mod pin_chat_message;
+mod promote_chat_member;
+mod restrict_chat_member;
+mod send_animation;
+mod send_audio;
+mod send_chat_action;
+mod send_contact;
+mod send_document;
+mod send_location;
+mod send_media_group;
+mod send_message;
+mod send_photo;
+mod send_poll;
+mod send_venue;
+mod send_video;
+mod send_video_note;
+mod send_voice;
+mod stop_message_live_location;
+mod unban_chat_member;
+mod unpin_chat_message;
use async_trait::async_trait;
+use reqwest::Client;
+use serde::de::DeserializeOwned;
use crate::RequestError;
@@ -25,18 +58,15 @@ pub use self::{
unban_chat_member::UnbanChatMember, unpin_chat_message::UnpinChatMessage,
};
-mod form_builder;
-mod utils;
-
pub type ResponseResult<T> = Result<T, RequestError>;
-/// Request that can be sent to telegram.
-/// `ReturnValue` - a type that will be returned from Telegram.
+/// A request that can be sent to Telegram.
#[async_trait]
pub trait Request {
+ /// A type of response.
type ReturnValue: DeserializeOwned;
- /// Send request to telegram
+ /// Send this request.
async fn send_boxed(self) -> ResponseResult<Self::ReturnValue>;
}
@@ -45,34 +75,3 @@ pub struct RequestContext<'a> {
pub client: &'a Client,
pub token: &'a str,
}
-
-mod answer_pre_checkout_query;
-mod answer_shipping_query;
-mod edit_message_live_location;
-mod forward_message;
-mod get_chat;
-mod get_file;
-mod get_me;
-mod get_updates;
-mod get_user_profile_photos;
-mod kick_chat_member;
-mod pin_chat_message;
-mod promote_chat_member;
-mod restrict_chat_member;
-mod send_animation;
-mod send_audio;
-mod send_chat_action;
-mod send_contact;
-mod send_document;
-mod send_location;
-mod send_media_group;
-mod send_message;
-mod send_photo;
-mod send_poll;
-mod send_venue;
-mod send_video;
-mod send_video_note;
-mod send_voice;
-mod stop_message_live_location;
-mod unban_chat_member;
-mod unpin_chat_message;
