pub struct ProviderRegistry { /* private fields */ }Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
pub fn new() -> Self
pub fn register<T>(&mut self)
Sourcepub fn register_use_value<T: Send + Sync + 'static>(&mut self, value: Arc<T>)
pub fn register_use_value<T: Send + Sync + 'static>(&mut self, value: Arc<T>)
NestJS useValue: register a pre-built singleton without an Injectable impl.
Sourcepub fn register_use_factory<T, F>(&mut self, scope: ProviderScope, factory: F)
pub fn register_use_factory<T, F>(&mut self, scope: ProviderScope, factory: F)
NestJS useFactory: register a provider from a synchronous closure Fn(&ProviderRegistry) -> Arc<T>.
The closure may call Self::get for dependencies. For async initialization of T, keep
construct/factory cheap and use Injectable::on_module_init on T, or load module
options with ConfigurableModuleBuilder::for_root_async. Do not block the async
runtime inside the factory.
Prefer Self::register when the provider is a normal #[injectable] type.
Sourcepub fn register_use_class<T>(&mut self)
pub fn register_use_class<T>(&mut self)
NestJS useClass: equivalent to Self::register for a normal injectable type.
Sourcepub fn override_provider<T>(&mut self, instance: Arc<T>)
pub fn override_provider<T>(&mut self, instance: Arc<T>)
Override a provider with a concrete singleton instance (testing utility).
This is primarily intended for TestingModule-style overrides where you want to replace an
injectable with a mock instance.
pub fn get<T>(&self) -> Arc<T>
Sourcepub fn registered_type_ids(&self) -> Vec<TypeId>
pub fn registered_type_ids(&self) -> Vec<TypeId>
All registered provider TypeId keys (NestJS discovery-style introspection).
Sourcepub fn registered_type_names(&self) -> Vec<&'static str>
pub fn registered_type_names(&self) -> Vec<&'static str>
Human-readable type names for registered providers (debug / tooling).
pub fn absorb(&mut self, other: ProviderRegistry)
pub fn absorb_exported(&mut self, other: ProviderRegistry, exported: &[TypeId])
Sourcepub fn absorb_exported_from(
&mut self,
other: &ProviderRegistry,
exported: &[TypeId],
)
pub fn absorb_exported_from( &mut self, other: &ProviderRegistry, exported: &[TypeId], )
Like Self::absorb_exported, but clones bindings from other so the source registry is kept intact
(used for lazy modules and shared provider cells).
Sourcepub fn eager_init_singletons(&self)
pub fn eager_init_singletons(&self)
Construct all singleton providers (so their lifecycle hooks can run deterministically).