pub trait AddMiddlewareServiceExt {
// Required methods
fn add_middleware_service<T>(&mut self) -> &mut Self
where T: Middleware + Service<Handle = Arc<T>> + 'static;
fn has_middleware_service<T>(&self) -> bool
where T: Middleware + Service<Handle = Arc<T>> + 'static;
}Expand description
Registers middleware resolved from the dependency-injection container.
The middleware type T is a Service; it is built by the container (with
its dependencies) and its handle - an Arc<T> - becomes the component the
router macros resolve. The service is added if it is not already present.
Required Methods§
Sourcefn add_middleware_service<T>(&mut self) -> &mut Self
fn add_middleware_service<T>(&mut self) -> &mut Self
Registers the Service T so it is available as middleware.
§Panics
Building the App panics if T is registered both as a
service and as an instance via AddMiddlewareExt::add_middleware.
Sourcefn has_middleware_service<T>(&self) -> bool
fn has_middleware_service<T>(&self) -> bool
Returns whether T is registered as a service (and therefore available
as middleware).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".