Trait Datatype

Source
pub trait Datatype:
    Clone
    + Display
    + Debug
    + Default
    + FromStr<Err = Self::Error>
    + Into<Self::Inner>
    + PartialEq
    + 'static {
    type Inner: Datatype;
    type Error: From<<Self::Inner as Datatype>::Error> + Error + Clone + PartialEq + 'static;

    // Required methods
    fn validate(input: Self::Inner) -> Result<Self, Self::Error>
       where Self: Sized;
    fn attributes() -> Vec<(&'static str, Attribute)>;
}
Expand description

A trait for defining custom datatypes. Implemented on all types that can be used as a form input.

Required Associated Types§

Source

type Inner: Datatype

Source

type Error: From<<Self::Inner as Datatype>::Error> + Error + Clone + PartialEq + 'static

Required Methods§

Source

fn validate(input: Self::Inner) -> Result<Self, Self::Error>
where Self: Sized,

Validate the input and return the datatype.

Source

fn attributes() -> Vec<(&'static str, Attribute)>

Return the HTML attributes for the datatype that should be added to an input field.

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 Datatype for bool

Source§

type Inner = bool

Source§

type Error = <bool as FromStr>::Err

Source§

fn validate(input: bool) -> Result<Self, <bool as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for i8

Source§

type Inner = i8

Source§

type Error = <i8 as FromStr>::Err

Source§

fn validate(input: i8) -> Result<Self, <i8 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for i16

Source§

type Inner = i16

Source§

type Error = <i16 as FromStr>::Err

Source§

fn validate(input: i16) -> Result<Self, <i16 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for i32

Source§

type Inner = i32

Source§

type Error = <i32 as FromStr>::Err

Source§

fn validate(input: i32) -> Result<Self, <i32 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for i64

Source§

type Inner = i64

Source§

type Error = <i64 as FromStr>::Err

Source§

fn validate(input: i64) -> Result<Self, <i64 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for i128

Source§

type Inner = i128

Source§

type Error = <i128 as FromStr>::Err

Source§

fn validate(input: i128) -> Result<Self, <i128 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for u8

Source§

type Inner = u8

Source§

type Error = <u8 as FromStr>::Err

Source§

fn validate(input: u8) -> Result<Self, <u8 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for u16

Source§

type Inner = u16

Source§

type Error = <u16 as FromStr>::Err

Source§

fn validate(input: u16) -> Result<Self, <u16 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for u32

Source§

type Inner = u32

Source§

type Error = <u32 as FromStr>::Err

Source§

fn validate(input: u32) -> Result<Self, <u32 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for u64

Source§

type Inner = u64

Source§

type Error = <u64 as FromStr>::Err

Source§

fn validate(input: u64) -> Result<Self, <u64 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for u128

Source§

type Inner = u128

Source§

type Error = <u128 as FromStr>::Err

Source§

fn validate(input: u128) -> Result<Self, <u128 as FromStr>::Err>

Source§

fn attributes() -> Vec<(&'static str, Attribute)>

Source§

impl Datatype for String

Source§

impl Datatype for BigInt

Source§

impl Datatype for BigRational

Implementors§

Source§

impl Datatype for Accept

Source§

impl Datatype for Date

Source§

impl Datatype for DateTime

Source§

impl Datatype for NonEmptyString

Source§

impl Datatype for Optional<i8>

Source§

impl Datatype for Optional<i16>

Source§

impl Datatype for Optional<i32>

Source§

impl Datatype for Optional<i64>

Source§

impl Datatype for Optional<i128>

Source§

impl Datatype for Optional<u8>

Source§

impl Datatype for Optional<u16>

Source§

impl Datatype for Optional<u32>

Source§

impl Datatype for Optional<u64>

Source§

impl Datatype for Optional<u128>

Source§

impl Datatype for Optional<BigInt>

Source§

impl Datatype for Optional<Date>

Source§

impl Datatype for Optional<DateTime>

Source§

impl Datatype for Optional<Time>

Source§

impl Datatype for Optional<BigRational>

Source§

impl Datatype for Time

Source§

impl<R: RegionalRule> Datatype for RegionalField<R>

Source§

impl<R: Rule> Datatype for Field<R>