Struct OperationContext
pub struct OperationContext {
pub name: Option<String>,
pub deadline: Option<Deadline>,
cancelled: Arc<AtomicBool>,
parent: Option<Arc<OperationContext>>,
created_at: Instant,
}Expand description
Context for tracking operation state including deadlines and cancellation.
Fields§
§name: Option<String>Operation name/ID for tracing.
deadline: Option<Deadline>Deadline for the operation.
cancelled: Arc<AtomicBool>§parent: Option<Arc<OperationContext>>§created_at: InstantImplementations§
§impl OperationContext
impl OperationContext
pub fn new() -> OperationContext
pub fn new() -> OperationContext
Create a new operation context.
pub fn with_name(self, name: impl Into<String>) -> OperationContext
pub fn with_name(self, name: impl Into<String>) -> OperationContext
Set the operation name.
pub fn with_deadline(self, deadline: Deadline) -> OperationContext
pub fn with_deadline(self, deadline: Deadline) -> OperationContext
Set a deadline.
pub fn with_timeout(self, timeout: Duration) -> OperationContext
pub fn with_timeout(self, timeout: Duration) -> OperationContext
Set a timeout (creates deadline from duration).
pub fn with_parent(self, parent: Arc<OperationContext>) -> OperationContext
pub fn with_parent(self, parent: Arc<OperationContext>) -> OperationContext
Set parent context.
pub fn child(&self) -> OperationContext
pub fn child(&self) -> OperationContext
Create a child context.
pub fn child_with_timeout(&self, timeout: Duration) -> OperationContext
pub fn child_with_timeout(&self, timeout: Duration) -> OperationContext
Create a child context with additional timeout.
pub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if operation is cancelled.
pub fn cancel(&self)
pub fn cancel(&self)
Cancel the operation.
pub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if deadline has expired.
pub fn remaining_time(&self) -> Option<Duration>
pub fn remaining_time(&self) -> Option<Duration>
Get remaining time until deadline.
pub fn should_continue(&self) -> bool
pub fn should_continue(&self) -> bool
Check if operation should continue (not cancelled, not expired).
pub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Get the cancellation token for sharing.
Trait Implementations§
§impl Clone for OperationContext
impl Clone for OperationContext
§fn clone(&self) -> OperationContext
fn clone(&self) -> OperationContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for OperationContext
impl Debug for OperationContext
§impl Default for OperationContext
impl Default for OperationContext
§fn default() -> OperationContext
fn default() -> OperationContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OperationContext
impl RefUnwindSafe for OperationContext
impl Send for OperationContext
impl Sync for OperationContext
impl Unpin for OperationContext
impl UnwindSafe for OperationContext
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.