OperationScope

Struct OperationScope 

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

Implementations§

Source§

impl<'a> OperationScope<'a>

Source

pub fn mark_success(&mut self)

显式标记成功

Source

pub fn mark_failure(&mut self)

保持失败状态(默认行为)

Source

pub fn cancel(&mut self)

标记为取消并阻止成功写入

Methods from Deref<Target = OperationContext>§

Source

pub fn context(&self) -> &CallContext

Get field context from instance of OperationContext.

Source

pub fn result(&self) -> &OperationResult

Get field result from instance of OperationContext.

Source

pub fn exit_log(&self) -> &bool

Get field exit_log from instance of OperationContext.

Source

pub fn mod_path(&self) -> &String

Get field mod_path from instance of OperationContext.

Source

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

Get field target from instance of OperationContext.

Source

pub fn with<S1: Into<String>, S2: Into<String>>(&mut self, key: S1, val: S2)

👎Deprecated since 0.5.4: use record
Source

pub fn with_path<S1: Into<String>, S2: Into<PathBuf>>( &mut self, key: S1, val: S2, )

👎Deprecated since 0.5.4: use record
Source

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

Source

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

别名:设置目标资源/操作名,与 with_want 等效

Source

pub fn mark_suc(&mut self)

Source

pub fn mark_cancel(&mut self)

Source

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

创建作用域 guard,默认为失败状态,需显式 mark_success()

Source

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

创建作用域 guard,在作用域结束时自动标记成功

Source

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

记录日志信息,在无错误情况下也可以提供有价值的上下文信息 注意:需要启用 log 特性

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)

与文档示例一致的别名方法(调用上面的同名方法)

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> !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.