pub struct Dependencies { /* private fields */ }Expand description
依赖容器
存储所有注册的服务实例。
Implementations§
Source§impl Dependencies
impl Dependencies
Sourcepub fn register<T: Send + Sync + 'static>(&mut self, name: &str, service: T)
pub fn register<T: Send + Sync + 'static>(&mut self, name: &str, service: T)
注册服务(按字符串键,默认单例作用域)
Sourcepub fn register_with_scope<T: Send + Sync + 'static>(
&mut self,
name: &str,
service: T,
scope: Scope,
)
pub fn register_with_scope<T: Send + Sync + 'static>( &mut self, name: &str, service: T, scope: Scope, )
按作用域注册服务(按字符串键)
Sourcepub fn register_type<T: Clone + Send + Sync + 'static>(&mut self, service: T)
pub fn register_type<T: Clone + Send + Sync + 'static>(&mut self, service: T)
按类型注册服务(默认单例作用域)
Sourcepub fn register_type_with_scope<T: Clone + Send + Sync + 'static>(
&mut self,
service: T,
scope: Scope,
)
pub fn register_type_with_scope<T: Clone + Send + Sync + 'static>( &mut self, service: T, scope: Scope, )
按作用域注册服务(按类型)
Sourcepub fn get_type_scope<T: 'static>(&self) -> Option<Scope>
pub fn get_type_scope<T: 'static>(&self) -> Option<Scope>
检查服务的作用域(按类型)
Trait Implementations§
Source§impl Default for Dependencies
impl Default for Dependencies
Source§fn default() -> Dependencies
fn default() -> Dependencies
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Dependencies
impl !RefUnwindSafe for Dependencies
impl Send for Dependencies
impl Sync for Dependencies
impl Unpin for Dependencies
impl UnsafeUnpin for Dependencies
impl !UnwindSafe for Dependencies
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