FromFormValue

Trait FromFormValue 

Source
pub trait FromFormValue<'f>: Sized {
    type Error;

    // Required method
    fn from_form_value(value: &'f str) -> Result<Self, Self::Error>;
}
Available on crate feature from_form only.
Expand description

A trait for types that can be created from a form.

This is for parsing from a HTML form, not a URL query string. Specifically, this parses from the body of a application/x-www-form-urlencoded request. This takes in the form value specified in the key-value pair provided to FromForm, and returns a Result<Self, Self::Error>. This is similar to FromStr, but allows for different parsings. For example, bool parses from 1, true, on, and yes (with other values defaulting to false).

Required Associated Types§

Source

type Error

The error type that can be returned if parsing fails. This is normally encapsulated into a anyhow::Error before being turned into a variant of the FromFormError.

Required Methods§

Source

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Converts the given value into a Self.

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<'f> FromFormValue<'f> for &'f str

Source§

type Error = Infallible

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for IpAddr

Source§

type Error = <IpAddr as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for SocketAddr

Source§

type Error = <SocketAddr as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for bool

Source§

type Error = Infallible

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for f32

Source§

type Error = <f32 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for f64

Source§

type Error = <f64 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for i8

Source§

type Error = <i8 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for i16

Source§

type Error = <i16 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for i32

Source§

type Error = <i32 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for i64

Source§

type Error = <i64 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for i128

Source§

type Error = <i128 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for isize

Source§

type Error = <isize as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for u8

Source§

type Error = <u8 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for u16

Source§

type Error = <u16 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for u32

Source§

type Error = <u32 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for u64

Source§

type Error = <u64 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for u128

Source§

type Error = <u128 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for usize

Source§

type Error = <usize as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for String

Source§

type Error = Infallible

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for Ipv4Addr

Source§

type Error = <Ipv4Addr as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for Ipv6Addr

Source§

type Error = <Ipv6Addr as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for SocketAddrV4

Source§

type Error = <SocketAddrV4 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for SocketAddrV6

Source§

type Error = <SocketAddrV6 as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroI8

Source§

type Error = <NonZero<i8> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroI16

Source§

type Error = <NonZero<i16> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroI32

Source§

type Error = <NonZero<i32> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroI64

Source§

type Error = <NonZero<i64> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroI128

Source§

type Error = <NonZero<i128> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroIsize

Source§

type Error = <NonZero<isize> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroU8

Source§

type Error = <NonZero<u8> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroU16

Source§

type Error = <NonZero<u16> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroU32

Source§

type Error = <NonZero<u32> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroU64

Source§

type Error = <NonZero<u64> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroU128

Source§

type Error = <NonZero<u128> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f> FromFormValue<'f> for NonZeroUsize

Source§

type Error = <NonZero<usize> as FromStr>::Err

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f, T> FromFormValue<'f> for Option<T>
where T: FromFormValue<'f>,

Source§

type Error = Infallible

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Source§

impl<'f, T> FromFormValue<'f> for Result<T, T::Error>
where T: FromFormValue<'f>,

Source§

type Error = Infallible

Source§

fn from_form_value(value: &'f str) -> Result<Self, Self::Error>

Implementors§