pub trait FromFormValue<'f>: Sized {
type Error;
// Required method
fn from_form_value(value: &'f str) -> Result<Self, Self::Error>;
}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.
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.