Skip to main content

ConfigFormat

Trait ConfigFormat 

Source
pub trait ConfigFormat: ConfigValue + Sealed {
    const FORMAT: Format;

    // Required methods
    fn parse_document(text: &str) -> Result<Self>;
    fn parse_inline(text: String) -> Self;
    fn serialize(&self, pretty: bool) -> Result<String>;
}
Expand description

Parsing and emission for the two supported native formats.

Sealed to JSON and TOML; structural algorithms use the open ConfigValue interface. Inline values and whole-string environment references always share this trait’s typing rule.

Required Associated Constants§

Source

const FORMAT: Format

The format represented by this native value.

Required Methods§

Source

fn parse_document(text: &str) -> Result<Self>

Parse a document. Top-level object validation happens in parse.

Source

fn parse_inline(text: String) -> Self

Parse one value, falling back to the original text as a string.

Source

fn serialize(&self, pretty: bool) -> Result<String>

Serialize directly in this native format.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ConfigFormat for Value

Source§

const FORMAT: Format = Format::Json

Source§

fn parse_document(text: &str) -> Result<Self>

Source§

fn parse_inline(text: String) -> Self

Source§

fn serialize(&self, pretty: bool) -> Result<String>

Source§

impl ConfigFormat for Value

Source§

const FORMAT: Format = Format::Toml

Source§

fn parse_document(text: &str) -> Result<Self>

Source§

fn parse_inline(text: String) -> Self

Source§

fn serialize(&self, pretty: bool) -> Result<String>

Implementors§