darling_core::options

Trait ParseData

source
pub trait ParseData: Sized {
    // Provided methods
    fn parse_body(self, body: &Data) -> Result<Self> { ... }
    fn parse_variant(&mut self, variant: &Variant) -> Result<()> { ... }
    fn parse_field(&mut self, field: &Field) -> Result<()> { ... }
    fn validate_body(&self, errors: &mut Accumulator) { ... }
}
Expand description

Middleware for extracting values from the body of the derive input. Implementers are expected to override parse_field or parse_variant as appropriate for their use-case, while parse_body dispatches to the appropriate methods and handles error collection.

Provided Methods§

source

fn parse_body(self, body: &Data) -> Result<Self>

source

fn parse_variant(&mut self, variant: &Variant) -> Result<()>

Apply the next found variant to the object, returning an error if parsing goes wrong.

source

fn parse_field(&mut self, field: &Field) -> Result<()>

Apply the next found struct field to the object, returning an error if parsing goes wrong.

source

fn validate_body(&self, errors: &mut Accumulator)

Perform validation checks that require data from more than one field or variant. The default implementation does no validations. Implementors can override this method as appropriate for their use-case.

Object Safety§

This trait is not object safe.

Implementors§