Make GetUpdates expose its timeout via Payload::timeout_hint

This commit is contained in:
Maybe Waffle 2022-02-14 19:48:32 +03:00
parent 2dc4a915ba
commit fb7710b838
2 changed files with 10 additions and 0 deletions

View file

@ -99,6 +99,9 @@ macro_rules! impl_payload {
$(
@[multipart = $($multipart_attr:ident),*]
)?
$(
@[timeout_secs = $timeout_secs:ident]
)?
$(
#[ $($method_meta:tt)* ]
)*
@ -179,6 +182,12 @@ macro_rules! impl_payload {
type Output = $Ret;
const NAME: &'static str = stringify!($Method);
$(
fn timeout_hint(&self) -> Option<std::time::Duration> {
self.$timeout_secs.map(<_>::into).map(std::time::Duration::from_secs)
}
)?
}
calculated_doc! {

View file

@ -11,6 +11,7 @@ use serde::Serialize;
use crate::types::{AllowedUpdate, Update};
impl_payload! {
@[timeout_secs = timeout]
/// Use this method to receive incoming updates using long polling ([wiki]). An Array of [`Update`] objects is returned.
///
/// [wiki]: https://en.wikipedia.org/wiki/Push_technology#Long_polling