pub trait Controller: Sized + 'static {
type State: Send + Sync + 'static;
// Required method
fn mount(
state: Arc<Self::State>,
) -> impl FnOnce(Router<()>) -> Result<Router<()>>;
}Expand description
A pure descriptor for a group of HTTP routes sharing a common service dependency.
Do not implement this trait manually. Use the [mount_handlers!] macro,
which generates the correct Kleisli arrow from your handler list.
The trait’s only concern is: given Arc<State>, produce a Kleisli arrow
that registers this controller’s routes into a Router<()>.
Required Associated Types§
Required Methods§
Sourcefn mount(
state: Arc<Self::State>,
) -> impl FnOnce(Router<()>) -> Result<Router<()>>
fn mount( state: Arc<Self::State>, ) -> impl FnOnce(Router<()>) -> Result<Router<()>>
Returns the Kleisli arrow for this controller.
Signature: Arc<State> -> (Router<()> -> Result<Router<()>>)
Generated by mount_handlers!. The returned closure:
- Builds a scoped
Router<Arc<State>>with this controller’s routes. - Provides state via
.with_state(state)→Router<()>. - Merges into the outer
routerand returnsOk(merged).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".