From cce0710c8ccc0846df35def421a7aca0f4fe5161 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 27 Jun 2022 03:28:23 +0400 Subject: [PATCH] Move `polling_builder` => `Polling::builder` Former-commit-id: 79f6cf4ee9ff0a13613b80cd3f690382916d91ca --- CHANGELOG.md | 2 +- src/dispatching/update_listeners.rs | 2 +- src/dispatching/update_listeners/polling.rs | 38 +++++++++++---------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2baea730..67ef18dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Security checks based on `secret_token` param of `set_webhook` to built-in webhooks -- `dispatching::update_listeners::{polling_builder, PollingBuilder, Polling, PollingStream}` +- `dispatching::update_listeners::{PollingBuilder, Polling, PollingStream}` ### Fixed diff --git a/src/dispatching/update_listeners.rs b/src/dispatching/update_listeners.rs index 677f681e..03a9fc5c 100644 --- a/src/dispatching/update_listeners.rs +++ b/src/dispatching/update_listeners.rs @@ -44,7 +44,7 @@ mod stateful_listener; #[allow(deprecated)] pub use self::{ - polling::{polling, polling_builder, polling_default, Polling, PollingBuilder, PollingStream}, + polling::{polling, polling_default, Polling, PollingBuilder, PollingStream}, stateful_listener::StatefulListener, }; diff --git a/src/dispatching/update_listeners/polling.rs b/src/dispatching/update_listeners/polling.rs index f71b8d1c..c41eeabe 100644 --- a/src/dispatching/update_listeners/polling.rs +++ b/src/dispatching/update_listeners/polling.rs @@ -99,21 +99,6 @@ where } } -/// Returns a builder for polling update listener. -pub fn polling_builder(bot: R) -> PollingBuilder -where - R: Requester + Send + 'static, - ::GetUpdates: Send, -{ - PollingBuilder { - bot, - timeout: None, - limit: None, - allowed_updates: None, - drop_pending_updates: false, - } -} - /// Returns a long polling update listener with `timeout` of 10 seconds. /// /// See also: [`polling_builder`]. @@ -126,11 +111,11 @@ where R: Requester + Send + 'static, ::GetUpdates: Send, { - polling_builder(bot).timeout(Duration::from_secs(10)).delete_webhook().await.build() + Polling::builder(bot).timeout(Duration::from_secs(10)).delete_webhook().await.build() } /// Returns a long polling update listener with some additional options. -#[deprecated(since = "0.10.0", note = "use `polling_builder` instead")] +#[deprecated(since = "0.10.0", note = "use `Polling::builder()` instead")] pub fn polling( bot: R, timeout: Option, @@ -141,7 +126,7 @@ where R: Requester + Send + 'static, ::GetUpdates: Send, { - let mut builder = polling_builder(bot); + let mut builder = Polling::builder(bot); builder.timeout = timeout; builder.limit = limit; builder.allowed_updates = allowed_updates; @@ -250,6 +235,23 @@ pub struct Polling { token: AsyncStopToken, } +impl Polling +where + R: Requester + Send + 'static, + ::GetUpdates: Send, +{ + /// Returns a builder for polling update listener. + pub fn builder(bot: R) -> PollingBuilder { + PollingBuilder { + bot, + timeout: None, + limit: None, + allowed_updates: None, + drop_pending_updates: false, + } + } +} + #[pin_project::pin_project] pub struct PollingStream<'a, B: Requester> { /// Parent structure