Skip to main content

FormatParser

Trait FormatParser 

Source
pub trait FormatParser: Send + Sync {
    // Required methods
    fn id(&self) -> &'static str;
    fn extensions(&self) -> &'static [&'static str];
    fn sniff(&self, bytes: &[u8]) -> Option<Confidence>;
    fn parse(&self, source: &str, bytes: &[u8]) -> Result<Vec<Column>, AxError>;
}
Expand description

One file format. Implementors live in parsers/ — one per format.

Required Methods§

Source

fn id(&self) -> &'static str

Stable identifier, recorded in the envelope’s format field (e.g. "csv").

Source

fn extensions(&self) -> &'static [&'static str]

File extensions this parser claims (lower-case, no dot).

Source

fn sniff(&self, bytes: &[u8]) -> Option<Confidence>

How strongly bytes looks like this format, or None if it clearly is not. Used only when the extension doesn’t decide.

Source

fn parse(&self, source: &str, bytes: &[u8]) -> Result<Vec<Column>, AxError>

Parse bytes (from logical source) into columns.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§