pub struct Attributes(/* private fields */);Expand description
A collection of Attribute entries associated with an element.
Implementations§
Source§impl Attributes
impl Attributes
Sourcepub fn insert(&mut self, attribute: impl Into<Attribute>) -> Option<Attribute>
Available on crate feature write only.
pub fn insert(&mut self, attribute: impl Into<Attribute>) -> Option<Attribute>
write only.Inserts the given attribute and returns the previous attribute with the same name, if any.
§Examples
- Inserting a custom attribute into a detached spine entry:
let mut detached = DetachedEpubSpineEntry::new("c1");
let mut entry_mut = detached.as_mut();
let attributes = entry_mut.attributes_mut();
// Insert a custom vendor attribute
attributes.insert(("this:appearance", "omit"));
assert_eq!(Some("omit"), attributes.get_value("this:appearance"));Sourcepub fn by_name_mut(&mut self, name: &str) -> Option<&mut Attribute>
Available on crate feature write only.
pub fn by_name_mut(&mut self, name: &str) -> Option<&mut Attribute>
write only.Sourcepub fn iter_mut(&mut self) -> AttributesIterMut<'_> ⓘ
Available on crate feature write only.
pub fn iter_mut(&mut self) -> AttributesIterMut<'_> ⓘ
write only.Returns an iterator over all mutable Attribute entries.
Sourcepub fn remove(&mut self, name: &str) -> Option<Attribute>
Available on crate feature write only.
pub fn remove(&mut self, name: &str) -> Option<Attribute>
write only.Removes and returns the attribute with the given name, if present.
Sourcepub fn retain(&mut self, f: impl FnMut(&Attribute) -> bool)
Available on crate feature write only.
pub fn retain(&mut self, f: impl FnMut(&Attribute) -> bool)
write only.Retains only the attributes specified by the predicate.
If the closure returns false, the attribute is retained.
Otherwise, the attribute is removed.
This method operates in place and visits every attribute exactly once.
§See Also
Self::extract_ifto get an iterator of the removed attributes.
Sourcepub fn extract_if(
&mut self,
f: impl FnMut(&Attribute) -> bool,
) -> impl Iterator<Item = Attribute>
Available on crate feature write only.
pub fn extract_if( &mut self, f: impl FnMut(&Attribute) -> bool, ) -> impl Iterator<Item = Attribute>
write only.Removes and returns only the attributes specified by the predicate.
If the closure returns true, the attribute is removed and yielded.
Otherwise, the attribute is retained.
§Drop
If the returned iterator is not exhausted, (e.g. dropped without iterating or iteration short-circuits), then the remaining attributes are retained.
Prefer Self::retain with a negated predicate if the returned iterator is not needed.
Sourcepub fn drain(&mut self) -> impl Iterator<Item = Attribute>
Available on crate feature write only.
pub fn drain(&mut self) -> impl Iterator<Item = Attribute>
write only.Removes and returns all attributes.
Source§impl Attributes
impl Attributes
Sourcepub fn iter(&self) -> AttributesIter<'_> ⓘ
pub fn iter(&self) -> AttributesIter<'_> ⓘ
Returns an iterator over all Attribute entries.
Sourcepub fn by_name(&self, name: &str) -> Option<&Attribute>
pub fn by_name(&self, name: &str) -> Option<&Attribute>
Returns the Attribute with the given name if present, otherwise None.
§See Also
Self::get_valueto get the attribute value directly.
Trait Implementations§
Source§impl Clone for Attributes
impl Clone for Attributes
Source§fn clone(&self) -> Attributes
fn clone(&self) -> Attributes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Attributes
impl Debug for Attributes
Source§impl Extend<Attribute> for Attributes
Available on crate feature write only.
impl Extend<Attribute> for Attributes
write only.Source§fn extend<I: IntoIterator<Item = Attribute>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Attribute>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a> IntoIterator for &'a mut Attributes
Available on crate feature write only.
impl<'a> IntoIterator for &'a mut Attributes
write only.