Trait TypedRouter

Source
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§

Source

type State: Clone + Send + Sync + 'static

The state type of the router.

Required Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl<S> TypedRouter for Router<S>
where S: Send + Sync + Clone + 'static,

Source§

type State = S

Source§

fn typed_route( self, handler: fn() -> (&'static str, MethodRouter<<Router<S> as TypedRouter>::State>), ) -> Router<S>

Implementors§