Documentation gardening

This commit is contained in:
Temirkhan Myrzamadi 2020-12-23 22:24:31 +06:00
parent e260f11558
commit f5d9cb1a73
15 changed files with 152 additions and 152 deletions

View file

@ -1,11 +1,10 @@
//! ## Bot adaptors
//! Wrappers altering functionality of a bot.
//!
//! Bot adaptors are very similar to [`Iterator`] adaptors —
//! they are bots (implement [`Requester`]) which wrap other bots
//! adding new functionality.
//! Bot adaptors are very similar to the [`Iterator`] adaptors: they are bots
//! wrapping other bots to alter existing or add new functionality.
//!
//! E.g. [`AutoSend`] allows `await`ing requests directly,
//! without need to use `.send()`.
//! E.g. [`AutoSend`] allows `await`ing requests directly, no need to to use
//! `.send()`.
//!
//! [`Requester`]: crate::requests::Requester

View file

@ -5,14 +5,14 @@ use crate::{
};
/// Default parse mode adaptor, see
/// [`RequesterExt::parse_mode`](crate::requests::RequesterExt::parse_mode)
/// [`RequesterExt::parse_mode`](crate::requests::RequesterExt::parse_mode).
pub struct DefaultParseMode<B> {
bot: B,
mode: ParseMode,
}
impl<B> DefaultParseMode<B> {
/// Creates new [`DefaultParseMode`]
/// Creates new [`DefaultParseMode`].
///
/// Note: it's recommended to use [`RequesterExt::parse_mode`] instead.
///
@ -21,12 +21,12 @@ impl<B> DefaultParseMode<B> {
Self { bot, mode: parse_mode }
}
/// Allows to access inner bot
/// Allows to access the inner bot.
pub fn inner(&self) -> &B {
&self.bot
}
/// Unwraps inner bot
/// Unwraps the inner bot.
pub fn into_inner(self) -> B {
self.bot
}

View file

@ -8,11 +8,11 @@ use thiserror::Error;
/// An error caused by downloading a file.
#[derive(Debug, Error, From)]
pub enum DownloadError {
/// Network error while downloading file from telegram.
/// Network error while downloading a file from Telegram.
#[error("A network error: {0}")]
NetworkError(#[source] reqwest::Error),
/// I/O error while writing file to destination.
/// An I/O error while writing a file to destination.
#[error("An I/O error: {0}")]
Io(#[source] std::io::Error),
}
@ -20,12 +20,13 @@ pub enum DownloadError {
/// An error caused by sending a request to Telegram.
#[derive(Debug, Error)]
pub enum RequestError {
/// Telegram API error
/// Telegram API error.
#[error("A Telegram's error #{status_code}: {kind:?}")]
ApiError {
/// Kind of api error
/// Kind of an API error.
kind: ApiError,
/// HTTP code returned by telegram, not very usefull in practice.
/// An HTTP code returned by Telegram, not very useful in practice.
status_code: StatusCode,
},
@ -39,11 +40,11 @@ pub enum RequestError {
#[error("Retry after {0} seconds")]
RetryAfter(i32),
/// Network error while sending request to telegram.
/// Network error while sending a request to Telegram.
#[error("A network error: {0}")]
NetworkError(#[source] reqwest::Error),
/// Error while parsing response from telegram.
/// Error while parsing a response from Telegram.
///
/// If you've received this error, please, [open an issue] with the
/// description of the error.

View file

@ -11,17 +11,15 @@ use tokio::io::{AsyncWrite, AsyncWriteExt};
use crate::{errors::DownloadError, net::file_url};
/// Download client.
///
/// This trait allows you to download files from telegram.
/// A trait for downloading files from Telegram.
pub trait Download<'w>
/* FIXME(waffle): ideally, this lifetime ('w) shouldn't be here, but we can't help it without
* GATs */
{
/// Error returned by [`download_file`](Self::download_file)
/// An error returned from [`download_file`](Self::download_file).
type Err;
/// Future returned from [`download_file`](Self::download_file)
/// A future returned from [`download_file`](Self::download_file).
type Fut: Future<Output = Result<(), Self::Err>> + Send;
/// Download a file from Telegram into `destination`.
@ -58,15 +56,16 @@ pub trait Download<'w>
destination: &'w mut (dyn AsyncWrite + Unpin + Send),
) -> Self::Fut;
/// Error returned by [`download_file_stream`](Self::download_file_stream)
/// An error returned from
/// [`download_file_stream`](Self::download_file_stream).
type StreamErr;
/// Stream returned from [`download_file_stream`]
/// A stream returned from [`download_file_stream`].
///
///[`download_file_stream`]: (Self::download_file_stream)
type Stream: Stream<Item = Result<Bytes, Self::StreamErr>> + Send;
/// Download a file from Telegram as a [`Stream`].
/// Download a file from Telegram as [`Stream`].
///
/// `path` can be obtained from the [`GetFile`].
///
@ -84,7 +83,7 @@ pub trait Download<'w>
///
/// Note: if you don't need to use a different (from you're bot) client and
/// don't need to get *all* performance (and you don't, c'mon it's very io-bound
/// job), then it's recommended to use [`Download::download_file`]
/// job), then it's recommended to use [`Download::download_file`].
pub fn download_file<'o, D>(
client: &Client,
api_url: Url,
@ -106,11 +105,11 @@ where
})
}
/// Download a file from Telegram as a [`Stream`].
/// Download a file from Telegram as [`Stream`].
///
/// Note: if you don't need to use a different (from you're bot) client and
/// don't need to get *all* performance (and you don't, c'mon it's very io-bound
/// job), then it's recommended to use [`Download::download_file_stream`]
/// job), then it's recommended to use [`Download::download_file_stream`].
pub fn download_file_stream(
client: &Client,
api_url: Url,

View file

@ -1,8 +1,4 @@
//! Network specific items.
//!
//! Currently this module contains only the file download stuff and the default
//! api url.
// ... and some internal stuff :P
//! Network-specific API.
pub use self::download::{download_file, download_file_stream, Download};
@ -15,7 +11,7 @@ mod download;
mod request;
mod telegram_response;
/// Default telegram api url
/// The default Telegram API URL.
pub const TELEGRAM_API_URL: &str = "https://api.telegram.org";
/// Creates URL for making HTTPS requests. See the [Telegram documentation].

View file

@ -1,11 +1,14 @@
//! Payloads - data types sended to relegram
//! Request data sent to Telegram.
/// This module reexports all setters traits as `_`. When used with a glob
/// This module re-exports all the setters traits as `_`. When used with a glob
/// import:
///
/// ```
/// use teloxide_core::payloads::setters::*;
/// ```
/// It allows you to use all payloads setters, without polluting your namespace.
///
/// It allows you to use all the payloads setters, without polluting your
/// namespace.
pub mod setters;
// This block is auto generated by `cg` <https://github.com/teloxide/cg> (878e847).

View file

@ -1,3 +1,3 @@
//! Crate prelude
//! Commonly used items.
pub use crate::requests::Requester;

View file

@ -1,15 +1,14 @@
use crate::requests::Payload;
/// Represent types that have payload inside it. E.g.: the payload itself or a
/// `Request`.
/// Represents types having payload inside.
///
/// This trait is something between [`DerefMut`] and [`BorrowMut`] — it allows
/// only one implementation per type (the [output] is associated type, not a
/// generic), have implementations for all types `P` such `P: `[`Payload`], but
/// have no magic compiler support like [`DerefMut`] does nor does it require
/// only one implementation per type (the [output type] is associated, not
/// generic), has implementations for all types `P` such `P: `[`Payload`], but
/// has no magic compiler support like [`DerefMut`] does nor does it require
/// any laws about `Eq`, `Ord` and `Hash` as [`BorrowMut`] does.
///
/// Also [output] type is bounded by [`Payload`] trait.
/// Also the [output type] is bounded by the [`Payload`] trait.
///
/// This trait is mostly used to implement payload setters (on both payloads &
/// requests), so you probably won't find yourself using it directly.
@ -17,13 +16,13 @@ use crate::requests::Payload;
/// [`DerefMut`]: std::ops::DerefMut
/// [`BorrowMut`]: std::borrow::BorrowMut
/// [`Payload`]: crate::requests::Payload
/// [output]: HasPayload::Payload
/// [output type]: HasPayload::Payload
pub trait HasPayload
// FIXME(waffle):
// we wanted to use As{Mut,Ref} here, but they doesn't work
// because of https://github.com/rust-lang/rust/issues/77010
{
/// Type of the payload contained.
/// A type of the payload contained.
type Payload: Payload;
/// Gain mutable access to the underlying payload.

View file

@ -6,11 +6,9 @@ use crate::{
RequestError,
};
/// Ready-to-send telegram request.
/// A ready-to-send Telegram request whose payload is sent using [JSON].
///
/// Note: payload will be sent to telegram using [`json`]
///
/// [`json`]: https://core.telegram.org/bots/api#making-requests
/// [JSON]: https://core.telegram.org/bots/api#making-requests
#[must_use = "requests do nothing until sent"]
pub struct JsonRequest<P> {
bot: Bot,

View file

@ -8,8 +8,7 @@ pub use self::{
/// A type that is returned after making a request to Telegram.
pub type ResponseResult<T> = Result<T, crate::RequestError>;
/// Output of a [`Payload`] in [`HasPayload`]. Alias to
/// `<<T as HasPayload>::Payload as Payload>::Output`.
/// An output type of [`Payload`] in [`HasPayload`].
pub type Output<T> = <<T as HasPayload>::Payload as Payload>::Output;
mod has_payload;

View file

@ -6,11 +6,10 @@ use crate::{
RequestError,
};
/// Ready-to-send telegram request.
/// A ready-to-send Telegram request whose payload is sent using
/// [multipart/form-data].
///
/// Note: payload will be sent to telegram using [`multipart/form-data`]
///
/// [`multipart/form-data`]: https://core.telegram.org/bots/api#making-requests
/// [multipart/form-data]: https://core.telegram.org/bots/api#making-requests
#[must_use = "requests do nothing until sent"]
pub struct MultipartRequest<P> {
bot: Bot,

View file

@ -1,20 +1,24 @@
/// Payload of a request.
///
/// Simply speaking structs implementing this trait represent arguments of
/// a telegram bot API method.
/// Simply speaking, structures implementing this trait represent arguments of
/// a Telegram bot API method.
///
/// This trait provides some additional information needed for sending request
/// to the telegram.
/// Also, this trait provides some additional information needed for sending a
/// request to Telegram.
#[cfg_attr(all(docsrs, feature = "nightly"), doc(spotlight))]
pub trait Payload {
/// Return type of the telegram method.
/// A return type of a Telegram method.
///
/// Note: that should not include result wrappers (e.g. it should be simply
/// `Message`, `True` or something else)
/// Note: it should not include `Result` wrappers (e.g. it should be simply
/// [`Message`], [`True`] or something else).
///
/// [`Message`]: crate::types::Message
/// [`True`]: crate::types::True
type Output;
/// Name of the telegram method. Case insensitive, though must not include
/// underscores. (e.g.: `GetMe`, `GETME`, `getme`, `getMe` are ok, but
/// `get_me` is not ok)
/// Name of a Telegram method.
///
/// It is case insensitive, though must not include underscores. (e.g.
/// `GetMe`, `GETME`, `getme`, `getMe` are ok, but `get_me` is not ok).
const NAME: &'static str;
}

View file

@ -2,7 +2,7 @@ use std::future::Future;
use crate::requests::{HasPayload, Output};
/// A ready-to-send telegram request.
/// A ready-to-send Telegram request.
// FIXME(waffle): Write better doc for the trait
///
/// ## Implementation notes
@ -23,19 +23,20 @@ pub trait Request: HasPayload {
* use it before it's integrated in async/await
*/
/// Type of error that may happen during sending the request to telegram.
/// A type of an error that may happen while sending a request to Telegram.
type Err: std::error::Error + Send;
/// Type of future returned by [`send`](Request::send) method.
/// A type of the future returned by the [`send`](Request::send) method.
type Send: Future<Output = Result<Output<Self>, Self::Err>> + Send;
/// Type of future returned by [`send_ref`](Request::send_ref) method.
/// A type of the future returned by the [`send_ref`](Request::send_ref)
/// method.
///
/// NOTE: it intentionally forbids borrowing from self
// though anyway we couldn't allow borrowing without GATs :sob:
/// Note: it intentionally forbids borrowing from `self` though anyway we
/// couldn't allow borrowing without GATs.
type SendRef: Future<Output = Result<Output<Self>, Self::Err>> + Send;
/// Send the request.
/// Send this request.
///
/// ## Examples
// FIXME(waffle): ignored until full request redesign lands
@ -51,15 +52,15 @@ pub trait Request: HasPayload {
/// ```
fn send(self) -> Self::Send;
/// Send the request.
/// Send this request by reference.
///
/// This method is analogous to [`send`](Request::send), but it doesn't take
/// the ownership of `self`. This allows to send the same (or slightly
/// different) requests over and over.
///
/// _Also_ it is expected that calling this method is better than just
/// `clone`ing the requests. (because instead of copying all the data
/// and then serializing it, this method should just serialize the data)
/// Also, it is expected that calling this method is better than just
/// cloning requests. (Because instead of copying all the data
/// and then serializing it, this method should just serialize the data.)
///
/// ## Examples
// FIXME(waffle): ignored until full request redesign lands

View file

@ -8,8 +8,9 @@ use crate::{
},
};
/// The trait implemented by all bots & bot adaptors.
/// Essentially a request builder factory (?).
/// Methods for building requests.
///
/// This trait is implemented by all bots & bot adaptors.
///
/// _This trait is included in the crate's [`prelude`](crate::prelude)_.
#[cfg_attr(all(docsrs, feature = "nightly"), doc(spotlight))]
@ -22,12 +23,12 @@ pub trait Requester {
type GetUpdates: Request<Payload = GetUpdates, Err = Self::Err>;
/// For telegram documentation see [`GetUpdates`]
/// For Telegram documentation see [`GetUpdates`].
fn get_updates(&self) -> Self::GetUpdates;
type SetWebhook: Request<Payload = SetWebhook, Err = Self::Err>;
/// For telegram documentation see [`SetWebhook`]
/// For Telegram documentation see [`SetWebhook`].
fn set_webhook<U, A>(&self, url: U, allowed_updates: A) -> Self::SetWebhook
where
U: Into<String>,
@ -35,22 +36,22 @@ pub trait Requester {
type DeleteWebhook: Request<Payload = DeleteWebhook, Err = Self::Err>;
/// For telegram documentation see [`DeleteWebhook`]
/// For Telegram documentation see [`DeleteWebhook`].
fn delete_webhook(&self) -> Self::DeleteWebhook;
type GetWebhookInfo: Request<Payload = GetWebhookInfo, Err = Self::Err>;
/// For telegram documentation see [`GetWebhookInfo`]
/// For Telegram documentation see [`GetWebhookInfo`].
fn get_webhook_info(&self) -> Self::GetWebhookInfo;
type GetMe: Request<Payload = GetMe, Err = Self::Err>;
/// For telegram documentation see [`GetMe`]
/// For Telegram documentation see [`GetMe`].
fn get_me(&self) -> Self::GetMe;
type SendMessage: Request<Payload = SendMessage, Err = Self::Err>;
/// For telegram documentation see [`SendMessage`]
/// For Telegram documentation see [`SendMessage`].
fn send_message<C, T>(&self, chat_id: C, text: T) -> Self::SendMessage
where
C: Into<ChatId>,
@ -58,7 +59,7 @@ pub trait Requester {
type ForwardMessage: Request<Payload = ForwardMessage, Err = Self::Err>;
/// For telegram documentation see [`ForwardMessage`]
/// For Telegram documentation see [`ForwardMessage`].
fn forward_message<C, F>(
&self,
chat_id: C,
@ -71,7 +72,7 @@ pub trait Requester {
type SendPhoto: Request<Payload = SendPhoto, Err = Self::Err>;
/// For telegram documentation see [`SendPhoto`]
/// For Telegram documentation see [`SendPhoto`].
fn send_photo<Ch, Ca>(&self, chat_id: Ch, photo: InputFile, caption: Ca) -> Self::SendPhoto
where
Ch: Into<ChatId>,
@ -79,7 +80,7 @@ pub trait Requester {
type SendAudio: Request<Payload = SendAudio, Err = Self::Err>;
/// For telegram documentation see [`SendAudio`]
/// For Telegram documentation see [`SendAudio`].
fn send_audio<Ch, Ca>(&self, chat_id: Ch, audio: InputFile, caption: Ca) -> Self::SendAudio
where
Ch: Into<ChatId>,
@ -87,7 +88,7 @@ pub trait Requester {
type SendDocument: Request<Payload = SendDocument, Err = Self::Err>;
/// For telegram documentation see [`SendDocument`]
/// For Telegram documentation see [`SendDocument`].
fn send_document<Ch, Ca>(
&self,
chat_id: Ch,
@ -100,7 +101,7 @@ pub trait Requester {
type SendVideo: Request<Payload = SendVideo, Err = Self::Err>;
/// For telegram documentation see [`SendVideo`]
/// For Telegram documentation see [`SendVideo`].
fn send_video<Ch, Ca>(&self, chat_id: Ch, video: InputFile, caption: Ca) -> Self::SendVideo
where
Ch: Into<ChatId>,
@ -108,7 +109,7 @@ pub trait Requester {
type SendAnimation: Request<Payload = SendAnimation, Err = Self::Err>;
/// For telegram documentation see [`SendAnimation`]
/// For Telegram documentation see [`SendAnimation`].
fn send_animation<Ch, Ca>(
&self,
chat_id: Ch,
@ -121,7 +122,7 @@ pub trait Requester {
type SendVoice: Request<Payload = SendVoice, Err = Self::Err>;
/// For telegram documentation see [`SendVoice`]
/// For Telegram documentation see [`SendVoice`].
fn send_voice<Ch, Ca>(&self, chat_id: Ch, voice: InputFile, caption: Ca) -> Self::SendVoice
where
Ch: Into<ChatId>,
@ -129,14 +130,14 @@ pub trait Requester {
type SendVideoNote: Request<Payload = SendVideoNote, Err = Self::Err>;
/// For telegram documentation see [`SendVideoNote`]
/// For Telegram documentation see [`SendVideoNote`].
fn send_video_note<C>(&self, chat_id: C, video_note: InputFile) -> Self::SendVideoNote
where
C: Into<ChatId>;
type SendMediaGroup: Request<Payload = SendMediaGroup, Err = Self::Err>;
/// For telegram documentation see [`SendMediaGroup`]
/// For Telegram documentation see [`SendMediaGroup`].
fn send_media_group<C, M>(&self, chat_id: C, media: M) -> Self::SendMediaGroup
where
C: Into<ChatId>,
@ -144,7 +145,7 @@ pub trait Requester {
type SendLocation: Request<Payload = SendLocation, Err = Self::Err>;
/// For telegram documentation see [`SendLocation`]
/// For Telegram documentation see [`SendLocation`].
fn send_location<C>(
&self,
chat_id: C,
@ -157,7 +158,7 @@ pub trait Requester {
type EditMessageLiveLocation: Request<Payload = EditMessageLiveLocation, Err = Self::Err>;
/// For telegram documentation see [`EditMessageLiveLocation`]
/// For Telegram documentation see [`EditMessageLiveLocation`].
fn edit_message_live_location<C>(
&self,
chat_id: C,
@ -173,7 +174,7 @@ pub trait Requester {
Err = Self::Err,
>;
/// For telegram documentation see [`EditMessageLiveLocationInline`]
/// For Telegram documentation see [`EditMessageLiveLocationInline`].
fn edit_message_live_location_inline<I>(
&self,
inline_message_id: I,
@ -185,7 +186,7 @@ pub trait Requester {
type StopMessageLiveLocation: Request<Payload = StopMessageLiveLocation, Err = Self::Err>;
/// For telegram documentation see [`StopMessageLiveLocation`]
/// For Telegram documentation see [`StopMessageLiveLocation`].
fn stop_message_live_location<C>(
&self,
chat_id: C,
@ -201,7 +202,7 @@ pub trait Requester {
Err = Self::Err,
>;
/// For telegram documentation see [`StopMessageLiveLocationInline`]
/// For Telegram documentation see [`StopMessageLiveLocationInline`].
fn stop_message_live_location_inline<I>(
&self,
inline_message_id: I,
@ -213,7 +214,7 @@ pub trait Requester {
type SendVenue: Request<Payload = SendVenue, Err = Self::Err>;
/// For telegram documentation see [`SendVenue`]
/// For Telegram documentation see [`SendVenue`].
fn send_venue<C, T, A>(
&self,
chat_id: C,
@ -229,14 +230,14 @@ pub trait Requester {
type SendContact: Request<Payload = SendContact, Err = Self::Err>;
/// For telegram documentation see [`SendContact`]
/// For Telegram documentation see [`SendContact`].
fn send_contact<C>(&self, chat_id: C, phone_number: f64, first_name: f64) -> Self::SendContact
where
C: Into<ChatId>;
type SendPoll: Request<Payload = SendPoll, Err = Self::Err>;
/// For telegram documentation see [`SendPoll`]
/// For Telegram documentation see [`SendPoll`].
fn send_poll<C, Q, O>(
&self,
chat_id: C,
@ -251,47 +252,47 @@ pub trait Requester {
type SendDice: Request<Payload = SendDice, Err = Self::Err>;
/// For telegram documentation see [`SendDice`]
/// For Telegram documentation see [`SendDice`].
fn send_dice<C>(&self, chat_id: C, emoji: DiceEmoji) -> Self::SendDice
where
C: Into<ChatId>;
type SendChatAction: Request<Payload = SendChatAction, Err = Self::Err>;
/// For telegram documentation see [`SendChatAction`]
/// For Telegram documentation see [`SendChatAction`].
fn send_chat_action<C>(&self, chat_id: C, action: ChatAction) -> Self::SendChatAction
where
C: Into<ChatId>;
type GetUserProfilePhotos: Request<Payload = GetUserProfilePhotos, Err = Self::Err>;
/// For telegram documentation see [`GetUserProfilePhotos`]
/// For Telegram documentation see [`GetUserProfilePhotos`].
fn get_user_profile_photos(&self, user_id: i32) -> Self::GetUserProfilePhotos;
type GetFile: Request<Payload = GetFile, Err = Self::Err>;
/// For telegram documentation see [`GetFile`]
/// For Telegram documentation see [`GetFile`].
fn get_file<F>(&self, file_id: F) -> Self::GetFile
where
F: Into<String>;
type KickChatMember: Request<Payload = KickChatMember, Err = Self::Err>;
/// For telegram documentation see [`KickChatMember`]
/// For Telegram documentation see [`KickChatMember`].
fn kick_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::KickChatMember
where
C: Into<ChatId>;
type UnbanChatMember: Request<Payload = UnbanChatMember, Err = Self::Err>;
/// For telegram documentation see [`UnbanChatMember`]
/// For Telegram documentation see [`UnbanChatMember`].
fn unban_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::UnbanChatMember
where
C: Into<ChatId>;
type RestrictChatMember: Request<Payload = RestrictChatMember, Err = Self::Err>;
/// For telegram documentation see [`RestrictChatMember`]
/// For Telegram documentation see [`RestrictChatMember`].
fn restrict_chat_member<C>(
&self,
chat_id: C,
@ -303,7 +304,7 @@ pub trait Requester {
type PromoteChatMember: Request<Payload = PromoteChatMember, Err = Self::Err>;
/// For telegram documentation see [`PromoteChatMember`]
/// For Telegram documentation see [`PromoteChatMember`].
fn promote_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::PromoteChatMember
where
C: Into<ChatId>;
@ -313,7 +314,7 @@ pub trait Requester {
Err = Self::Err,
>;
/// For telegram documentation see [`SetChatAdministratorCustomTitle`]
/// For Telegram documentation see [`SetChatAdministratorCustomTitle`].
fn set_chat_administrator_custom_title<Ch, Cu>(
&self,
chat_id: Ch,
@ -326,7 +327,7 @@ pub trait Requester {
type SetChatPermissions: Request<Payload = SetChatPermissions, Err = Self::Err>;
/// For telegram documentation see [`SetChatPermissions`]
/// For Telegram documentation see [`SetChatPermissions`].
fn set_chat_permissions<C>(
&self,
chat_id: C,
@ -337,28 +338,28 @@ pub trait Requester {
type ExportChatInviteLink: Request<Payload = ExportChatInviteLink, Err = Self::Err>;
/// For telegram documentation see [`ExportChatInviteLink`]
/// For Telegram documentation see [`ExportChatInviteLink`].
fn export_chat_invite_link<C>(&self, chat_id: C) -> Self::ExportChatInviteLink
where
C: Into<ChatId>;
type SetChatPhoto: Request<Payload = SetChatPhoto, Err = Self::Err>;
/// For telegram documentation see [`SetChatPhoto`]
/// For Telegram documentation see [`SetChatPhoto`].
fn set_chat_photo<C>(&self, chat_id: C, photo: InputFile) -> Self::SetChatPhoto
where
C: Into<ChatId>;
type DeleteChatPhoto: Request<Payload = DeleteChatPhoto, Err = Self::Err>;
/// For telegram documentation see [`DeleteChatPhoto`]
/// For Telegram documentation see [`DeleteChatPhoto`].
fn delete_chat_photo<C>(&self, chat_id: C) -> Self::DeleteChatPhoto
where
C: Into<ChatId>;
type SetChatTitle: Request<Payload = SetChatTitle, Err = Self::Err>;
/// For telegram documentation see [`SetChatTitle`]
/// For Telegram documentation see [`SetChatTitle`].
fn set_chat_title<C, T>(&self, chat_id: C, title: T) -> Self::SetChatTitle
where
C: Into<ChatId>,
@ -366,63 +367,63 @@ pub trait Requester {
type SetChatDescription: Request<Payload = SetChatDescription, Err = Self::Err>;
/// For telegram documentation see [`SetChatDescription`]
/// For Telegram documentation see [`SetChatDescription`].
fn set_chat_description<C>(&self, chat_id: C) -> Self::SetChatDescription
where
C: Into<ChatId>;
type PinChatMessage: Request<Payload = PinChatMessage, Err = Self::Err>;
/// For telegram documentation see [`PinChatMessage`]
/// For Telegram documentation see [`PinChatMessage`].
fn pin_chat_message<C>(&self, chat_id: C, message_id: i32) -> Self::PinChatMessage
where
C: Into<ChatId>;
type UnpinChatMessage: Request<Payload = UnpinChatMessage, Err = Self::Err>;
/// For telegram documentation see [`UnpinChatMessage`]
/// For Telegram documentation see [`UnpinChatMessage`].
fn unpin_chat_message<C>(&self, chat_id: C) -> Self::UnpinChatMessage
where
C: Into<ChatId>;
type LeaveChat: Request<Payload = LeaveChat, Err = Self::Err>;
/// For telegram documentation see [`LeaveChat`]
/// For Telegram documentation see [`LeaveChat`].
fn leave_chat<C>(&self, chat_id: C) -> Self::LeaveChat
where
C: Into<ChatId>;
type GetChat: Request<Payload = GetChat, Err = Self::Err>;
/// For telegram documentation see [`GetChat`]
/// For Telegram documentation see [`GetChat`].
fn get_chat<C>(&self, chat_id: C) -> Self::GetChat
where
C: Into<ChatId>;
type GetChatAdministrators: Request<Payload = GetChatAdministrators, Err = Self::Err>;
/// For telegram documentation see [`GetChatAdministrators`]
/// For Telegram documentation see [`GetChatAdministrators`].
fn get_chat_administrators<C>(&self, chat_id: C) -> Self::GetChatAdministrators
where
C: Into<ChatId>;
type GetChatMembersCount: Request<Payload = GetChatMembersCount, Err = Self::Err>;
/// For telegram documentation see [`GetChatMembersCount`]
/// For Telegram documentation see [`GetChatMembersCount`].
fn get_chat_members_count<C>(&self, chat_id: C) -> Self::GetChatMembersCount
where
C: Into<ChatId>;
type GetChatMember: Request<Payload = GetChatMember, Err = Self::Err>;
/// For telegram documentation see [`GetChatMember`]
/// For Telegram documentation see [`GetChatMember`].
fn get_chat_member<C>(&self, chat_id: C, user_id: i32) -> Self::GetChatMember
where
C: Into<ChatId>;
type SetChatStickerSet: Request<Payload = SetChatStickerSet, Err = Self::Err>;
/// For telegram documentation see [`SetChatStickerSet`]
/// For Telegram documentation see [`SetChatStickerSet`].
fn set_chat_sticker_set<C, S>(
&self,
chat_id: C,
@ -434,33 +435,33 @@ pub trait Requester {
type DeleteChatStickerSet: Request<Payload = DeleteChatStickerSet, Err = Self::Err>;
/// For telegram documentation see [`DeleteChatStickerSet`]
/// For Telegram documentation see [`DeleteChatStickerSet`].
fn delete_chat_sticker_set<C>(&self, chat_id: C) -> Self::DeleteChatStickerSet
where
C: Into<ChatId>;
type AnswerCallbackQuery: Request<Payload = AnswerCallbackQuery, Err = Self::Err>;
/// For telegram documentation see [`AnswerCallbackQuery`]
/// For Telegram documentation see [`AnswerCallbackQuery`].
fn answer_callback_query<C>(&self, callback_query_id: C) -> Self::AnswerCallbackQuery
where
C: Into<String>;
type SetMyCommands: Request<Payload = SetMyCommands, Err = Self::Err>;
/// For telegram documentation see [`SetMyCommands`]
/// For Telegram documentation see [`SetMyCommands`].
fn set_my_commands<C>(&self, commands: C) -> Self::SetMyCommands
where
C: IntoIterator<Item = BotCommand>;
type GetMyCommands: Request<Payload = GetMyCommands, Err = Self::Err>;
/// For telegram documentation see [`GetMyCommands`]
/// For Telegram documentation see [`GetMyCommands`].
fn get_my_commands(&self) -> Self::GetMyCommands;
type AnswerInlineQuery: Request<Payload = AnswerInlineQuery, Err = Self::Err>;
/// For telegram documentation see [`AnswerInlineQuery`]
/// For Telegram documentation see [`AnswerInlineQuery`].
fn answer_inline_query<I, R>(&self, inline_query_id: I, results: R) -> Self::AnswerInlineQuery
where
I: Into<String>,
@ -468,7 +469,7 @@ pub trait Requester {
type EditMessageText: Request<Payload = EditMessageText, Err = Self::Err>;
/// For telegram documentation see [`EditMessageText`]
/// For Telegram documentation see [`EditMessageText`].
fn edit_message_text<C, T>(
&self,
chat_id: C,
@ -481,7 +482,7 @@ pub trait Requester {
type EditMessageTextInline: Request<Payload = EditMessageTextInline, Err = Self::Err>;
/// For telegram documentation see [`EditMessageTextInline`]
/// For Telegram documentation see [`EditMessageTextInline`].
fn edit_message_text_inline<I, T>(
&self,
inline_message_id: I,
@ -493,7 +494,7 @@ pub trait Requester {
type EditMessageCaption: Request<Payload = EditMessageCaption, Err = Self::Err>;
/// For telegram documentation see [`EditMessageCaption`]
/// For Telegram documentation see [`EditMessageCaption`].
fn edit_message_caption<Ch, Ca>(
&self,
chat_id: Ch,
@ -506,7 +507,7 @@ pub trait Requester {
type EditMessageCaptionInline: Request<Payload = EditMessageCaptionInline, Err = Self::Err>;
/// For telegram documentation see [`EditMessageCaptionInline`]
/// For Telegram documentation see [`EditMessageCaptionInline`].
fn edit_message_caption_inline<I, C>(
&self,
inline_message_id: I,
@ -518,7 +519,7 @@ pub trait Requester {
type EditMessageMedia: Request<Payload = EditMessageMedia, Err = Self::Err>;
/// For telegram documentation see [`EditMessageMedia`]
/// For Telegram documentation see [`EditMessageMedia`].
fn edit_message_media<C>(
&self,
chat_id: C,
@ -530,7 +531,7 @@ pub trait Requester {
type EditMessageMediaInline: Request<Payload = EditMessageMediaInline, Err = Self::Err>;
/// For telegram documentation see [`EditMessageMediaInline`]
/// For Telegram documentation see [`EditMessageMediaInline`].
fn edit_message_media_inline<I>(
&self,
inline_message_id: I,
@ -541,7 +542,7 @@ pub trait Requester {
type EditMessageReplyMarkup: Request<Payload = EditMessageReplyMarkup, Err = Self::Err>;
/// For telegram documentation see [`EditMessageReplyMarkup`]
/// For Telegram documentation see [`EditMessageReplyMarkup`].
fn edit_message_reply_markup<C>(
&self,
chat_id: C,
@ -555,7 +556,7 @@ pub trait Requester {
Err = Self::Err,
>;
/// For telegram documentation see [`EditMessageReplyMarkupInline`]
/// For Telegram documentation see [`EditMessageReplyMarkupInline`].
fn edit_message_reply_markup_inline<I>(
&self,
inline_message_id: I,
@ -565,40 +566,40 @@ pub trait Requester {
type StopPoll: Request<Payload = StopPoll, Err = Self::Err>;
/// For telegram documentation see [`StopPoll`]
/// For Telegram documentation see [`StopPoll`].
fn stop_poll<C>(&self, chat_id: C, message_id: i32) -> Self::StopPoll
where
C: Into<ChatId>;
type DeleteMessage: Request<Payload = DeleteMessage, Err = Self::Err>;
/// For telegram documentation see [`DeleteMessage`]
/// For Telegram documentation see [`DeleteMessage`].
fn delete_message<C>(&self, chat_id: C, message_id: i32) -> Self::DeleteMessage
where
C: Into<ChatId>;
type SendSticker: Request<Payload = SendSticker, Err = Self::Err>;
/// For telegram documentation see [`SendSticker`]
/// For Telegram documentation see [`SendSticker`].
fn send_sticker<C>(&self, chat_id: C, sticker: InputFile) -> Self::SendSticker
where
C: Into<ChatId>;
type GetStickerSet: Request<Payload = GetStickerSet, Err = Self::Err>;
/// For telegram documentation see [`GetStickerSet`]
/// For Telegram documentation see [`GetStickerSet`].
fn get_sticker_set<N>(&self, name: N) -> Self::GetStickerSet
where
N: Into<String>;
type UploadStickerFile: Request<Payload = UploadStickerFile, Err = Self::Err>;
/// For telegram documentation see [`UploadStickerFile`]
/// For Telegram documentation see [`UploadStickerFile`].
fn upload_sticker_file(&self, user_id: i32, png_sticker: InputFile) -> Self::UploadStickerFile;
type CreateNewStickerSet: Request<Payload = CreateNewStickerSet, Err = Self::Err>;
/// For telegram documentation see [`CreateNewStickerSet`]
/// For Telegram documentation see [`CreateNewStickerSet`].
fn create_new_sticker_set<N, T, E>(
&self,
user_id: i32,
@ -613,7 +614,7 @@ pub trait Requester {
type AddStickerToSet: Request<Payload = AddStickerToSet, Err = Self::Err>;
/// For telegram documentation see [`AddStickerToSet`]
/// For Telegram documentation see [`AddStickerToSet`].
fn add_sticker_to_set<N, E>(
&self,
user_id: i32,
@ -627,7 +628,7 @@ pub trait Requester {
type SetStickerPositionInSet: Request<Payload = SetStickerPositionInSet, Err = Self::Err>;
/// For telegram documentation see [`SetStickerPositionInSet`]
/// For Telegram documentation see [`SetStickerPositionInSet`].
fn set_sticker_position_in_set<S>(
&self,
sticker: S,
@ -638,21 +639,21 @@ pub trait Requester {
type DeleteStickerFromSet: Request<Payload = DeleteStickerFromSet, Err = Self::Err>;
/// For telegram documentation see [`DeleteStickerFromSet`]
/// For Telegram documentation see [`DeleteStickerFromSet`].
fn delete_sticker_from_set<S>(&self, sticker: S) -> Self::DeleteStickerFromSet
where
S: Into<String>;
type SetStickerSetThumb: Request<Payload = SetStickerSetThumb, Err = Self::Err>;
/// For telegram documentation see [`SetStickerSetThumb`]
/// For Telegram documentation see [`SetStickerSetThumb`].
fn set_sticker_set_thumb<N>(&self, name: N, user_id: i32) -> Self::SetStickerSetThumb
where
N: Into<String>;
type SendInvoice: Request<Payload = SendInvoice, Err = Self::Err>;
/// For telegram documentation see [`SendInvoice`]
/// For Telegram documentation see [`SendInvoice`].
#[allow(clippy::too_many_arguments)]
fn send_invoice<T, D, Pa, P, S, C, Pri>(
&self,
@ -676,14 +677,14 @@ pub trait Requester {
type AnswerShippingQuery: Request<Payload = AnswerShippingQuery, Err = Self::Err>;
/// For telegram documentation see [`AnswerShippingQuery`]
/// For Telegram documentation see [`AnswerShippingQuery`].
fn answer_shipping_query<S>(&self, shipping_query_id: S, ok: bool) -> Self::AnswerShippingQuery
where
S: Into<String>;
type AnswerPreCheckoutQuery: Request<Payload = AnswerPreCheckoutQuery, Err = Self::Err>;
/// For telegram documentation see [`AnswerPreCheckoutQuery`]
/// For Telegram documentation see [`AnswerPreCheckoutQuery`].
fn answer_pre_checkout_query<P>(
&self,
pre_checkout_query_id: P,
@ -694,7 +695,7 @@ pub trait Requester {
type SetPassportDataErrors: Request<Payload = SetPassportDataErrors, Err = Self::Err>;
/// For telegram documentation see [`SetPassportDataErrors`]
/// For Telegram documentation see [`SetPassportDataErrors`].
fn set_passport_data_errors<E>(&self, user_id: i32, errors: E) -> Self::SetPassportDataErrors
where
E: IntoIterator<Item = PassportElementError>;

View file

@ -9,6 +9,7 @@ use crate::adaptors::AutoSend;
#[cfg(feature = "throttle")]
use crate::adaptors::throttle::{Limits, Throttle};
/// Extensions methods for [`Requester`].
pub trait RequesterExt: Requester {
/// Add `get_me` caching ability, see [`CacheMe`] for more.
///