Skip to main content

FromPath

Trait FromPath 

Source
pub trait FromPath: Sized {
    const ARITY: usize;
    const NAMES: &'static [&'static str] = _;

    // Required method
    fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>;
}
Expand description

A type Path can build from route parameters.

Implemented for the standard scalars (one parameter), tuples of up to six FromStr values (one parameter each, in order), and structs with #[derive(FromPath)] (one parameter per field, by name). A type of your own with FromStr works as a one-tuple: Path((slug,)): Path<(Slug,)>.

Required Associated Constants§

Source

const ARITY: usize

How many parameters this type takes.

Provided Associated Constants§

Source

const NAMES: &'static [&'static str] = _

The parameters by name (a struct’s fields), or empty when they are taken in order. The route macros check these against the pattern.

Required Methods§

Source

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Build the value. names are the route parameters to take, in order (ARITY of them); an error is the rejection’s detail.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromPath for IpAddr

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for Ipv4Addr

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for Ipv6Addr

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for String

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for bool

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for char

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for f32

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for f64

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for i8

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for i16

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for i32

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for i64

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for i128

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for isize

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for u8

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for u16

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for u32

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for u64

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for u128

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl FromPath for usize

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl<A, B, C, D, E, F> FromPath for (A, B, C, D, E, F)
where A: FromStr, A::Err: Display, B: FromStr, B::Err: Display, C: FromStr, C::Err: Display, D: FromStr, D::Err: Display, E: FromStr, E::Err: Display, F: FromStr, F::Err: Display,

Source§

const ARITY: usize = 6

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl<A, B, C, D, E> FromPath for (A, B, C, D, E)
where A: FromStr, A::Err: Display, B: FromStr, B::Err: Display, C: FromStr, C::Err: Display, D: FromStr, D::Err: Display, E: FromStr, E::Err: Display,

Source§

const ARITY: usize = 5

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl<A, B, C, D> FromPath for (A, B, C, D)
where A: FromStr, A::Err: Display, B: FromStr, B::Err: Display, C: FromStr, C::Err: Display, D: FromStr, D::Err: Display,

Source§

const ARITY: usize = 4

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl<A, B, C> FromPath for (A, B, C)
where A: FromStr, A::Err: Display, B: FromStr, B::Err: Display, C: FromStr, C::Err: Display,

Source§

const ARITY: usize = 3

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl<A, B> FromPath for (A, B)
where A: FromStr, A::Err: Display, B: FromStr, B::Err: Display,

Source§

const ARITY: usize = 2

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Source§

impl<A> FromPath for (A,)
where A: FromStr, A::Err: Display,

Source§

const ARITY: usize = 1

Source§

fn from_path(params: &PathParams, names: &[&str]) -> Result<Self, String>

Implementors§