Skip to main content

Toml

Struct Toml 

Source
pub(crate) struct Toml {
    pub(super) inline_width: InlineWidth,
    format: Format,
}
Expand description

Reconciles TOML documents, rendering inline tables up to a fixed width.

Fields§

§inline_width: InlineWidth§format: Format

Implementations§

Source§

impl Toml

Source

pub(crate) const fn new(inline_width: InlineWidth) -> Self

Source

pub(super) const fn unsupported(self, feature: Feature) -> DocumentError

Source§

impl Toml

Source

fn key_comment(parent: &Item, key: &str) -> Option<String>

The comment above the value key key of parent, if it has one.

Source

fn set_key_comment( table: &mut dyn TableLike, key: &str, comment: Option<String>, )

Source

fn trim_leading_blank_lines(table: &mut Table)

Drop the blank lines before the first entry of table, which only separated it from an entry that is gone.

Source

fn replace_keeping_decor(old: &Item, new: Item) -> Item

new, with the decor of the item it replaces so that the user’s spacing and comments stay. A table keeps the comment above its header unless the new table brings one, and then keeps the blank lines above the old one.

Source§

impl Toml

Source

pub(super) fn build_document( self, annotated: &Annotated, ) -> Result<TomlTree, DocumentError>

Source

fn populate_table( self, table: &mut Table, entries: &Entries, is_root: bool, ) -> Result<(), DocumentError>

Source

fn has_header(item: &Item) -> bool

Whether item is printed under a header of its own.

Source

fn item( self, key: &str, annotated: &Annotated, is_root: bool, ) -> Result<Item, DocumentError>

Source

fn fits_inline(self, key: &str, inline: &InlineTable) -> bool

Whether key = inline fits within the configured columns.

Source

fn array_item(self, items: &[Annotated]) -> Result<Item, DocumentError>

Source

fn array(self, items: &[Annotated]) -> Result<Array, DocumentError>

Source

fn spread(array: &mut Array, items: &[Annotated])

Put every item on its own line, with its comment above it.

Source

fn inline_value(self, annotated: &Annotated) -> Result<TomlValue, DocumentError>

A value inside an inline table, which cannot hold comments.

Source

fn array_value(self, annotated: &Annotated) -> Result<TomlValue, DocumentError>

Source

fn scalar(self, scalar: &Scalar) -> Result<TomlValue, DocumentError>

Source

const fn unvalidated(feature: Feature) -> DocumentError

Source

fn styled_string( self, text: &str, style: StringStyle, ) -> Result<TomlValue, DocumentError>

Source

fn literal_string(self, text: &str) -> Result<TomlValue, DocumentError>

Source

fn inline_table(self, entries: &Entries) -> Result<InlineTable, DocumentError>

Source

fn write_comment(out: &mut String, comment: &Comment, indent: &str)

Source

fn comment_first_leaf(table: &mut Table, prefix: String)

Put prefix before the first line of a dotted table, which prints the decor of its leaf keys.

Source

fn attach_comment(table: &mut Table, key: &str, comment: &Comment)

Trait Implementations§

Source§

impl Backend for Toml

Source§

type Document = TomlTree

Source§

fn parse(&self, source: &str) -> Result<TomlTree, DocumentError>

Parse an existing source document. Read more
Source§

fn format(&self) -> Format

The format this backend reads and writes.
Source§

fn build(&self, desired: &Annotated) -> Result<TomlTree, DocumentError>

Build the desired document from its annotated value. Read more
Source§

fn string_leaf(&self, node: &Item) -> Result<Option<String>, DocumentError>

The text of node when it is a string, None for any other kind of value. Read more
Source§

fn finish(&self, current: &mut TomlTree, desired: &TomlTree, existing: Existing)

Adjust the merged document before it is rendered.
Source§

fn descend<'n>( &self, node: &'n <<Self as Backend>::Document as Editable>::Node, key: &str, _path: &[String], ) -> Result<Option<&'n <<Self as Backend>::Document as Editable>::Node>, DocumentError>

The child key of node, which sits at path. Backends fail here when a node on the way cannot be read through. Read more
Source§

fn explain(&self, _current: &Self::Document, error: MergeError) -> DocumentError

The error for a merge that failed against current. Backends can name a cause more precisely than the generic conflict.
Source§

fn read_string( &self, source: &str, path: &[String], ) -> Result<Option<String>, DocumentError>

The string at path in source, or None when a key on the way is absent. Read more
Source§

fn reconcile( &self, desired: &Annotated, source: &Source<'_>, ownership: &Ownership, ) -> Result<Vec<u8>, DocumentError>

Reconcile a desired value against the current source. Read more
Source§

impl Clone for Toml

Source§

fn clone(&self) -> Toml

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 Toml

Source§

impl Debug for Toml

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Toml

§

impl RefUnwindSafe for Toml

§

impl Send for Toml

§

impl Sync for Toml

§

impl Unpin for Toml

§

impl UnsafeUnpin for Toml

§

impl UnwindSafe for Toml

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<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> 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, <T as TryFrom<U>>::Error>

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.