pub struct OpContext {
pub request_id: u64,
pub cancel: CancelFlag,
pub progress: Option<ProgressSink>,
/* private fields */
}Expand description
Immutable-ish control context for one operation.
Fresh cancel token per operation — never reset a shared engine flag across ops.
Deadline uses a single absolute monotonic Instant; nested APIs should call
Self::remaining rather than stacking independent timeouts.
Fields§
§request_id: u64§cancel: CancelFlag§progress: Option<ProgressSink>Implementations§
Source§impl OpContext
impl OpContext
pub fn new() -> Self
Sourcepub fn with_cancel(cancel: CancelFlag) -> Self
pub fn with_cancel(cancel: CancelFlag) -> Self
Create from an optional host cancel flag (cloned ownership of the same token).
Sourcepub fn from_optional_cancel(cancel: Option<CancelFlag>) -> Self
pub fn from_optional_cancel(cancel: Option<CancelFlag>) -> Self
Build from an optional cancel flag, creating a fresh token when absent.
pub fn with_deadline_from_now(self, timeout: Duration) -> Self
pub fn with_absolute_deadline(self, at: Instant) -> Self
pub fn with_progress(self, sink: ProgressSink) -> Self
pub fn deadline(&self) -> Option<Instant>
pub fn remaining(&self) -> Option<Duration>
pub fn emit(&self, stage: &'static str, detail: impl Into<String>)
Sourcepub fn timeout_or(&self, fallback: Duration) -> Duration
pub fn timeout_or(&self, fallback: Duration) -> Duration
Tokio-compatible timeout duration for the remaining budget (or fallback).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for OpContext
impl !UnwindSafe for OpContext
impl Freeze for OpContext
impl Send for OpContext
impl Sync for OpContext
impl Unpin for OpContext
impl UnsafeUnpin for OpContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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