Skip to main content

ServiceProviderWrapper

Struct ServiceProviderWrapper 

Source
pub struct ServiceProviderWrapper { /* private fields */ }

Implementations§

Source§

impl ServiceProviderWrapper

Source

pub fn new(child: Arc<ServiceProvider>, root: Arc<ServiceProvider>) -> Arc<Self>

Source

pub fn child(&self) -> &Arc<ServiceProvider>

Source

pub fn root(&self) -> &Arc<ServiceProvider>

Source

pub fn get<T: ?Sized + Send + Sync + 'static>(&self) -> Result<Arc<T>, RdiError>

Source

pub fn get_optional<T: ?Sized + Send + Sync + 'static>(&self) -> Option<Arc<T>>

Source

pub fn get_keyed<T: ?Sized + Send + Sync + 'static>( &self, key: &str, ) -> Result<Arc<T>, RdiError>

Source

pub fn get_all<T: ?Sized + Send + Sync + 'static>(&self) -> Vec<Arc<T>>

Source

pub fn get_named<T: Send + Sync + 'static>(&self, name: &str) -> Option<Arc<T>>

Source

pub fn get_named_any(&self, name: &str) -> Option<Arc<dyn Any + Send + Sync>>

Source

pub fn get_owned<T: Send + Sync + 'static>(&self) -> Result<T, RdiError>

Resolve owned T (bypass cache, fresh each call). Child-first, root-fallback. Returns Err if not registered or the service is Singleton.

Source

pub fn try_get_owned<T: Send + Sync + 'static>(&self) -> Option<T>

Resolve owned T, returning None if not registered or Singleton.

Source

pub fn get_keyed_owned<T: Send + Sync + 'static>( &self, key: &str, ) -> Result<T, RdiError>

Resolve owned keyed T. Child-first, root-fallback.

Source

pub fn try_get_keyed_owned<T: Send + Sync + 'static>( &self, key: &str, ) -> Option<T>

Resolve owned keyed T, returning None if not found or Singleton.

Source

pub async fn get_async<T: ?Sized + Send + Sync + 'static>( &self, ) -> Result<Arc<T>, RdiError>

Resolve an async service by type. Child-first, root-fallback.

Source

pub async fn get_keyed_async<T: ?Sized + Send + Sync + 'static>( &self, key: &str, ) -> Result<Arc<T>, RdiError>

Resolve an async keyed service. Child-first, root-fallback.

Source§

impl ServiceProviderWrapper

Source

pub fn rdi_register_named( &self, name: &str, service: Arc<dyn Any + Send + Sync>, )

Register a named service (for IProvider trait).

Source

pub fn rdi_remove_named(&self, name: &str)

Remove a named service (for IProvider trait).

Trait Implementations§

Source§

impl IProvider for ServiceProviderWrapper

Source§

fn get_named_any(&self, name: &str) -> Option<Arc<dyn Any + Send + Sync>>

Source§

fn rdi_register_named(&self, name: &str, service: Arc<dyn Any + Send + Sync>)

Source§

fn rdi_remove_named(&self, name: &str)

Source§

impl IServiceResolver for ServiceProviderWrapper

Source§

fn get_any(&self, key: &str) -> Option<Arc<dyn Any + Send + Sync>>

Source§

fn get_keyed_any( &self, key: &str, variant: &str, ) -> Option<Arc<dyn Any + Send + Sync>>

Source§

fn get_by_type_id(&self, tid: TypeId) -> Option<Arc<dyn Any + Send + Sync>>

TypeId 直查(默认 NoneServiceProvider 等覆盖为 O(1) 直查)。 Read more
Source§

fn get_keyed_by_type_id( &self, tid: TypeId, key: &str, ) -> Option<Arc<dyn Any + Send + Sync>>

TypeId 直查 keyed 版本(默认 None)。
Source§

fn get_all_any(&self, key: &str) -> Vec<Arc<dyn Any + Send + Sync>>

Type-erased polymorphic resolution: return all registered instances (default + keyed) of the given type. Read more
Source§

fn get_owned_any(&self, key: &str) -> Option<Arc<dyn Any + Send + Sync>>

Type-erased owned resolution: bypass cache, call factory fresh, return Arc<dyn Any + Send + Sync> (concrete Arc<Arc<T>>). Read more
Source§

fn get_keyed_owned_any( &self, key: &str, variant: &str, ) -> Option<Arc<dyn Any + Send + Sync>>

Source§

fn provider_arc(&self) -> Option<Arc<ServiceProvider>>

Return an Arc<ServiceProvider> for on-demand service resolution. Read more
Source§

fn get<T: ?Sized + Sync + Send + 'static>(&self) -> Result<Arc<T>, RdiError>
where Self: Sized,

Resolve a service by type (concrete or dyn Trait). Returns Err(RdiError::ServiceNotFound) if not registered. Read more
Source§

fn try_get<T: ?Sized + Sync + Send + 'static>(&self) -> Option<Arc<T>>
where Self: Sized,

Resolve a service by type, returning None if not registered.
Source§

fn get_keyed<T: ?Sized + Sync + Send + 'static>( &self, variant: &str, ) -> Result<Arc<T>, RdiError>
where Self: Sized,

Resolve a keyed service by type and key. Returns Err if not found.
Source§

fn try_get_keyed<T: ?Sized + Sync + Send + 'static>( &self, variant: &str, ) -> Option<Arc<T>>
where Self: Sized,

Resolve a keyed service by type and key, returning None if not found.
Source§

fn get_all<T: ?Sized + Sync + Send + 'static>(&self) -> Vec<Arc<T>>
where Self: Sized,

Resolve all registered instances of T (default + keyed). Read more
Source§

fn get_owned<T: Send + Sync + 'static>(&self) -> Result<T, RdiError>
where Self: Sized,

Resolve owned T (bypass cache, fresh each call). Returns Err if not registered or the service is Singleton.
Source§

fn try_get_owned<T: Send + Sync + 'static>(&self) -> Option<T>
where Self: Sized,

Resolve owned T, returning None if not registered or Singleton.
Source§

fn get_keyed_owned<T: Send + Sync + 'static>( &self, variant: &str, ) -> Result<T, RdiError>
where Self: Sized,

Resolve owned keyed T. Returns Err if not found or Singleton.
Source§

fn try_get_keyed_owned<T: Send + Sync + 'static>( &self, variant: &str, ) -> Option<T>
where Self: Sized,

Resolve owned keyed T, returning None if not found or Singleton.

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.