pub struct Attributes(/* private fields */);Expand description
A validated attribute map limited to MAX_ATTRIBUTE_ENTRIES entries and
MAX_ATTRIBUTES_TOTAL_BYTES total key and value UTF-8 bytes.
Construction and decoding reject values over these limits; an empty map represents cleared attributes.
Implementations§
Source§impl Attributes
impl Attributes
Sourcepub fn new(
entries: BTreeMap<AttributeKey, AttributeValue>,
) -> Result<Self, AttributesError>
pub fn new( entries: BTreeMap<AttributeKey, AttributeValue>, ) -> Result<Self, AttributesError>
Creates a map after checking every limit.
Sourcepub fn get(&self, key: &AttributeKey) -> Option<&AttributeValue>
pub fn get(&self, key: &AttributeKey) -> Option<&AttributeValue>
Returns the value stored under a key.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&AttributeKey, &AttributeValue)>
pub fn iter(&self) -> impl Iterator<Item = (&AttributeKey, &AttributeValue)>
Iterates the entries in key order.
Sourcepub fn as_map(&self) -> &BTreeMap<AttributeKey, AttributeValue>
pub fn as_map(&self) -> &BTreeMap<AttributeKey, AttributeValue>
Returns the entries.
Sourcepub fn logical_bytes(&self) -> usize
pub fn logical_bytes(&self) -> usize
Returns the map’s total logical size in UTF-8 bytes.
Trait Implementations§
Source§impl Clone for Attributes
impl Clone for Attributes
Source§impl Debug for Attributes
impl Debug for Attributes
Source§impl Default for Attributes
impl Default for Attributes
Source§impl<'de> Deserialize<'de> for Attributes
impl<'de> Deserialize<'de> for Attributes
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Attributes
Source§impl From<Attributes> for BTreeMap<AttributeKey, AttributeValue>
impl From<Attributes> for BTreeMap<AttributeKey, AttributeValue>
Source§fn from(attributes: Attributes) -> Self
fn from(attributes: Attributes) -> Self
Converts to this type from the input type.
Source§impl PartialEq for Attributes
impl PartialEq for Attributes
Source§impl Serialize for Attributes
impl Serialize for Attributes
impl StructuralPartialEq for Attributes
Source§impl TryFrom<BTreeMap<AttributeKey, AttributeValue>> for Attributes
impl TryFrom<BTreeMap<AttributeKey, AttributeValue>> for Attributes
Source§type Error = AttributesError
type Error = AttributesError
The type returned in the event of a conversion error.
Source§fn try_from(
entries: BTreeMap<AttributeKey, AttributeValue>,
) -> Result<Self, Self::Error>
fn try_from( entries: BTreeMap<AttributeKey, AttributeValue>, ) -> Result<Self, Self::Error>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for Attributes
impl RefUnwindSafe for Attributes
impl Send for Attributes
impl Sync for Attributes
impl Unpin for Attributes
impl UnsafeUnpin for Attributes
impl UnwindSafe for Attributes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more