pub struct DocumentBuilder {
    session: Session,
    load_options: Arc<LoadOptions>,
    tree: Option<Node<NodeData>>,
    ids: HashMap<String, Node<NodeData>>,
    stylesheets: Vec<Stylesheet>,
}
Expand description

Used to build a tree of SVG nodes while an XML document is being read.

This struct holds the document-related state while loading an SVG document from XML: the loading options, the partially-built tree of nodes, the CSS stylesheets that appear while loading the document.

The XML loader asks a DocumentBuilder to append_element, append_characters, etc. When all the XML has been consumed, the caller can use build to get a fully-loaded Document.

Fields§

§session: Session

Metadata for the document’s lifetime.

§load_options: Arc<LoadOptions>

Loading options; mainly the URL resolver.

§tree: Option<Node<NodeData>>

Root node of the tree.

§ids: HashMap<String, Node<NodeData>>

Mapping from id attributes to nodes.

§stylesheets: Vec<Stylesheet>

Stylesheets defined in the document.

Implementations§

Adds a stylesheet in order to the document.

Stylesheets will later be matched in the order in which they were added.

Creates an element of the specified name as a child of parent.

This is the main function to create new SVG elements while parsing XML.

name is the XML element’s name, for example rect.

attrs has the XML element’s attributes, e.g. cx/cy/r for <circle cx="0" cy="0" r="5">.

If parent is None it means that we are creating the root node in the tree of elements. The code will later validate that this is indeed an <svg> element.

Creates a node for an XML text element as a child of parent.

Does the final validation on the Document being read, and returns it.

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 alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
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.