pub struct AbortController { /* private fields */ }
Expand description
AbortController
is a controller that allows you to monitor for a stream reset and
cancel an associated asynchronous task if the reset occurs.
Implementations§
Source§impl AbortController
impl AbortController
Sourcepub fn poll_reset(&mut self, cx: &mut Context<'_>) -> Poll<()>
pub fn poll_reset(&mut self, cx: &mut Context<'_>) -> Poll<()>
Polls to be notified when the client resets this rpc.
If the stream has not been reset. This returns Poll::Pending
Sourcepub async fn abort_on_reset(self, task: impl Future)
pub async fn abort_on_reset(self, task: impl Future)
Executes a given asynchronous task and aborts it when stream is reset.
§Example
controller.abort_on_reset(async { }).await;
Sourcepub fn spawn_and_abort_on_reset<F>(self, task: F) -> JoinHandle<()>
pub fn spawn_and_abort_on_reset<F>(self, task: F) -> JoinHandle<()>
Spawns a new task that will be aborted if the stream is reset.
This function spawns the given task in background, and automatically cancels the task if the stream reset event occurs.
§Example
controller.spawn_and_abort_on_reset(async { ... });
Auto Trait Implementations§
impl Freeze for AbortController
impl RefUnwindSafe for AbortController
impl Send for AbortController
impl Sync for AbortController
impl Unpin for AbortController
impl UnwindSafe for AbortController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more