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§
fn name(&self) -> &'static str
Sourcefn parse(&self, path: &Path, bytes: &[u8]) -> Result<ConfigValue, SourceError>
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.
Sourcefn serialize(&self, value: &ConfigValue) -> Result<Vec<u8>, SourceError>
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".