teloxide_core_ng/requests/payload.rs
1use std::time::Duration;
2
3/// Payload of a request.
4///
5/// Simply speaking, structures implementing this trait represent arguments of
6/// a Telegram bot API method.
7///
8/// Also, this trait provides some additional information needed to send a
9/// request to Telegram.
10#[cfg_attr(all(any(docsrs, dep_docsrs), feature = "nightly"), doc(notable_trait))]
11pub trait Payload {
12 /// The return type of a Telegram method.
13 ///
14 /// Note: it should not include `Result` wrappers (e.g. it should be simply
15 /// [`Message`], [`True`] or something else).
16 ///
17 /// [`Message`]: crate::types::Message
18 /// [`True`]: crate::types::True
19 type Output;
20
21 /// Name of a Telegram method.
22 ///
23 /// It is case insensitive, though must not include underscores. (e.g.
24 /// `GetMe`, `GETME`, `getme`, `getMe` are ok, but `get_me` is not ok).
25 const NAME: &'static str;
26
27 /// If this payload may take long time to execute (e.g. [`GetUpdates`] with
28 /// big `timeout`), the **minimum** timeout that should be used.
29 ///
30 /// [`GetUpdates`]: crate::payloads::GetUpdates
31 fn timeout_hint(&self) -> Option<Duration> {
32 None
33 }
34}