pub struct Element {
pub name: Name,
pub attrs: Vec<Attribute>,
pub children: Vec<Node>,
pub self_closing: bool,
}Expand description
An element: its name, its attributes in the order they were written, and its children.
Fields§
§name: NameThe element’s name.
attrs: Vec<Attribute>Attributes in document order, including any namespace declarations.
children: Vec<Node>Children in document order.
self_closing: boolTrue when the element was written <a/>. Only consulted when there are
no children, and exists so that a round trip does not rewrite every
empty element in the document.
Implementations§
Source§impl Element
impl Element
Sourcepub fn new(prefix: &str, local: &str, ns: Ns) -> Self
pub fn new(prefix: &str, local: &str, ns: Ns) -> Self
A new element with no attributes and no children.
Sourcepub fn attr(&self, ns: &Ns, local: &str) -> Option<&str>
pub fn attr(&self, ns: &Ns, local: &str) -> Option<&str>
The value of an attribute, by namespace and local name.
Sourcepub fn attr_usize(&self, ns: &Ns, local: &str) -> Option<usize>
pub fn attr_usize(&self, ns: &Ns, local: &str) -> Option<usize>
The value of an attribute, read as an integer. Absent, or present and
unreadable, are the same answer: ODF’s own default applies either way and
a document that says table:number-columns-repeated="many" is not a
reason to refuse the document.
Sourcepub fn child(&self, ns: &Ns, local: &str) -> Option<&Element>
pub fn child(&self, ns: &Ns, local: &str) -> Option<&Element>
The first child element with the given name.
Sourcepub fn descendant(&self, ns: &Ns, local: &str) -> Option<&Element>
pub fn descendant(&self, ns: &Ns, local: &str) -> Option<&Element>
The first descendant element with the given name, depth first.
Sourcepub fn plain_text(&self) -> String
pub fn plain_text(&self) -> String
Every character of text under this element, with ODF’s own whitespace elements turned back into the characters they stand for.
text:s is a run of spaces, text:tab a tab and text:line-break a
newline, because ODF collapses literal runs of whitespace and spells out
what it means instead. This is what a spreadsheet cell’s displayed string
and a search over a document both read.
Trait Implementations§
impl Eq for Element
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl UnwindSafe for Element
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.