Struct usvg::Tree

source ·
pub struct Tree { /* private fields */ }
Expand description

A nodes tree container.

Implementations§

source§

impl Tree

source

pub fn from_data(data: &[u8], opt: &Options<'_>) -> Result<Self, Error>

Parses Tree from an SVG data.

Can contain an SVG string or a gzip compressed data.

source

pub fn from_str(text: &str, opt: &Options<'_>) -> Result<Self, Error>

Parses Tree from an SVG string.

source

pub fn from_xmltree( doc: &Document<'_>, opt: &Options<'_> ) -> Result<Self, Error>

Parses Tree from roxmltree::Document.

source§

impl Tree

source

pub fn size(&self) -> Size

Image size.

Size of an image that should be created to fit the SVG.

width and height in SVG.

source

pub fn root(&self) -> &Group

The root element of the SVG tree.

source

pub fn node_by_id(&self, id: &str) -> Option<&Node>

Returns a renderable node by ID.

If an empty ID is provided, than this method will always return None.

source

pub fn has_text_nodes(&self) -> bool

Checks if the current tree has any text nodes.

source

pub fn linear_gradients(&self) -> &[Arc<LinearGradient>]

Returns a list of all unique LinearGradients in the tree.

source

pub fn radial_gradients(&self) -> &[Arc<RadialGradient>]

Returns a list of all unique RadialGradients in the tree.

source

pub fn patterns(&self) -> &[Arc<Pattern>]

Returns a list of all unique Patterns in the tree.

source

pub fn clip_paths(&self) -> &[Arc<ClipPath>]

Returns a list of all unique ClipPaths in the tree.

source

pub fn masks(&self) -> &[Arc<Mask>]

Returns a list of all unique Masks in the tree.

source

pub fn filters(&self) -> &[Arc<Filter>]

Returns a list of all unique Filters in the tree.

source

pub fn fontdb(&self) -> &Arc<Database>

Returns the font database that applies to all text nodes in the tree.

source§

impl Tree

source

pub fn to_string(&self, opt: &WriteOptions) -> String

Writes usvg::Tree back to SVG.

Trait Implementations§

source§

impl Clone for Tree

source§

fn clone(&self) -> Tree

Returns a copy 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 Tree

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl !RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl !UnwindSafe for Tree

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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.