Crate svgdom [] [src]

This library is designed to represent SVG data as a tree structure.

Here is simple overview of a such structure:

The Document itself is just a container of the Nodes. You can create new a Nodes only from the Document. Parsing and generating of the SVG data also done through it.

The Node represents any kind of a XML node. It can be an element, a comment, a text, etc. There are no different structs for each type.

The TagName represents tag name of the element node. It's a tuple of ElementId and String types. The ElementId contains all possible SVG element names and String used for unknown elements. Such separation used for a performance reasons.

There are two types of attributes, like with tag names: one for SVG attributes and one for unknown. Unknown attributes stored in a simple HashMap<String,String> structure. And SVG attributes stored behind a pretty complex struct. See Attributes documentation for details. Only SVG attributes supports AttributeValue, which is stored preprocessed data and not a raw strings like usual XML parser.

At last, the id attribute is stored as a separate value and not as part of the Attributes.

 

See modules and structs documentation for details.

 

DOM structure itself based on: https://github.com/SimonSapin/rust-forest/tree/master/rctree

Modules

types

This module contains submodules which represents SVG value types.

Structs

Attribute

Representation oh the SVG attribute object.

Attributes

Wrapper around attributes list.

Document

Container of Nodes.

ErrorPos

The position of the error.

Node

Representation of an SVG node.

ParseOptions

Options used during parsing.

Traverse

An iterator of references to a given node and its descendants, in tree order.

WriteOptions

Options used during writing.

WriteOptionsNumbers

Options used during writing numbers.

WriteOptionsPaths

Options used during writing SVG paths.

WriteOptionsTransforms

Options used during writing SVG transforms.

Enums

AttributeId

List of all SVG attributes.

AttributeValue

Value of SVG attribute.

ElementId

List of all SVG elements.

Error

List of all errors that can occur during processing of SVG DOM.

NodeEdge
NodeType

List of supported node types.

TagName

Wrapper arrow element tag name.

ValueId

List of all values for presentation attributes.

Traits

FromStream

Trait for parsing data from data stream.

WriteBuffer

Trait for writing data to buffer.

WriteToString

Trait for writing data to String. Tunable to_string() alternative.