Trait under::FromFormValue
source · pub trait FromFormValue<'f>: Sized {
type Error;
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§
sourcetype Error
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§
sourcefn from_form_value(value: &'f str) -> Result<Self, Self::Error>
fn from_form_value(value: &'f str) -> Result<Self, Self::Error>
Converts the given value into a Self.
Implementations on Foreign Types§
source§impl<'f> FromFormValue<'f> for String
impl<'f> FromFormValue<'f> for String
§type Error = Infallible
type Error = Infallible
Available on crate feature
from_form only.source§impl<'f> FromFormValue<'f> for &'f str
impl<'f> FromFormValue<'f> for &'f str
§type Error = Infallible
type Error = Infallible
Available on crate feature
from_form only.source§impl<'f, T> FromFormValue<'f> for Option<T>where
T: FromFormValue<'f>,
impl<'f, T> FromFormValue<'f> for Option<T>where
T: FromFormValue<'f>,
§type Error = Infallible
type Error = Infallible
Available on crate feature
from_form only.source§impl<'f, T> FromFormValue<'f> for Result<T, T::Error>where
T: FromFormValue<'f>,
impl<'f, T> FromFormValue<'f> for Result<T, T::Error>where
T: FromFormValue<'f>,
§type Error = Infallible
type Error = Infallible
Available on crate feature
from_form only.source§impl<'f> FromFormValue<'f> for bool
impl<'f> FromFormValue<'f> for bool
§type Error = Infallible
type Error = Infallible
Available on crate feature
from_form only.