pub trait Datatype:
Clone
+ Display
+ FromStr<Err = Self::Error>
+ Into<Self::Inner>
+ 'static {
type Inner: Datatype;
type Error: From<<Self::Inner as Datatype>::Error> + Error + Clone + 'static;
// Required methods
fn validate(input: Self::Inner) -> Result<Self, Self::Error>
where Self: Sized;
fn attributes() -> Vec<(&'static str, Attribute)>;
fn default_debug_value() -> Self
where Self: Sized;
}Expand description
A trait for defining custom datatypes. Implemented on all types that can be used as a form input.
Required Associated Types§
type Inner: Datatype
type Error: From<<Self::Inner as Datatype>::Error> + Error + Clone + 'static
Required Methods§
Sourcefn validate(input: Self::Inner) -> Result<Self, Self::Error>where
Self: Sized,
fn validate(input: Self::Inner) -> Result<Self, Self::Error>where
Self: Sized,
Validate the input and return the datatype.
Sourcefn attributes() -> Vec<(&'static str, Attribute)>
fn attributes() -> Vec<(&'static str, Attribute)>
Return the HTML attributes for the datatype that should be added to an input field.
Sourcefn default_debug_value() -> Selfwhere
Self: Sized,
fn default_debug_value() -> Selfwhere
Self: Sized,
Debug value to autofill the form.
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.