pub enum Format {
Json,
Json5,
Jsonc,
Yaml,
Toon,
Toml,
Ini,
}Expand description
Supported textual formats for the value-model disassembler.
Variants§
Json
Json5
Jsonc
Yaml
Toon
Toml
TOML is intentionally isolated from the JSON-value formats: TOML’s syntactic constraints (no nulls, no array root, bare keys must precede tables) mean conversions through TOML can reorder or fail to represent values produced by JSON/JSON5/JSONC/YAML/TOON. TOML files can therefore only be split into TOML files and reassembled into TOML.
Ini
INI uses the same table-document split layout as TOML, but is even narrower: section values are strings (or valueless keys) and deeper nesting/arrays cannot be represented without inventing an encoding.
Implementations§
Source§impl Format
impl Format
Sourcepub fn canonical_name(self) -> &'static str
pub fn canonical_name(self) -> &'static str
Canonical lower-case name used in CLI and metadata.
Sourcepub fn display_name(self) -> &'static str
pub fn display_name(self) -> &'static str
Human-facing display name.
Sourcepub fn extensions(self) -> &'static [&'static str]
pub fn extensions(self) -> &'static [&'static str]
File extensions that identify this format.
Sourcepub fn family(self) -> FormatFamily
pub fn family(self) -> FormatFamily
The conversion family this format belongs to.
Sourcepub fn compatible_formats(self) -> &'static [Format]
pub fn compatible_formats(self) -> &'static [Format]
Formats that can safely convert to/from this format.
Sourcepub fn allows_format_overrides(self) -> bool
pub fn allows_format_overrides(self) -> bool
Whether CLI --input-format / --output-format flags are useful
for this subcommand.
Sourcepub fn is_cross_format_compatible(self) -> bool
pub fn is_cross_format_compatible(self) -> bool
Whether this format participates in cross-format conversions.
Sourcepub fn can_convert_to(self, output: Format) -> bool
pub fn can_convert_to(self, output: Format) -> bool
Whether this format can be converted into output.
Sourcepub fn ensure_can_convert_to(
self,
output: Format,
operation: ConversionOperation,
) -> Result<()>
pub fn ensure_can_convert_to( self, output: Format, operation: ConversionOperation, ) -> Result<()>
Return a clear error if a conversion edge is not allowed.
Sourcepub fn from_path(path: &Path) -> Result<Self>
pub fn from_path(path: &Path) -> Result<Self>
Best-effort detection of a format from a file path’s extension.
Sourcepub fn parse(self, input: &str) -> Result<Value>
pub fn parse(self, input: &str) -> Result<Value>
Parse a string in this format into a generic Value.
Sourcepub fn serialize(self, value: &Value) -> Result<String>
pub fn serialize(self, value: &Value) -> Result<String>
Serialize a Value in this format. The output is always
pretty-printed with newline-terminated content.
Sourcepub fn wrap_split_payload(self, key: &str, value: &Value) -> Value
pub fn wrap_split_payload(self, key: &str, value: &Value) -> Value
Prepare a per-key split payload for this format.
Most formats can write the payload value directly. TOML wraps the payload under its parent key so every split file remains a valid TOML table document.
Sourcepub fn unwrap_split_payload(
self,
key: &str,
filename: &str,
loaded: Value,
) -> Result<Value>
pub fn unwrap_split_payload( self, key: &str, filename: &str, loaded: Value, ) -> Result<Value>
Reverse Format::wrap_split_payload while reassembling.
Sourcepub fn supported_format_list() -> String
pub fn supported_format_list() -> String
Canonical CLI names for all registered formats.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Format
impl<'de> Deserialize<'de> for Format
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for Format
impl Eq for Format
impl StructuralPartialEq for Format
Auto Trait Implementations§
impl Freeze for Format
impl RefUnwindSafe for Format
impl Send for Format
impl Sync for Format
impl Unpin for Format
impl UnsafeUnpin for Format
impl UnwindSafe for Format
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.