pub trait TryFromMeta<V: SynVersion>: Sized {
    type InitialType: Concat;
    type Metadata;

    // Required methods
    fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>;
    fn validate(
        state: ArgResult<Self::InitialType>,
        arg_name: &'static str
    ) -> Result<Self, Vec<Error>>;
}
Expand description

A trait for deserializing Syn metadata.
Its recommended that you use the CustomArgFromMeta trait for deserializing simple arguments.

Required Associated Types§

source

type InitialType: Concat

This is the initial type and will be converted to Self in the validate function.
For most types this is typically Self but for lists this is a builder.

source

type Metadata

The metadata of an argument or an attribute.

Required Methods§

source

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

Looks for values & errors in the metadata.
The returned result is added to the argument’s state using the concat method on ArgResult which in turn will call the initial type’s Concat implementation if found.

source

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

Converts the initial type to Self or returns found errors.
If the argument is required it should return a missing error.
Wrapper types such as Option can overwrite this.

Implementations on Foreign Types§

source§

impl<V: SynVersion> TryFromMeta<V> for u64

§

type InitialType = u64

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for u128

§

type InitialType = u128

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for i128

§

type InitialType = i128

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for f32

§

type InitialType = f32

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for i16

§

type InitialType = i16

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion, T: TryFromMeta<V>> TryFromMeta<V> for Option<T>

§

type InitialType = <T as TryFromMeta<V>>::InitialType

§

type Metadata = <T as TryFromMeta<V>>::Metadata

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for String

§

type InitialType = String

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for i32

§

type InitialType = i32

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for i64

§

type InitialType = i64

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion, T: TryFromMeta<V, Metadata = V::ArgMeta>> TryFromMeta<V> for Vec<T>

§

type InitialType = Vec<ArgResult<<T as TryFromMeta<V>>::InitialType>, Global>

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for u8

§

type InitialType = u8

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for f64

§

type InitialType = f64

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for i8

§

type InitialType = i8

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for u16

§

type InitialType = u16

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for bool

§

type InitialType = bool

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, _arg_name: &'static str ) -> Result<Self, Vec<Error>>

source§

impl<V: SynVersion> TryFromMeta<V> for u32

§

type InitialType = u32

§

type Metadata = <V as SynVersion>::ArgMeta

source§

fn try_from_meta(meta: Self::Metadata) -> ArgResult<Self::InitialType>

source§

fn validate( state: ArgResult<Self::InitialType>, arg_name: &'static str ) -> Result<Self, Vec<Error>>

Implementors§