Skip to main content

Format

Trait Format 

Source
pub trait Format {
    // Required methods
    fn name(&self) -> &'static str;
    fn parse(
        &self,
        path: &Path,
        bytes: &[u8],
    ) -> Result<ConfigValue, SourceError>;
    fn serialize(&self, value: &ConfigValue) -> Result<Vec<u8>, SourceError>;
}
Expand description

Pluggable serialization format for config files.

Required Methods§

Source

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

Source

fn parse(&self, path: &Path, bytes: &[u8]) -> Result<ConfigValue, SourceError>

Parse raw bytes from path into a ConfigValue tree.

§Errors

Returns SourceError::Parse if the bytes are not valid for this format.

Source

fn serialize(&self, value: &ConfigValue) -> Result<Vec<u8>, SourceError>

Serialize a ConfigValue tree to bytes.

§Errors

Returns SourceError::Serialize if the value cannot be expressed in this format.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§