Trait foxbox_taxonomy::parse::Parser [] [src]

pub trait Parser<T: Sized> {
    fn description() -> String;
    fn parse(path: Path, source: &mut JSON) -> Result<T, ParseError>;

    fn from_str(source: &str) -> Result<T, ParseError> { ... }
    fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError> { ... }
    fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>> { ... }
    fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>> { ... }
    fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError> { ... }
}

An object that knows how to parse values from JSON into type T.

The JSON object is expected to be consumed along the way. A successful parse will typically leave an empty JSON object.

Required Methods

fn description() -> String

fn parse(path: Path, source: &mut JSON) -> Result<T, ParseError>

Parse a single value from JSON, consuming as much as necessary from JSON.

Provided Methods

fn from_str(source: &str) -> Result<T, ParseError>

fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError>

Parse a field from JSON, consuming it.

fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>>

Parse a field from JSON, consuming it.

fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>>

Parse a field containing an array from JSON, consuming the field.

fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError>

Implementors