Skip to main content

Effectful

Struct Effectful 

Source
pub struct Effectful { /* private fields */ }
Expand description

代数效应请求上下文

包含依赖容器和请求信息,用于在请求处理过程中获取依赖。

Implementations§

Source§

impl Effectful

Source

pub fn new(deps: Arc<Dependencies>, parts: Parts) -> Self

创建新的 Effectful

Source

pub fn get<T: Clone + Send + Sync + 'static>(&self, name: &str) -> WaeResult<T>

获取依赖(按字符串键)

如果依赖是 RequestScoped 作用域,将从当前请求的独立存储中获取或初始化。

Source

pub fn set<T: Send + Sync + 'static>( &mut self, name: &str, service: T, ) -> WaeResult<()>

设置请求作用域的依赖(按字符串键)

仅对 RequestScoped 作用域的依赖有效。

Source

pub fn get_type<T: Clone + Send + Sync + 'static>(&self) -> WaeResult<T>

按类型获取依赖

如果依赖是 RequestScoped 作用域,将从当前请求的独立存储中获取或初始化。

Source

pub fn set_type<T: Clone + Send + Sync + 'static>( &mut self, service: T, ) -> WaeResult<()>

设置请求作用域的依赖(按类型)

仅对 RequestScoped 作用域的依赖有效。

Source

pub fn header(&self, name: &str) -> Option<&str>

获取请求头

Source

pub fn parts(&self) -> &Parts

获取请求 Parts 的引用

Source

pub fn use_type<T: Clone + Send + Sync + 'static>(&self) -> WaeResult<T>

按类型获取依赖(便捷方法)

Source

pub fn use_config<T: Clone + Send + Sync + 'static>(&self) -> WaeResult<T>

获取配置(按类型)

Source

pub fn use_auth<T: Clone + Send + Sync + 'static>(&self) -> WaeResult<T>

获取认证服务(按类型)

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