mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Move polling_builder
=> Polling::builder
This commit is contained in:
parent
195d34ba0c
commit
79f6cf4ee9
3 changed files with 22 additions and 20 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue