pub struct Effectful { /* private fields */ }Expand description
代数效应请求上下文
包含依赖容器和请求信息,用于在请求处理过程中获取依赖。
Implementations§
Source§impl Effectful
impl Effectful
Sourcepub fn new(deps: Arc<Dependencies>, parts: Parts) -> Self
pub fn new(deps: Arc<Dependencies>, parts: Parts) -> Self
创建新的 Effectful
Sourcepub fn get<T: Clone + Send + Sync + 'static>(&self, name: &str) -> WaeResult<T>
pub fn get<T: Clone + Send + Sync + 'static>(&self, name: &str) -> WaeResult<T>
获取依赖(按字符串键)
如果依赖是 RequestScoped 作用域,将从当前请求的独立存储中获取或初始化。
Sourcepub fn set<T: Send + Sync + 'static>(
&mut self,
name: &str,
service: T,
) -> WaeResult<()>
pub fn set<T: Send + Sync + 'static>( &mut self, name: &str, service: T, ) -> WaeResult<()>
设置请求作用域的依赖(按字符串键)
仅对 RequestScoped 作用域的依赖有效。
Sourcepub fn get_type<T: Clone + Send + Sync + 'static>(&self) -> WaeResult<T>
pub fn get_type<T: Clone + Send + Sync + 'static>(&self) -> WaeResult<T>
按类型获取依赖
如果依赖是 RequestScoped 作用域,将从当前请求的独立存储中获取或初始化。
Auto Trait Implementations§
impl !Freeze for Effectful
impl !RefUnwindSafe for Effectful
impl Send for Effectful
impl Sync for Effectful
impl Unpin for Effectful
impl UnsafeUnpin for Effectful
impl !UnwindSafe for Effectful
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more