pub enum Format {
Json,
Toml,
Yaml,
Dotenv,
Ini,
TomlFrontmatter,
YamlFrontmatter,
Markdown,
}Variants§
Json
Toml
Yaml
Dotenv
Ini
TomlFrontmatter
A +++-fenced TOML frontmatter block; the Markdown body is frozen. Never
auto-detected — selected only via --input-format toml-frontmatter.
YamlFrontmatter
A ----fenced YAML frontmatter block; the Markdown body is frozen. Never
auto-detected — selected only via --input-format yaml-frontmatter.
Markdown
A CommonMark document read as a tree of heading sections (preamble,
h1, h1.0.h2, …). Read-only, and never auto-detected — the same .md
file is legitimately readable as frontmatter, and choosing between two
valid readings is not something an extension can decide.
Implementations§
Source§impl Format
impl Format
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
Stable human-readable label used in document results and diagnostics.
Sourcepub const fn is_read_only(self) -> bool
pub const fn is_read_only(self) -> bool
Whether this format can be written at all.
Markdown is the one reader-only format: its parsed value is a flattened view of prose, so re-rendering a document from it would discard everything the flattening dropped. Every mutating verb refuses up front rather than producing that file.
Sourcepub const fn array_rule(self) -> Option<ArrayRule<'static>>
pub const fn array_rule(self) -> Option<ArrayRule<'static>>
This format’s own rule for resolving a non-numeric path segment
against an array, or None when only a caller-declared keyed list can.
A format earns a rule by owning the shape of its own value. Markdown’s
value is a tree afdata synthesized — every node carries text because
this crate put it there — so h2.look can be answered from the format
alone. JSON, TOML, YAML, dotenv, and INI hand back whatever the file
said; nothing in deps.foo tells afdata which field of a deps element
foo is supposed to match, and inventing one is the shape-guessing this
crate exists to refuse. Those keep needing an explicit
KeyedList.
Sourcepub const fn cli_name(self) -> &'static str
pub const fn cli_name(self) -> &'static str
Exact CLI token accepted by --input-format and emitted in result
payloads. Unlike Self::name, this is stable machine data rather than
a display label.
Sourcepub fn load(&self, content: &str) -> DocumentResult<Value>
pub fn load(&self, content: &str) -> DocumentResult<Value>
Load a config file in the detected format.
Sourcepub fn save(&self, value: &Value) -> DocumentResult<String>
pub fn save(&self, value: &Value) -> DocumentResult<String>
Save a config in the target format.
Trait Implementations§
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.