mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-08 19:33:53 +01:00
Prettify requests/mod.rs
This commit is contained in:
parent
7ddd8fce06
commit
e874f849a7
1 changed files with 44 additions and 45 deletions
|
@ -1,51 +1,6 @@
|
|||
use reqwest::Client;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::RequestError;
|
||||
|
||||
pub use self::{
|
||||
answer_pre_checkout_query::AnswerPreCheckoutQuery,
|
||||
answer_shipping_query::AnswerShippingQuery,
|
||||
edit_message_live_location::EditMessageLiveLocation,
|
||||
forward_message::ForwardMessage, get_chat::GetChat, get_file::GetFile,
|
||||
get_me::GetMe, get_updates::GetUpdates,
|
||||
get_user_profile_photos::GetUserProfilePhotos,
|
||||
kick_chat_member::KickChatMember, pin_chat_message::PinChatMessage,
|
||||
promote_chat_member::PromoteChatMember,
|
||||
restrict_chat_member::RestrictChatMember, send_animation::SendAnimation,
|
||||
send_audio::SendAudio, send_chat_action::SendChatAction,
|
||||
send_contact::SendContact, send_document::SendDocument,
|
||||
send_location::SendLocation, send_media_group::SendMediaGroup,
|
||||
send_message::SendMessage, send_photo::SendPhoto, send_poll::SendPoll,
|
||||
send_venue::SendVenue, send_video::SendVideo,
|
||||
send_video_note::SendVideoNote, send_voice::SendVoice,
|
||||
stop_message_live_location::StopMessageLiveLocation,
|
||||
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.
|
||||
#[async_trait]
|
||||
pub trait Request {
|
||||
type ReturnValue: DeserializeOwned;
|
||||
|
||||
/// Send request to telegram
|
||||
async fn send_boxed(self) -> ResponseResult<Self::ReturnValue>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
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;
|
||||
|
@ -76,3 +31,47 @@ 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;
|
||||
|
||||
pub use self::{
|
||||
answer_pre_checkout_query::AnswerPreCheckoutQuery,
|
||||
answer_shipping_query::AnswerShippingQuery,
|
||||
edit_message_live_location::EditMessageLiveLocation,
|
||||
forward_message::ForwardMessage, get_chat::GetChat, get_file::GetFile,
|
||||
get_me::GetMe, get_updates::GetUpdates,
|
||||
get_user_profile_photos::GetUserProfilePhotos,
|
||||
kick_chat_member::KickChatMember, pin_chat_message::PinChatMessage,
|
||||
promote_chat_member::PromoteChatMember,
|
||||
restrict_chat_member::RestrictChatMember, send_animation::SendAnimation,
|
||||
send_audio::SendAudio, send_chat_action::SendChatAction,
|
||||
send_contact::SendContact, send_document::SendDocument,
|
||||
send_location::SendLocation, send_media_group::SendMediaGroup,
|
||||
send_message::SendMessage, send_photo::SendPhoto, send_poll::SendPoll,
|
||||
send_venue::SendVenue, send_video::SendVideo,
|
||||
send_video_note::SendVideoNote, send_voice::SendVoice,
|
||||
stop_message_live_location::StopMessageLiveLocation,
|
||||
unban_chat_member::UnbanChatMember, unpin_chat_message::UnpinChatMessage,
|
||||
};
|
||||
|
||||
pub type ResponseResult<T> = Result<T, RequestError>;
|
||||
|
||||
/// A request that can be sent to Telegram.
|
||||
#[async_trait]
|
||||
pub trait Request {
|
||||
/// A type of response.
|
||||
type ReturnValue: DeserializeOwned;
|
||||
|
||||
/// Send this request.
|
||||
async fn send_boxed(self) -> ResponseResult<Self::ReturnValue>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RequestContext<'a> {
|
||||
pub client: &'a Client,
|
||||
pub token: &'a str,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue