Trait svgdom::ElementType[][src]

pub trait ElementType {
    fn is_referenced(&self) -> bool;
fn is_basic_shape(&self) -> bool;
fn is_shape(&self) -> bool;
fn is_container(&self) -> bool;
fn is_text_content(&self) -> bool;
fn is_text_content_child(&self) -> bool;
fn is_graphic(&self) -> bool;
fn is_gradient(&self) -> bool;
fn is_paint_server(&self) -> bool; }

This trait contains methods that check element's type according to the SVG spec.

Note that all methods works with Node type and will return false if node's type is not equal to NodeType::Element.

Panics

All methods panics if the node is currently mutability borrowed.

Required Methods

Returns true if the current node is referenced.

Referenced elements are elements that do not render by itself, rather defines rendering properties for other.

List: altGlyphDef, clipPath, cursor, filter, linearGradient, marker, mask, pattern, radialGradient and symbol.

Details: https://www.w3.org/TR/SVG/struct.html#Head

Examples

use svgdom::{Document, ElementType};

let doc = Document::from_str(
    "<svg xmlns='http://www.w3.org/2000/svg'><linearGradient/></svg>").unwrap();
let mut iter = doc.root().descendants();
assert_eq!(iter.next().unwrap().is_referenced(), false); // root
assert_eq!(iter.next().unwrap().is_referenced(), false); // svg
assert_eq!(iter.next().unwrap().is_referenced(), true); // linearGradient

Returns true if the current node is a basic shape element.

List: rect, circle, ellipse, line, polyline, polygon.

Details: https://www.w3.org/TR/SVG/shapes.html

Returns true if the current node is a shape element.

List: path, rect, circle, ellipse, line, polyline and polygon.

Details: https://www.w3.org/TR/SVG/intro.html#TermShape

Returns true if the current node is a container element.

List: a, defs, glyph, g, marker, mask, missing-glyph, pattern, svg, switch and symbol.

Details: https://www.w3.org/TR/SVG/intro.html#TermContainerElement

Returns true if the current node is a text content element.

List: altGlyph, textPath, text, tref and tspan.

Details: https://www.w3.org/TR/SVG/intro.html#TermTextContentElement

Returns true if the current node is a text content child element.

List: altGlyph, textPath, tref and tspan.

Details: https://www.w3.org/TR/SVG/intro.html#TermTextContentChildElement

Returns true if the current node is a graphic element.

List: circle, ellipse, image, line, path, polygon, polyline, rect, text and use.

Details: https://www.w3.org/TR/SVG/intro.html#TermGraphicsElement

Returns true if the current node is a gradient element.

List: linearGradient, radialGradient.

Returns true if the current node is a paint server.

List: linearGradient, radialGradient and pattern.

Implementors