Struct Document

Source
pub struct Document<'input> {
    nodes: Vec<NodeData>,
    attrs: Vec<Attribute<'input>>,
    links: HashMap<String, NodeId>,
}
Expand description

An SVG tree container.

Contains only element and text nodes. Text nodes are present only inside the text element.

Fields§

§nodes: Vec<NodeData>§attrs: Vec<Attribute<'input>>§links: HashMap<String, NodeId>

Implementations§

Source§

impl<'input> Document<'input>

Source

pub fn parse_tree( xml: &Document<'input>, injected_stylesheet: Option<&'input str>, ) -> Result<Document<'input>, Error>

Parses a Document from a roxmltree::Document.

Source

pub(crate) fn append(&mut self, parent_id: NodeId, kind: NodeKind) -> NodeId

Source

fn append_attribute( &mut self, name: AId, value: StringStorage<'input>, important: bool, )

Source§

impl<'input> Document<'input>

Source

pub fn root<'a>(&'a self) -> SvgNode<'a, 'input>

Returns the root node.

Source

pub fn root_element<'a>(&'a self) -> SvgNode<'a, 'input>

Returns the root element.

Source

pub fn descendants<'a>(&'a self) -> Descendants<'a, 'input>

Returns an iterator over document’s descendant nodes.

Shorthand for doc.root().descendants().

Source

pub fn element_by_id<'a>(&'a self, id: &str) -> Option<SvgNode<'a, 'input>>

Returns an element by ID.

Unlike the Descendants iterator, this is just a HashMap lookup. Meaning it’s way faster.

Source

fn get<'a>(&'a self, id: NodeId) -> SvgNode<'a, 'input>

Trait Implementations§

Source§

impl Debug for Document<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'input> Freeze for Document<'input>

§

impl<'input> RefUnwindSafe for Document<'input>

§

impl<'input> Send for Document<'input>

§

impl<'input> Sync for Document<'input>

§

impl<'input> Unpin for Document<'input>

§

impl<'input> UnwindSafe for Document<'input>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.