pub trait IServiceCollectionExt: Sized {
// Required methods
fn add_mediator(self) -> Self;
fn add_request_endpoints(self) -> Self;
fn add_controllers(self) -> Self;
fn add_middleware<T>(self) -> Self
where T: IMiddleware + Default + Send + Sync + 'static;
fn add_pipeline<T>(self) -> Self
where T: IPipelineBehavior + Default + Send + Sync + 'static;
fn add_hosted_service<T>(self) -> Self
where T: IHostedService + Default + Send + Sync + 'static;
}Expand description
Extension methods for rust_dix::ServiceCollection to enable
framework-level service registration patterns.
Required Methods§
Sourcefn add_mediator(self) -> Self
fn add_mediator(self) -> Self
Register the mediator in the DI container.
The actual IRequestHandler and IEventHandler implementations
are registered via #[rust_dix::module] blocks (re-exported as webx::module).
Sourcefn add_request_endpoints(self) -> Self
fn add_request_endpoints(self) -> Self
Signal that endpoints should be auto-discovered from #[get] / #[endpoint]
annotations at compile time. The actual route table is built during
Host::build() by scanning the inventory for RouteEntry items.
Sourcefn add_controllers(self) -> Self
fn add_controllers(self) -> Self
Register controller types scoped per request.
Sourcefn add_middleware<T>(self) -> Self
fn add_middleware<T>(self) -> Self
Register a middleware type in the DI container as a singleton.
Sourcefn add_pipeline<T>(self) -> Self
fn add_pipeline<T>(self) -> Self
Register a pipeline behavior in the DI container as a singleton.
Sourcefn add_hosted_service<T>(self) -> Self
fn add_hosted_service<T>(self) -> Self
Register a hosted service in the DI container as a singleton.
Hosted services are started when the host starts (before accepting requests) and stopped during graceful shutdown.
Analogous to ASP.NET Core’s AddHostedService<T>().
§Example
Host::builder()
.register(|svc| {
svc.add_hosted_service::<DbInitService>()
})
.build()
.run()
.awaitDyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".