pub struct KdlEntry { /* private fields */ }
Expand description
Implementations§
Source§impl KdlEntry
impl KdlEntry
Sourcepub fn name(&self) -> Option<&KdlIdentifier>
pub fn name(&self) -> Option<&KdlIdentifier>
Gets a reference to this entry’s name, if it’s a property entry.
Sourcepub fn name_mut(&mut self) -> Option<&mut KdlIdentifier>
pub fn name_mut(&mut self) -> Option<&mut KdlIdentifier>
Gets a mutable reference to this node’s name.
Sourcepub fn set_name(&mut self, name: Option<impl Into<KdlIdentifier>>)
pub fn set_name(&mut self, name: Option<impl Into<KdlIdentifier>>)
Sets this node’s name.
Sourcepub fn span(&self) -> SourceSpan
Available on crate feature span
only.
pub fn span(&self) -> SourceSpan
span
only.Gets this entry’s span.
This value will be properly initialized when created via crate::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.
Sourcepub fn set_span(&mut self, span: impl Into<SourceSpan>)
Available on crate feature span
only.
pub fn set_span(&mut self, span: impl Into<SourceSpan>)
span
only.Sets this entry’s span.
Sourcepub fn ty(&self) -> Option<&KdlIdentifier>
pub fn ty(&self) -> Option<&KdlIdentifier>
Gets the entry’s type.
Sourcepub fn ty_mut(&mut self) -> Option<&mut KdlIdentifier>
pub fn ty_mut(&mut self) -> Option<&mut KdlIdentifier>
Gets a mutable reference to this entry’s type.
Sourcepub fn set_ty(&mut self, ty: impl Into<KdlIdentifier>)
pub fn set_ty(&mut self, ty: impl Into<KdlIdentifier>)
Sets the entry’s type.
Sourcepub fn format(&self) -> Option<&KdlEntryFormat>
pub fn format(&self) -> Option<&KdlEntryFormat>
Gets the formatting details for this entry.
Sourcepub fn format_mut(&mut self) -> Option<&mut KdlEntryFormat>
pub fn format_mut(&mut self) -> Option<&mut KdlEntryFormat>
Gets a mutable reference to this entry’s formatting details.
Sourcepub fn set_format(&mut self, format: KdlEntryFormat)
pub fn set_format(&mut self, format: KdlEntryFormat)
Sets the formatting details for this entry.
Sourcepub fn new_prop(
key: impl Into<KdlIdentifier>,
value: impl Into<KdlValue>,
) -> Self
pub fn new_prop( key: impl Into<KdlIdentifier>, value: impl Into<KdlValue>, ) -> Self
Creates a new Property (key/value) KdlEntry.
Sourcepub fn clear_format(&mut self)
pub fn clear_format(&mut self)
Clears leading and trailing text (whitespace, comments), as well as resetting this entry’s value to its default representation.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this entry is completely empty (including whitespace).
Sourcepub fn keep_format(&mut self)
pub fn keep_format(&mut self)
Keeps the general entry formatting, though v1 entries will still be updated to v2 while preserving as much as possible.
Sourcepub fn autoformat(&mut self)
pub fn autoformat(&mut self)
Auto-formats this entry.
Sourcepub fn parse(s: &str) -> Result<Self, KdlError>
pub fn parse(s: &str) -> Result<Self, KdlError>
Parses a string into a entry.
If the v1-fallback
feature is enabled, this method will first try to
parse the string as a KDL v2 entry, and, if that fails, it will try
to parse again as a KDL v1 entry. If both fail, only the v2 parse
errors will be returned.