Merge pull request #568 from teloxide/stop_send

Require that `UpdateListener::StopToken` is `Send`
This commit is contained in:
Waffle Maybe 2022-03-27 21:48:17 +04:00 committed by GitHub
commit 5bd134bc21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View file

@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## unreleased
### Changed
- `UpdateListener::StopToken` is now always `Send`
## 0.7.2 - 2022-03-23
### Added

View file

@ -53,7 +53,7 @@ pub use self::{
/// [module-level documentation]: mod@self
pub trait UpdateListener<E>: for<'a> AsUpdateStream<'a, E> {
/// The type of token which allows to stop this listener.
type StopToken: StopToken;
type StopToken: StopToken + Send;
/// Returns a token which stops this listener.
///

View file

@ -7,7 +7,7 @@ use futures::{
use crate::{
dispatching::{
stop_token::{AsyncStopFlag, AsyncStopToken, StopToken},
stop_token::{AsyncStopFlag, AsyncStopToken},
update_listeners::{stateful_listener::StatefulListener, UpdateListener},
},
payloads::{GetUpdates, GetUpdatesSetters as _},
@ -22,9 +22,7 @@ use crate::{
/// ## Notes
///
/// This function will automatically delete a webhook if it was set up.
pub async fn polling_default<R>(
requester: R,
) -> impl UpdateListener<R::Err, StopToken = impl Send + StopToken>
pub async fn polling_default<R>(requester: R) -> impl UpdateListener<R::Err>
where
R: Requester + Send + 'static,
<R as Requester>::GetUpdates: Send,
@ -130,7 +128,7 @@ pub fn polling<R>(
timeout: Option<Duration>,
limit: Option<u8>,
allowed_updates: Option<Vec<AllowedUpdate>>,
) -> impl UpdateListener<R::Err, StopToken = impl Send + StopToken>
) -> impl UpdateListener<R::Err>
where
R: Requester + Send + 'static,
<R as Requester>::GetUpdates: Send,

View file

@ -123,7 +123,7 @@ impl<St, Assf, Sf, Hauf, Stt, Thf, E> UpdateListener<E>
where
Self: for<'a> AsUpdateStream<'a, E>,
Sf: FnMut(&mut St) -> Stt,
Stt: StopToken,
Stt: StopToken + Send,
Hauf: FnMut(&mut St, &mut dyn Iterator<Item = AllowedUpdate>),
Thf: Fn(&St) -> Option<Duration>,
{