Struct SvgNode

Source
pub struct SvgNode<'a, 'input: 'a> {
    id: NodeId,
    doc: &'a Document<'input>,
    d: &'a NodeData,
}
Expand description

An SVG node.

Fields§

§id: NodeId§doc: &'a Document<'input>§d: &'a NodeData

Implementations§

Source§

impl<'a, 'input: 'a> SvgNode<'a, 'input>

Source

pub(crate) fn convert_length( &self, aid: AId, object_units: Units, state: &State<'_>, def: Length, ) -> f32

Source

pub fn convert_user_length( &self, aid: AId, state: &State<'_>, def: Length, ) -> f32

Source

pub fn parse_viewbox(&self) -> Option<NonZeroRect>

Source

pub fn resolve_length(&self, aid: AId, state: &State<'_>, def: f32) -> f32

Source

pub fn resolve_valid_length( &self, aid: AId, state: &State<'_>, def: f32, ) -> Option<NonZeroPositiveF32>

Source

pub(crate) fn try_convert_length( &self, aid: AId, object_units: Units, state: &State<'_>, ) -> Option<f32>

Source

pub fn has_valid_transform(&self, aid: AId) -> bool

Source

pub fn is_visible_element(&self, opt: &Options<'_>) -> bool

Source§

impl SvgNode<'_, '_>

Source

pub(crate) fn resolve_transform( &self, transform_aid: AId, state: &State<'_>, ) -> Transform

Source§

impl<'a, 'input: 'a> SvgNode<'a, 'input>

Source

fn id(&self) -> NodeId

Source

pub fn is_element(&self) -> bool

Checks if the current node is an element.

Source

pub fn is_text(&self) -> bool

Checks if the current node is a text.

Source

pub fn document(&self) -> &'a Document<'input>

Returns node’s document.

Source

pub fn tag_name(&self) -> Option<EId>

Returns element’s tag name, unless the current node is text.

Source

pub fn element_id(&self) -> &'a str

Returns element’s id attribute value.

Returns an empty string otherwise.

Source

pub fn attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>

Returns an attribute value.

Source

pub fn try_attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>

Returns an attribute value.

Same as SvgNode::attribute, but doesn’t show a warning.

Source

fn node_attribute(&self, aid: AId) -> Option<SvgNode<'a, 'input>>

Source

pub fn has_attribute(&self, aid: AId) -> bool

Checks if an attribute is present.

Source

pub fn attributes(&self) -> &'a [Attribute<'input>]

Returns a list of all element’s attributes.

Source

fn attribute_id(&self, aid: AId) -> Option<usize>

Source

pub fn find_attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>

Finds a [Node] that contains the required attribute.

For inheritable attributes walks over ancestors until a node with the specified attribute is found.

For non-inheritable attributes checks only the current node and the parent one. As per SVG spec.

Source

fn find_attribute_impl(&self, aid: AId) -> Option<SvgNode<'a, 'input>>

Source

pub fn text(&self) -> &'a str

Returns node’s text data.

For text nodes returns its content. For elements returns the first child node text.

Source

pub fn parent(&self) -> Option<Self>

Returns a parent node.

Source

pub fn parent_element(&self) -> Option<Self>

Returns the parent element.

Source

pub fn next_sibling(&self) -> Option<Self>

Returns the next sibling.

Source

pub fn first_child(&self) -> Option<Self>

Returns the first child.

Source

pub fn first_element_child(&self) -> Option<Self>

Returns the first child element.

Source

pub fn last_child(&self) -> Option<Self>

Returns the last child.

Source

pub fn has_children(&self) -> bool

Checks if the node has child nodes.

Source

pub fn ancestors(&self) -> Ancestors<'a, 'input>

Returns an iterator over ancestor nodes starting at this node.

Source

pub fn children(&self) -> Children<'a, 'input>

Returns an iterator over children nodes.

Source

fn traverse(&self) -> Traverse<'a, 'input>

Returns an iterator which traverses the subtree starting at this node.

Source

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

Returns an iterator over this node and its descendants.

Source

pub fn href_iter(&self) -> HrefIter<'a, 'input>

Returns an iterator over elements linked via xlink:href.

Trait Implementations§

Source§

impl<'a, 'input: 'a> Clone for SvgNode<'a, 'input>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SvgNode<'_, '_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, 'input: 'a> FromValue<'a, 'input> for SvgNode<'a, 'input>

Source§

fn parse(node: SvgNode<'a, 'input>, aid: AId, value: &str) -> Option<Self>

Parses an attribute value. Read more
Source§

impl PartialEq for SvgNode<'_, '_>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'input: 'a> Copy for SvgNode<'a, 'input>

Source§

impl Eq for SvgNode<'_, '_>

Auto Trait Implementations§

§

impl<'a, 'input> Freeze for SvgNode<'a, 'input>

§

impl<'a, 'input> RefUnwindSafe for SvgNode<'a, 'input>

§

impl<'a, 'input> Send for SvgNode<'a, 'input>

§

impl<'a, 'input> Sync for SvgNode<'a, 'input>

§

impl<'a, 'input> Unpin for SvgNode<'a, 'input>

§

impl<'a, 'input> UnwindSafe for SvgNode<'a, '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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.