Struct svgdom::Attributes
[−]
[src]
pub struct Attributes(_);
Wrapper around attributes list.
More low level API than in Node
, but it supports getting a reference to the attribute,
and not only copy like Node
's API.
Use with care, since it didn't perform many check from Node
's API.
Methods
impl Attributes
[src]
fn new() -> Attributes
Constructs a new attribute.
Warning: newer construct it manually. All nodes have Attributes
by default.
fn get<'a, N>(&self, name: N) -> Option<&Attribute> where AttributeNameRef<'a>: From<N>
Returns an optional reference to Attribute
.
fn get_mut<'a, N>(&mut self, name: N) -> Option<&mut Attribute> where AttributeNameRef<'a>: From<N>
Returns an optional mutable reference to Attribute
.
fn get_value<'a, N>(&self, name: N) -> Option<&AttributeValue> where AttributeNameRef<'a>: From<N>
Returns an optional reference to AttributeValue
.
fn get_value_mut<'a, N>(&mut self, name: N) -> Option<&mut AttributeValue> where AttributeNameRef<'a>: From<N>
Returns an optional mutable reference to AttributeValue
.
fn insert(&mut self, attr: Attribute)
Inserts a new attribute. Previous will be overwritten.
Warning: this method did not perform any checks for linked attributes.
If you want to insert an linked attribute - use Node::set_link_attribute()
.
fn insert_from<'a, N, T>(&mut self, name: N, value: T) where AttributeNameRef<'a>: From<N>, N: Copy, AttributeValue: From<T>
Creates a new attribute from name and value and inserts it. Previous will be overwritten.
Warning: this method did not perform any checks for linked attributes.
If you want to insert an linked attribute - use Node::set_link_attribute()
.
fn remove<'a, N>(&mut self, name: N) where AttributeNameRef<'a>: From<N>
Removes an existing attribute.
Warning: this method did not perform any checks for linked attributes.
If you want to remove an linked attribute - use Node::remove_attribute()
.
fn contains<'a, N>(&self, name: N) -> bool where AttributeNameRef<'a>: From<N>
Returns true
if the container contains an attribute with such id
.
fn len(&self) -> usize
Returns count of the attributes.
fn is_empty(&self) -> bool
Returns true
if attributes is empty.
fn iter(&self) -> Iter<Attribute>
Returns an iterator.
fn iter_mut(&mut self) -> IterMut<Attribute>
Returns a mutable iterator.
fn iter_svg<'a>(&'a self)
-> Map<Filter<Iter<'a, Attribute>, fn(_: &&Attribute) -> bool>, fn(_: &'a Attribute) -> (AttributeId, &'a Attribute)>
-> Map<Filter<Iter<'a, Attribute>, fn(_: &&Attribute) -> bool>, fn(_: &'a Attribute) -> (AttributeId, &'a Attribute)>
Returns an iterator over SVG attributes.
Shorthand for: iter().filter(|a| a.is_svg()).map(|a| (a.id().unwrap(), a))
fn iter_svg_mut<'a>(&'a mut self)
-> Map<Filter<IterMut<'a, Attribute>, fn(_: &&mut Attribute) -> bool>, fn(_: &'a mut Attribute) -> (AttributeId, &'a mut Attribute)>
-> Map<Filter<IterMut<'a, Attribute>, fn(_: &&mut Attribute) -> bool>, fn(_: &'a mut Attribute) -> (AttributeId, &'a mut Attribute)>
Returns a mutable iterator over SVG attributes.
Shorthand for: iter_mut().filter(|a| a.is_svg()).map(|a| (a.id().unwrap(), a))
fn retain<F>(&mut self, f: F) where F: FnMut(&Attribute) -> bool
Retains only elements specified by the predicate.