Require that UpdateListener::StopToken is Send

This commit is contained in:
Maybe Waffle 2022-03-24 19:47:42 +04:00
parent 10b1e045c7
commit ceb2415351
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>,
{