pub struct Attributes(/* private fields */);Expand description
A validated attribute map for one inode.
Construction and decoding both enforce the same limits: a map holds at
most MAX_ATTRIBUTE_ENTRIES entries, each value is at most
MAX_ATTRIBUTE_VALUE_BYTES UTF-8 bytes, and the whole map is at most
MAX_ATTRIBUTES_TOTAL_BYTES logical UTF-8 bytes. The total counts key
bytes and value bytes and nothing else, so it does not depend on the
encoding the map is written in. Durable state that breaks a limit fails to
decode rather than decoding to something smaller.
An empty map is valid. It is the cleared state, and clearing an inode’s attributes is a real update with its own revision.
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§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 more