mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Fix polling
's StopToken
not being Send
This commit is contained in:
parent
818a493a4a
commit
a7182962f7
3 changed files with 16 additions and 3 deletions
|
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Infinite retries while stopping polling listener ([issue 496](https://github.com/teloxide/teloxide/issues/496))
|
- Infinite retries while stopping polling listener ([issue 496](https://github.com/teloxide/teloxide/issues/496))
|
||||||
|
- `polling{,_default}` and it's `Stream` and `StopToken` not being `Send` (and by extension fix the same problem with `repl`s)
|
||||||
|
|
||||||
## 0.5.3 - 2021-10-25
|
## 0.5.3 - 2021-10-25
|
||||||
|
|
||||||
|
|
|
@ -83,3 +83,12 @@ pub async fn repl_with_listener<'a, R, H, Fut, E, L, ListenerE>(
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn repl_is_send() {
|
||||||
|
let bot = crate::Bot::new("");
|
||||||
|
let repl = crate::repl(bot, |_| async { crate::respond(()) });
|
||||||
|
assert_send(&repl);
|
||||||
|
|
||||||
|
fn assert_send(_: &impl Send) {}
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use futures::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::{
|
dispatching::{
|
||||||
stop_token::{AsyncStopFlag, AsyncStopToken},
|
stop_token::{AsyncStopFlag, AsyncStopToken, StopToken},
|
||||||
update_listeners::{stateful_listener::StatefulListener, UpdateListener},
|
update_listeners::{stateful_listener::StatefulListener, UpdateListener},
|
||||||
},
|
},
|
||||||
payloads::{GetUpdates, GetUpdatesSetters as _},
|
payloads::{GetUpdates, GetUpdatesSetters as _},
|
||||||
|
@ -22,7 +22,9 @@ use crate::{
|
||||||
/// ## Notes
|
/// ## Notes
|
||||||
///
|
///
|
||||||
/// This function will automatically delete a webhook if it was set up.
|
/// This function will automatically delete a webhook if it was set up.
|
||||||
pub async fn polling_default<R>(requester: R) -> impl UpdateListener<R::Err>
|
pub async fn polling_default<R>(
|
||||||
|
requester: R,
|
||||||
|
) -> impl UpdateListener<R::Err, StopToken = impl Send + StopToken>
|
||||||
where
|
where
|
||||||
R: Requester + Send + 'static,
|
R: Requester + Send + 'static,
|
||||||
<R as Requester>::GetUpdates: Send,
|
<R as Requester>::GetUpdates: Send,
|
||||||
|
@ -48,7 +50,7 @@ pub fn polling<R>(
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
limit: Option<u8>,
|
limit: Option<u8>,
|
||||||
allowed_updates: Option<Vec<AllowedUpdate>>,
|
allowed_updates: Option<Vec<AllowedUpdate>>,
|
||||||
) -> impl UpdateListener<R::Err>
|
) -> impl UpdateListener<R::Err, StopToken = impl Send + StopToken>
|
||||||
where
|
where
|
||||||
R: Requester + Send + 'static,
|
R: Requester + Send + 'static,
|
||||||
<R as Requester>::GetUpdates: Send,
|
<R as Requester>::GetUpdates: Send,
|
||||||
|
@ -172,6 +174,7 @@ fn polling_is_send() {
|
||||||
|
|
||||||
assert_send(&polling);
|
assert_send(&polling);
|
||||||
assert_send(&polling.as_stream());
|
assert_send(&polling.as_stream());
|
||||||
|
assert_send(&polling.stop_token());
|
||||||
|
|
||||||
fn assert_send(_: &impl Send) {}
|
fn assert_send(_: &impl Send) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue