pub struct ServiceRegistry { /* private fields */ }
Expand description
Registry for managing service instances and factories
Implementations§
Source§impl ServiceRegistry
impl ServiceRegistry
Sourcepub fn register_service<T>(&mut self, service: T) -> Result<(), CoreError>
pub fn register_service<T>(&mut self, service: T) -> Result<(), CoreError>
Register a service instance
Sourcepub fn register_singleton<T>(&mut self, service: T) -> Result<(), CoreError>
pub fn register_singleton<T>(&mut self, service: T) -> Result<(), CoreError>
Register a singleton service
Sourcepub fn register_transient<T>(
&mut self,
factory: Box<dyn Fn() -> T + Send + Sync>,
) -> Result<(), CoreError>where
T: Service + 'static,
pub fn register_transient<T>(
&mut self,
factory: Box<dyn Fn() -> T + Send + Sync>,
) -> Result<(), CoreError>where
T: Service + 'static,
Register a transient service factory
Sourcepub fn try_resolve<T>(&self) -> Option<Arc<T>>
pub fn try_resolve<T>(&self) -> Option<Arc<T>>
Try to resolve a service instance
Sourcepub fn contains<T>(&self) -> boolwhere
T: Service + 'static,
pub fn contains<T>(&self) -> boolwhere
T: Service + 'static,
Check if a service type is registered
Sourcepub fn service_count(&self) -> usize
pub fn service_count(&self) -> usize
Get the number of registered services
Sourcepub fn registered_services(&self) -> Vec<TypeId>
pub fn registered_services(&self) -> Vec<TypeId>
Get all registered service type IDs
Sourcepub async fn initialize_all(&self) -> Result<(), CoreError>
pub async fn initialize_all(&self) -> Result<(), CoreError>
Initialize all services that implement Initializable
Trait Implementations§
Source§impl Debug for ServiceRegistry
impl Debug for ServiceRegistry
Auto Trait Implementations§
impl Freeze for ServiceRegistry
impl RefUnwindSafe for ServiceRegistry
impl Send for ServiceRegistry
impl Sync for ServiceRegistry
impl Unpin for ServiceRegistry
impl UnwindSafe for ServiceRegistry
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