pub trait TypedRouter: Sized {
type State: Clone + Send + Sync + 'static;
// Required method
fn typed_route(
self,
handler: fn() -> (&'static str, MethodRouter<Self::State>),
) -> Self;
}
Expand description
A trait that allows typed routes, created with the route
macro to
be added to an axum router.
Typed handlers are of the form fn() -> (&'static str, MethodRouter<S>)
, where
S
is the state type. The first element of the tuple is the path, and the second
is the method router.
Required Associated Types§
Required Methods§
Sourcefn typed_route(
self,
handler: fn() -> (&'static str, MethodRouter<Self::State>),
) -> Self
fn typed_route( self, handler: fn() -> (&'static str, MethodRouter<Self::State>), ) -> Self
Add a typed route to the router, usually created with the route
macro.
Typed handlers are of the form fn() -> (&'static str, MethodRouter<S>)
, where
S
is the state type. The first element of the tuple is the path, and the second
is the method router.
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.