pub struct CancelContext { /* private fields */ }
Expand description
A cancellation context.
This is used to get a notification when an operation has been cancelled. It can be cloned or sent across process boundaries.
Implementations§
Source§impl CancelContext
impl CancelContext
Sourcepub fn with_cancel(&self) -> (Self, Cancel)
pub fn with_cancel(&self) -> (Self, Cancel)
Returns a new child context and a cancel function.
The new context is notified when either this context is cancelled, or
the returned Cancel
object’s cancel
method is called.
Sourcepub fn with_deadline(&self, deadline: Deadline) -> Self
pub fn with_deadline(&self, deadline: Deadline) -> Self
Returns a new child context with a deadline.
The new context is notified when either this context is cancelled, or the deadline is exceeded.
Sourcepub fn with_timeout(&self, timeout: Duration) -> Self
pub fn with_timeout(&self, timeout: Duration) -> Self
Returns a new child context with a timeout.
The new context is notified when either this context is cancelled, or the timeout has expired.
Sourcepub fn cancelled(&mut self) -> Cancelled<'_> ⓘ
pub fn cancelled(&mut self) -> Cancelled<'_> ⓘ
Returns a future that completes when the context is cancelled.
Sourcepub async fn until_cancelled<F: Future>(
&mut self,
fut: F,
) -> Result<F::Output, CancelReason>
pub async fn until_cancelled<F: Future>( &mut self, fut: F, ) -> Result<F::Output, CancelReason>
Runs fut
until this context is cancelled.
Sourcepub async fn until_cancelled_failable<F: Future<Output = Result<T, E>>, T, E>(
&mut self,
fut: F,
) -> Result<T, ErrorOrCancelled<E>>
pub async fn until_cancelled_failable<F: Future<Output = Result<T, E>>, T, E>( &mut self, fut: F, ) -> Result<T, ErrorOrCancelled<E>>
Runs a failable future until this context is cancelled, merging the result with the cancellation reason.
Sourcepub fn is_cancelled(&mut self) -> bool
pub fn is_cancelled(&mut self) -> bool
Returns true if the context has been cancelled.
Trait Implementations§
Source§impl Clone for CancelContext
impl Clone for CancelContext
Source§impl Debug for CancelContext
impl Debug for CancelContext
Source§impl Default for CancelContext
impl Default for CancelContext
Source§impl DefaultEncoding for CancelContext
impl DefaultEncoding for CancelContext
Source§impl Drop for CancelContext
impl Drop for CancelContext
Source§impl<'encoding> StructDecodeMetadata<'encoding, Resource> for CancelContext
impl<'encoding> StructDecodeMetadata<'encoding, Resource> for CancelContext
Source§impl StructEncodeMetadata<Resource> for CancelContext
impl StructEncodeMetadata<Resource> for CancelContext
Auto Trait Implementations§
impl Freeze for CancelContext
impl !RefUnwindSafe for CancelContext
impl Send for CancelContext
impl Sync for CancelContext
impl Unpin for CancelContext
impl !UnwindSafe for CancelContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> MeshField for T
impl<T> MeshField for T
§impl<T> MeshPayload for T
impl<T> MeshPayload for T
§impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
§fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
MessageEncode::compute_message_size
].§fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
MessageEncode::write_message
].