Return named Polling<_> type from polling* functions

This replaces the `impl UpdateListener<R::Err>` and makes using polling
nicer.


Former-commit-id: db417caa52
This commit is contained in:
Maybe Waffle 2022-06-27 02:06:29 +04:00
parent 2ceccdf442
commit e51c4c774c

View file

@ -71,7 +71,7 @@ where
} }
/// Creates a polling update listener. /// Creates a polling update listener.
pub fn build(self) -> impl UpdateListener<R::Err> { pub fn build(self) -> Polling<R> {
let Self { bot, timeout, limit, allowed_updates } = self; let Self { bot, timeout, limit, allowed_updates } = self;
polling(bot, timeout, limit, allowed_updates) polling(bot, timeout, limit, allowed_updates)
} }
@ -93,7 +93,7 @@ where
/// ## Notes /// ## Notes
/// ///
/// This function will automatically delete a webhook if it was set up. /// This function will automatically delete a webhook if it was set up.
pub async fn polling_default<R>(bot: R) -> impl UpdateListener<R::Err> pub async fn polling_default<R>(bot: R) -> Polling<R>
where where
R: Requester + Send + 'static, R: Requester + Send + 'static,
<R as Requester>::GetUpdates: Send, <R as Requester>::GetUpdates: Send,
@ -198,7 +198,7 @@ pub fn polling<R>(
timeout: Option<Duration>, timeout: Option<Duration>,
limit: Option<u8>, limit: Option<u8>,
allowed_updates: Option<Vec<AllowedUpdate>>, allowed_updates: Option<Vec<AllowedUpdate>>,
) -> impl UpdateListener<R::Err> ) -> Polling<R>
where where
R: Requester + Send + 'static, R: Requester + Send + 'static,
<R as Requester>::GetUpdates: Send, <R as Requester>::GetUpdates: Send,
@ -228,7 +228,7 @@ where
} }
} }
struct Polling<B: Requester> { pub struct Polling<B: Requester> {
bot: B, bot: B,
timeout: Option<Duration>, timeout: Option<Duration>,
limit: Option<u8>, limit: Option<u8>,
@ -238,7 +238,7 @@ struct Polling<B: Requester> {
} }
#[pin_project::pin_project] #[pin_project::pin_project]
struct PollingStream<'a, B: Requester> { pub struct PollingStream<'a, B: Requester> {
/// Parent structure /// Parent structure
polling: &'a mut Polling<B>, polling: &'a mut Polling<B>,