Trait TryFromMeta

Source
pub trait TryFromMeta<V>: Sized
where V: SynVersion,
{ 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> TryFromMeta<V> for bool
where V: SynVersion,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§