pub trait EasyArgumentField {
    // Required methods
    fn try_parse(
        lookahead1: &Lookahead1<'_>,
        stream: ParseStream<'_>
    ) -> Result<Option<Self>>
       where Self: Sized;
    fn try_extend(
        &mut self,
        lookahead1: &Lookahead1<'_>,
        stream: ParseStream<'_>
    ) -> Result<bool>;
    fn missing() -> Result<Self, String>
       where Self: Sized;
}
Expand description

Trait for types that can be used as fields in easy attributes structures. Fields can parsed and extended when encountered again in parsing stream. If field is never encountered - EasyArgumentField::missing value will be used. If attribute type or group is not mandatory - wrap it into Option.

Required Methods§

source

fn try_parse( lookahead1: &Lookahead1<'_>, stream: ParseStream<'_> ) -> Result<Option<Self>>where Self: Sized,

Attempt to parse attribute field. Returns some field when parsing succeeds. Returns none if attribute peeking returns false, signalling that stream contains some other attribute. Returns error if peeking returns true but parsing fails.

source

fn try_extend( &mut self, lookahead1: &Lookahead1<'_>, stream: ParseStream<'_> ) -> Result<bool>

Attempt to parse attribute field when it already has been successfully parsed. Field value should extend itself with newly parsed attribute or return error. Returns true when parsing and extending succeeds. Returns false if attribute peeking returns false, signalling that stream contains some other attribute. Returns error if peeking returns true but parsing or extending fails.

source

fn missing() -> Result<Self, String>where Self: Sized,

Called if the attribute field was never parsed. Returns error if attribute is mandatory. Otherwise returns an instance that will be used to build attributes structure.

Implementations on Foreign Types§

source§

impl<T> EasyArgumentField for Vec<T>where T: EasyArgumentGroup,

source§

fn try_parse( lookahead1: &Lookahead1<'_>, stream: ParseStream<'_> ) -> Result<Option<Self>>

source§

fn try_extend( &mut self, lookahead1: &Lookahead1<'_>, stream: ParseStream<'_> ) -> Result<bool>

source§

fn missing() -> Result<Self, String>

source§

impl<T> EasyArgumentField for Option<T>where T: EasyArgumentField,

source§

fn try_parse( lookahead1: &Lookahead1<'_>, stream: ParseStream<'_> ) -> Result<Option<Option<T>>>

source§

fn try_extend( &mut self, lookahead1: &Lookahead1<'_>, stream: ParseStream<'_> ) -> Result<bool>

source§

fn missing() -> Result<Self, String>

Implementors§