Skip to main content

XmlTree

Trait XmlTree 

Source
pub trait XmlTree: Sized {
Show 14 methods // Required methods fn tag(&self) -> Option<String>; fn attribute(&self, name: &str) -> Option<String>; fn set_attribute(&mut self, name: &str, value: &str) -> Result<()>; fn text(&self) -> Option<String>; fn set_text(&mut self, text: &str) -> Result<()>; fn len(&self) -> usize; fn child(&self, index: usize) -> Option<Self>; fn with_child<R>( &mut self, index: usize, change: impl FnOnce(&mut Self) -> R, ) -> Option<R>; fn insert(&mut self, index: usize, child: Self) -> Result<()>; fn remove(&mut self, index: usize) -> Result<()>; fn element(&self, tag: &str) -> Result<Self>; fn comment(&self, text: &str) -> Result<Self>; fn deep_copy(&self) -> Result<Self>; // Provided method fn is_empty(&self) -> bool { ... }
}
Available on crate feature musicxml only.
Expand description

An XML element the joining steps can read and change: its tag, attributes, text and children, counted as ElementTree counts them, comments included.

XmlTree::child hands back a child to read. What it hands back may be a copy, so a child is changed through XmlTree::with_child.

Required Methods§

Source

fn tag(&self) -> Option<String>

The tag, or nothing for a comment.

Source

fn attribute(&self, name: &str) -> Option<String>

An attribute, where it is set.

Source

fn set_attribute(&mut self, name: &str, value: &str) -> Result<()>

Sets an attribute.

Source

fn text(&self) -> Option<String>

The text, where there is some.

Source

fn set_text(&mut self, text: &str) -> Result<()>

Sets the text.

Source

fn len(&self) -> usize

How many children, comments included.

Source

fn child(&self, index: usize) -> Option<Self>

The child at an index, to read.

Source

fn with_child<R>( &mut self, index: usize, change: impl FnOnce(&mut Self) -> R, ) -> Option<R>

Runs change on the child at an index, where it is an element.

Source

fn insert(&mut self, index: usize, child: Self) -> Result<()>

Puts a node in at an index.

Source

fn remove(&mut self, index: usize) -> Result<()>

Takes away the child at an index.

Source

fn element(&self, tag: &str) -> Result<Self>

A new element of this tag, of the same kind of tree.

Source

fn comment(&self, text: &str) -> Result<Self>

A new comment, of the same kind of tree.

Source

fn deep_copy(&self) -> Result<Self>

A copy of the whole element, unconnected to this one.

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether it has no children.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§