pub trait Injectable:
Send
+ Sync
+ 'static {
// Required method
fn construct(registry: &ProviderRegistry) -> Arc<Self>;
// Provided methods
fn scope() -> ProviderScope { ... }
fn on_module_init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_module_destroy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_application_bootstrap<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_application_shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Application service or provider type constructed through the DI container.
construct is synchronous. Perform async I/O in Self::on_module_init or after you have
an Arc<Self> from the registry. Lifecycle hooks run for singleton providers when the
framework drives ProviderRegistry::run_on_module_init and related methods (see NestFactory / listen).
Scopes: override Self::scope via #[injectable(scope = "...")].
Docs: mdBook Fundamentals (docs/src/fundamentals.md).
Required Methods§
fn construct(registry: &ProviderRegistry) -> Arc<Self>
Provided Methods§
Sourcefn scope() -> ProviderScope
fn scope() -> ProviderScope
Provider scope used when the module registers this type.
fn on_module_init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_module_destroy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_application_bootstrap<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_application_shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.