Skip to main content

Format

Enum Format 

Source
#[non_exhaustive]
pub enum Format {
Show 13 variants Json, Jsonc, Json5, Yaml, Toml, Zon, Fig, Ini, Dotenv, Properties, Plist, Nestedtext, Runtime(RuntimeFormat),
}
Expand description

A config format. Every variant parses, edits, and serializes.

Every variant is always present in the enum, but each format is gated by a crate feature of the same name (json, yaml, toml, zon, fig). Every format the core registers. json, yaml, toml, fig, ini, dotenv, properties and nestedtext are on by default; zon and plist are opt-in features. Disabling a feature compiles that format out of the bundled native library, so selecting it then fails with Error::UnsupportedFormat at runtime. Json/Jsonc/Json5 share one core behind the json feature.

#[non_exhaustive]: the core gains formats over time, so a match needs a _ arm. Constructing a variant is unaffected.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Json

§

Jsonc

§

Json5

§

Yaml

§

Toml

§

Zon

§

Fig

The native fig authoring dialect (see src/languages/fig/DESIGN.md in the core repo) — a memorable, typeable surface over the same AST.

§

Ini

INI ([section] + key = value). Untyped-string scalars: port = 8080 reads back as the string "8080". A root mapping and one level of [section] nesting only.

§

Dotenv

dotenv / .env (flat KEY=value). A flat string map: no nesting, untyped scalars.

§

Properties

Java .properties (flat key=value). Same flat, untyped limits as Format::Dotenv.

§

Plist

Apple XML property list. Typed and nested (dict/array/string/integer/ real/bool, with date/data on the extended scalar). Opt-in: the plist feature.

§

Nestedtext

NestedText (https://nestedtext.org). Nested (dict/list) but deliberately untyped — every leaf is a string.

§

Runtime(RuntimeFormat)

A language registered at runtime through language::register — the value that call returns, a peer of every variant above at every entry point that takes a Format. Its integer is assigned per process: persist the name and resolve it with Format::by_name.

Implementations§

Source§

impl Format

Source

pub fn by_name(name: &str) -> Option<Format>

The format named name: a compiled format’s registry name ("json5", "yaml", …) or a language registered at runtime. None when nothing answers to it in this process.

Trait Implementations§

Source§

impl Clone for Format

Source§

fn clone(&self) -> Format

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Format

Source§

impl Debug for Format

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Format

Source§

impl PartialEq for Format

Source§

fn eq(&self, other: &Format) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Format

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.