Parser

Trait Parser 

Source
pub trait Parser:
    Send
    + Sync
    + Debug
    + Display {
    // Required methods
    fn supported_format_list(&self) -> Vec<String>;
    fn try_parse(&self, bytes: &[u8]) -> Result<Input>;
    fn is_format_supported(&self, bytes: &[u8]) -> Option<bool>;

    // Provided method
    fn parse(&self, bytes: &[u8]) -> Result<Input, Error> { ... }
}
Expand description

A trait to parse configuration contents.

Required Methods§

Source

fn supported_format_list(&self) -> Vec<String>

Supported format list (e.g. “yml”)

Source

fn try_parse(&self, bytes: &[u8]) -> Result<Input>

Parses a byte slice to Input.

Source

fn is_format_supported(&self, bytes: &[u8]) -> Option<bool>

Checks if provided byte slice is ok for future parsing. (e.g. is it YAML at all or not)

Provided Methods§

Source

fn parse(&self, bytes: &[u8]) -> Result<Input, Error>

Implementors§