Skip to main content

OperationScope

Struct OperationScope 

Source
pub struct OperationScope<'a> { /* private fields */ }
Expand description

Guard value for scoped OperationContext lifecycle management.

Created via OperationContext::scope or [OperationContext::auto_scope]. Automatically records the exit result when dropped.

Implementations§

Source§

impl<'a> OperationScope<'a>

Source

pub fn with_field<K, V>(&mut self, key: K, val: V) -> &mut Self
where K: Into<String>, V: Display,

Builder-style field addition while keeping the scope guard alive.

Source

pub fn with_meta<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: Into<String>, V: Into<MetadataValue>,

Builder-style metadata addition while keeping the scope guard alive.

Source

pub fn mark_success(&mut self)

Explicitly mark as success.

Source

pub fn mark_failure(&mut self)

Keep the failure state (default behavior).

Source

pub fn cancel(&mut self)

Mark as cancelled and prevent success write.

Methods from Deref<Target = OperationContext>§

Source

pub fn context(&self) -> &CallContext

Source

pub fn result(&self) -> &OperationResult

Source

pub fn exit_log(&self) -> &bool

Source

pub fn mod_path(&self) -> &String

Source

pub fn action(&self) -> &Option<String>

Source

pub fn locator(&self) -> &Option<String>

Source

pub fn path(&self) -> &[String]

Source

pub fn metadata(&self) -> &ErrorMetadata

Source

pub fn with_doing<S: Into<String>>(&mut self, action: S)

Source

pub fn with_at<S: Into<String>>(&mut self, locator: S)

Source

pub fn set_target<S: Into<String>>(&mut self, target: S)

Alias: set the target resource/operation name. The first call establishes the root target; subsequent calls only append to the path.

Source

pub fn path_string(&self) -> Option<String>

Source

pub fn record_field<K, V>(&mut self, key: K, val: V)
where K: Into<String>, V: Display,

Record a human-readable key-value pair into the context stack.

The entry will appear in the error’s Display output. For typed metadata hidden from console output, use [record_meta()] instead.

Prefer with_field for chained construction. record_field is for when you already have a mutable reference.

Source

pub fn record<K, V>(&mut self, key: K, val: V)
where K: Into<String>, V: Display,

Source

pub fn record_meta<K, V>(&mut self, key: K, value: V)
where K: Into<String>, V: Into<MetadataValue>,

Record typed metadata that is not included in Display output.

Use this for structured fields intended for serialization, snapshots, or API responses. For user-visible context entries, use [record_field()].

Prefer with_meta for chained construction. record_meta is for when you already have a mutable reference.

Source

pub fn mark_suc(&mut self)

Source

pub fn mark_cancel(&mut self)

Source

pub fn scope(&mut self) -> OperationScope<'_>

Create a scope guard, defaulting to failure state. Requires explicit mark_success(), mark_cancel(), or mark_fail().

Source

pub fn scoped_success(&mut self) -> OperationScope<'_>

Create a scope guard that automatically marks success on drop.

Source

pub fn info<S: AsRef<str>>(&self, message: S)

Source

pub fn debug<S: AsRef<str>>(&self, message: S)

Source

pub fn warn<S: AsRef<str>>(&self, message: S)

Source

pub fn error<S: AsRef<str>>(&self, message: S)

Source

pub fn trace<S: AsRef<str>>(&self, message: S)

Source

pub fn log_info<S: AsRef<str>>(&self, message: S)

Alias for documentation consistency (calls the same-named method above).

Source

pub fn log_debug<S: AsRef<str>>(&self, message: S)

Source

pub fn log_warn<S: AsRef<str>>(&self, message: S)

Source

pub fn log_error<S: AsRef<str>>(&self, message: S)

Source

pub fn log_trace<S: AsRef<str>>(&self, message: S)

Trait Implementations§

Source§

impl<'a> Deref for OperationScope<'a>

Source§

type Target = OperationContext

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> DerefMut for OperationScope<'a>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for OperationScope<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for OperationScope<'a>

§

impl<'a> RefUnwindSafe for OperationScope<'a>

§

impl<'a> Send for OperationScope<'a>

§

impl<'a> Sync for OperationScope<'a>

§

impl<'a> Unpin for OperationScope<'a>

§

impl<'a> UnsafeUnpin for OperationScope<'a>

§

impl<'a> !UnwindSafe for OperationScope<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.