pub struct ServiceRegistry { /* private fields */ }Expand description
Registry for managing service instances and factories
Implementations§
Source§impl ServiceRegistry
impl ServiceRegistry
Sourcepub fn new() -> ServiceRegistry
pub fn new() -> ServiceRegistry
Create a new service registry
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 + Sync + Send>,
) -> Result<(), CoreError>where
T: Service + 'static,
pub fn register_transient<T>(
&mut self,
factory: Box<dyn Fn() -> T + Sync + Send>,
) -> 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
Source§impl Default for ServiceRegistry
impl Default for ServiceRegistry
Source§fn default() -> ServiceRegistry
fn default() -> ServiceRegistry
Returns the “default value” for a type. Read more
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more