Move polling_builder => Polling::builder

Former-commit-id: 79f6cf4ee9
This commit is contained in:
Maybe Waffle 2022-06-27 03:28:23 +04:00
parent 79e393c445
commit cce0710c8c
3 changed files with 22 additions and 20 deletions

View file

@ -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

View file

@ -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,
};

View file

@ -99,21 +99,6 @@ where
}
}
/// Returns a builder for polling update listener.
pub fn polling_builder<R>(bot: R) -> PollingBuilder<R>
where
R: Requester + Send + 'static,
<R as Requester>::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,
<R as Requester>::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<R>(
bot: R,
timeout: Option<Duration>,
@ -141,7 +126,7 @@ where
R: Requester + Send + 'static,
<R as Requester>::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<B: Requester> {
token: AsyncStopToken,
}
impl<R> Polling<R>
where
R: Requester + Send + 'static,
<R as Requester>::GetUpdates: Send,
{
/// Returns a builder for polling update listener.
pub fn builder(bot: R) -> PollingBuilder<R> {
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