logo
pub struct KdlNode { /* private fields */ }
Expand description

Represents an individual KDL Node inside a KDL Document.

Implementations

Creates a new KdlNode with a given name.

Gets this node’s name.

Gets a mutable reference to this node’s name.

Sets this node’s name.

Gets this node’s span.

This value will be properly initialized when created via [KdlDocument::parse] but may become invalidated if the document is mutated. We do not currently guarantee this to yield any particularly consistent results at that point.

Gets a mutable reference to this node’s span.

Sets this node’s span.

Gets the node’s type identifier, if any.

Gets a mutable reference to the node’s type identifier.

Sets the node’s type identifier.

Returns a reference to this node’s entries (arguments and properties).

Returns a mutable reference to this node’s entries (arguments and properties).

Gets leading text (whitespace, comments) for this node.

Sets leading text (whitespace, comments) for this node.

Gets text (whitespace, comments) right before the children block’s starting {.

Gets text (whitespace, comments) right before the children block’s starting {.

Gets trailing text (whitespace, comments) for this node.

Sets trailing text (whitespace, comments) for this node.

Length of this node when rendered as a string.

Returns true if this node is completely empty (including whitespace).

Clears leading and trailing text (whitespace, comments), as well as the space before the children block, if any. Individual entries and their formatting will be preserved.

If you want to clear formatting on all children and entries as well, use Self::clear_fmt_recursive.

Clears leading and trailing text (whitespace, comments), as well as the space before the children block, if any. Individual entries and children formatting will also be cleared.

Fetches an entry by key. Number keys will look up arguments, strings will look up properties.

Fetches a mutable referene to an entry by key. Number keys will look up arguments, strings will look up properties.

Inserts an entry into this node. If an entry already exists with the same key, it will be replaced and the previous entry will be returned.

Numerical keys will insert arguments, string keys will insert properties.

Removes an entry from this node. If an entry already exists with the same key, it will be returned.

Numerical keys will remove arguments, string keys will remove properties.

Shorthand for self.entries_mut().push(entry).

Shorthand for self.entries_mut().clear()

Returns a reference to this node’s children, if any.

Returns a mutable reference to this node’s children, if any.

Sets the KdlDocument representing this node’s children.

Removes this node’s children completely.

Returns a mutable reference to this node’s children KdlDocument, creating one first if one does not already exist.

Auto-formats this node and its contents.

Auto-formats this node and its contents, stripping comments.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.