Trait TryFromMeta

Source
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.

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<V: SynVersion> TryFromMeta<V> for bool

Source§

type InitialType = bool

Source§

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

Source§

type InitialType = f32

Source§

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

Source§

type InitialType = f64

Source§

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

Source§

type InitialType = i8

Source§

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

Source§

type InitialType = i16

Source§

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 i32

Source§

type InitialType = i32

Source§

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

Source§

type InitialType = i64

Source§

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

Source§

type InitialType = i128

Source§

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

Source§

type InitialType = u8

Source§

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

Source§

type InitialType = u16

Source§

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

Source§

type InitialType = u32

Source§

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 u64

Source§

type InitialType = u64

Source§

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

Source§

type InitialType = u128

Source§

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 String

Source§

type InitialType = String

Source§

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, T: TryFromMeta<V>> TryFromMeta<V> for Option<T>

Source§

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

Source§

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, T: TryFromMeta<V, Metadata = V::ArgMeta>> TryFromMeta<V> for Vec<T>

Source§

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

Source§

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§