pub struct OperationContext {
pub name: Option<String>,
pub deadline: Option<Deadline>,
/* private fields */
}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.
Implementations§
Source§impl OperationContext
impl OperationContext
Sourcepub fn new() -> OperationContext
pub fn new() -> OperationContext
Create a new operation context.
Sourcepub fn with_name(self, name: impl Into<String>) -> OperationContext
pub fn with_name(self, name: impl Into<String>) -> OperationContext
Set the operation name.
Sourcepub fn with_deadline(self, deadline: Deadline) -> OperationContext
pub fn with_deadline(self, deadline: Deadline) -> OperationContext
Set a deadline.
Sourcepub fn with_timeout(self, timeout: Duration) -> OperationContext
pub fn with_timeout(self, timeout: Duration) -> OperationContext
Set a timeout (creates deadline from duration).
Sourcepub fn with_parent(self, parent: Arc<OperationContext>) -> OperationContext
pub fn with_parent(self, parent: Arc<OperationContext>) -> OperationContext
Set parent context.
Sourcepub fn child(&self) -> OperationContext
pub fn child(&self) -> OperationContext
Create a child context.
Sourcepub fn child_with_timeout(&self, timeout: Duration) -> OperationContext
pub fn child_with_timeout(&self, timeout: Duration) -> OperationContext
Create a child context with additional timeout.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if operation is cancelled.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if deadline has expired.
Sourcepub fn remaining_time(&self) -> Option<Duration>
pub fn remaining_time(&self) -> Option<Duration>
Get remaining time until deadline.
Sourcepub fn should_continue(&self) -> bool
pub fn should_continue(&self) -> bool
Check if operation should continue (not cancelled, not expired).
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Get the cancellation token for sharing.
Trait Implementations§
Source§impl Clone for OperationContext
impl Clone for OperationContext
Source§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 moreSource§impl Debug for OperationContext
impl Debug for OperationContext
Source§impl Default for OperationContext
impl Default for OperationContext
Source§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§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§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,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§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.