Skip to main content

OperationContext

Struct OperationContext 

Source
pub struct OperationContext { /* private fields */ }

Implementations§

Source§

impl 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 new() -> Self

Source

pub fn doing<S: Into<String>>(action: S) -> Self

Source

pub fn at<S: Into<String>>(locator: S) -> Self

Source

pub fn with_auto_log(self) -> Self

Source

pub fn with_mod_path<S: Into<String>>(self, path: S) -> Self

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 with_field<K, V>(self, key: K, val: V) -> Self
where K: Into<String>, V: Display,

Builder-pattern version of [record_field].

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 with_meta<K, V>(self, key: K, value: V) -> Self
where K: Into<String>, V: Into<MetadataValue>,

Builder-pattern version of [record_meta].

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 Clone for OperationContext

Source§

fn clone(&self) -> OperationContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OperationContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OperationContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for OperationContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for OperationContext

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for OperationContext

§

impl From<&OperationContext> for OperationContext

§

fn from(value: &OperationContext) -> Self

Converts to this type from the input type.
§

impl From<&Path> for OperationContext

§

fn from(value: &Path) -> Self

Converts to this type from the input type.
§

impl From<&PathBuf> for OperationContext

§

fn from(value: &PathBuf) -> Self

Converts to this type from the input type.
§

impl From<&str> for OperationContext

§

fn from(value: &str) -> Self

Converts to this type from the input type.
§

impl From<(&str, &str)> for OperationContext

§

fn from(value: (&str, &str)) -> Self

Converts to this type from the input type.
§

impl From<(&str, String)> for OperationContext

§

fn from(value: (&str, String)) -> Self

Converts to this type from the input type.
§

impl<V> From<(&str, V)> for OperationContext
where V: NotAsRefStr + AsRef<Path>,

§

fn from(value: (&str, V)) -> Self

Converts to this type from the input type.
§

impl From<(String, String)> for OperationContext

§

fn from(value: (String, String)) -> Self

Converts to this type from the input type.
§

impl From<String> for OperationContext

§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for OperationContext

Source§

fn eq(&self, other: &OperationContext) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OperationContext

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.