Skip to main content

Guarded

Trait Guarded 

Source
pub trait Guarded: Send + Sync {
    // Required method
    fn guard(&self) -> &Guard;
}
Expand description

把 Guard 从应用状态里取出来。

实现它只需要指向一个字段。适配层据此提供各框架的提取器 / 守卫。

Guard 自身与 Arc<Guard> 已经实现了它,所以「状态就是一把守卫」这种 最小场景不需要写任何代码。

Required Methods§

Source

fn guard(&self) -> &Guard

取出守卫。永远成功 —— 取不到说明状态装配错了,那是编译期该发现的事。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Guarded for Arc<Guard>

Source§

fn guard(&self) -> &Guard

Implementors§