1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
use crate::{adaptors::DefaultParseMode, requests::Requester, types::ParseMode}; #[cfg(feature = "cache_me")] use crate::adaptors::CacheMe; #[cfg(feature = "auto_send")] 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. /// /// [`CacheMe`]: #[cfg(feature = "cache_me")] #[cfg_attr(all(docsrs, feature = "nightly"), doc(cfg(feature = "cache_me")))] fn cache_me(self) -> CacheMe<Self> where Self: Sized, { CacheMe::new(self) } /// Send requests automatically, see [`AutoSend`] for more. #[cfg(feature = "auto_send")] #[cfg_attr(all(docsrs, feature = "nightly"), doc(cfg(feature = "auto_send")))] fn auto_send(self) -> AutoSend<Self> where Self: Sized, { AutoSend::new(self) } /// Add throttling ability, see [`Throttle`] for more. /// /// Note: this spawns the worker, just as [`Throttle::new_spawn`]. #[cfg(feature = "throttle")] #[cfg_attr(all(docsrs, feature = "nightly"), doc(cfg(feature = "throttle")))] fn throttle(self, limits: Limits) -> Throttle<Self> where Self: Sized, // >:( // (waffle) Self: 'static, { Throttle::new_spawn(self, limits) } /// Specifies default [`ParseMode`], which will be used during all calls to: /// /// - [`send_message`] /// - [`send_photo`] /// - [`send_video`] /// - [`send_audio`] /// - [`send_document`] /// - [`send_animation`] /// - [`send_voice`] /// - [`send_poll`] /// - [`edit_message_text`] (and [`edit_message_text_inline`]) /// - [`edit_message_caption`] (and [`edit_message_caption_inline`]) /// /// [`send_message`]: crate::requests::Requester::send_message /// [`send_photo`]: crate::requests::Requester::send_photo /// [`send_video`]: crate::requests::Requester::send_video /// [`send_audio`]: crate::requests::Requester::send_audio /// [`send_document`]: crate::requests::Requester::send_document /// [`send_animation`]: crate::requests::Requester::send_animation /// [`send_voice`]: crate::requests::Requester::send_voice /// [`send_poll`]: crate::requests::Requester::send_poll /// [`edit_message_text`]: crate::requests::Requester::edit_message_text /// [`edit_message_text_inline`]: /// crate::requests::Requester::edit_message_text_inline /// [`edit_message_caption`]: /// crate::requests::Requester::edit_message_caption /// [`edit_message_caption_inline`]: /// crate::requests::Requester::edit_message_caption_inline fn parse_mode(self, parse_mode: ParseMode) -> DefaultParseMode<Self> where Self: Sized, { DefaultParseMode::new(self, parse_mode) } } impl<T> RequesterExt for T where T: Requester, { /* use default impls */ }