Param

Trait Param 

Source
pub trait Param<T>: Sized {
    // Required method
    fn from_request(req: &T) -> Result<Self, Error>;
}
Expand description

A param describes a route’s dependency (route’s second argument).

T is the request type. With hyper, it will be http::Request

When using #[derive(Param)], T must implements both PathReq and MethodReq.

Required Methods§

Source

fn from_request(req: &T) -> Result<Self, Error>

Construct param from request.

Error::Path should be returned when request’s path does not match.

Error::Method should be returned when request’s method does not match.

Error::Prefix should not be returned. It’s used specifically by mount

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.

Implementors§