#[repr(u8)]pub enum Format {
Json,
Json5,
Toml {
inline_width: InlineWidth,
},
Yaml,
}Expand description
Output syntax for a structured document.
Variants§
Json
JSON.
Json5
JSON5, with unquoted keys, comments, and literal strings.
Toml
TOML.
Fields
inline_width: InlineWidthColumn limit for rendering a table as an inline table.
Yaml
YAML.
Implementations§
Source§impl Format
impl Format
Sourcepub fn from_extension(
extension: &str,
inline_width: InlineWidth,
) -> Option<Self>
pub fn from_extension( extension: &str, inline_width: InlineWidth, ) -> Option<Self>
The format of a file with this extension, without the dot. TOML needs the inline width the caller wants.
fn run<R: Run>(self, operation: R) -> R::Output
Sourcepub(crate) fn reconcile(
self,
desired: &Annotated,
source: &Source<'_>,
ownership: &Ownership,
) -> Result<Vec<u8>, DocumentError>
pub(crate) fn reconcile( self, desired: &Annotated, source: &Source<'_>, ownership: &Ownership, ) -> Result<Vec<u8>, DocumentError>
Reconcile a desired value against the current source.
§Errors
Returns an error for malformed source, values the format cannot represent, or an incompatible merge.
Sourcepub fn read_string(
self,
source: &str,
path: &ManagedPath,
) -> Result<Option<String>, DocumentError>
pub fn read_string( self, source: &str, path: &ManagedPath, ) -> Result<Option<String>, DocumentError>
The string at path in source. A key that is absent on the way
gives None.
§Errors
Returns an error for malformed source, and
ValueError::NotString when the value at path is not a string.
YAML returns the text of any scalar, including numbers and booleans.
Sourcepub(crate) const fn supports(self, feature: Feature) -> bool
pub(crate) const fn supports(self, feature: Feature) -> bool
Whether the format can express feature at all.
A literal string can still fail when the format cannot reproduce its text.
Sourcepub(crate) fn reproduces_literal(self, text: &str) -> bool
pub(crate) fn reproduces_literal(self, text: &str) -> bool
Whether the format can write text as a literal string.
Sourcepub(crate) const fn reject(self, feature: Feature) -> ValueError
pub(crate) const fn reject(self, feature: Feature) -> ValueError
The error for a feature this format cannot express.
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.