pub struct AttributeEntry { /* private fields */ }Expand description
One attribute as an object header holds it: the message, plus the creation index the file records for it.
AttributeMessage::decode fails on a payload this crate cannot model —
an object-reference datatype, say — but the name sits ahead of the datatype
in the message, so such an attribute is still identifiable. Carrying the
unreadable case in the same list is what lets a listing answer “this object
has an attribute named X that I cannot read” instead of answering as though
X were not there.
The creation index is a property of the attribute, exactly as its name is —
H5A_shared_t::crt_idx, stored in the object header message envelope when
the set is compact and in the index records when it is dense. Keeping it
here is what stops a rewrite from re-deriving it from the position an
attribute happens to occupy in a list: a dense set is read back in name-hash
order, so a position-derived index re-stamps the whole set with the order
the hash walk took.
Implementations§
Source§impl AttributeEntry
impl AttributeEntry
Sourcepub fn parse(buf: &[u8], ctx: &FormatContext) -> FormatResult<Self>
pub fn parse(buf: &[u8], ctx: &FormatContext) -> FormatResult<Self>
Parse one attribute message. The entry carries no creation index —
only the envelope or index record it came out of knows one, so the
caller that has it attaches it with
with_creation_index.
Total over every message whose envelope and name parse: a payload this crate cannot decode is named, never an absence. Only a message too damaged to yield a name at all is an error, because there is then no name to report.
Sourcepub fn with_creation_index(self, creation_index: Option<u16>) -> Self
pub fn with_creation_index(self, creation_index: Option<u16>) -> Self
This entry with creation_index attached.
Sourcepub fn set_creation_index(&mut self, creation_index: Option<u16>)
pub fn set_creation_index(&mut self, creation_index: Option<u16>)
Attach creation_index in place.
Sourcepub fn creation_index(&self) -> Option<u16>
pub fn creation_index(&self) -> Option<u16>
The index this attribute was created with, or None when its object
does not track creation order.
Sourcepub fn decoded(&self) -> Result<&AttributeMessage, &str>
pub fn decoded(&self) -> Result<&AttributeMessage, &str>
The decoded message, or the reason there is none — exactly one of the two, so a caller reporting the failure never needs a branch for an attribute that is neither.
Sourcepub fn readable(&self) -> Option<&AttributeMessage>
pub fn readable(&self) -> Option<&AttributeMessage>
The decoded message, or None when only the name is known.
Sourcepub fn unreadable_reason(&self) -> Option<&str>
pub fn unreadable_reason(&self) -> Option<&str>
Why this attribute cannot be read, or None when it can be.
Sourcepub fn encode(&self, ctx: &FormatContext) -> Vec<u8> ⓘ
pub fn encode(&self, ctx: &FormatContext) -> Vec<u8> ⓘ
The message payload to write back into an object header.
An unreadable attribute returns the bytes it was read from: re-encoding is impossible without a decoded form, and dropping it would delete an attribute the caller never asked to change.
Sourcepub fn encode_at(&self, ctx: &FormatContext, libver: LibverBound) -> Vec<u8> ⓘ
pub fn encode_at(&self, ctx: &FormatContext, libver: LibverBound) -> Vec<u8> ⓘ
The same, for a file whose low libver bound is libver: the datatype
message inside a readable attribute follows it. An unreadable one is
bytes, and bytes have no version to choose.
Sourcepub fn encode_for(
&self,
ctx: &FormatContext,
libver: LibverBound,
format: ObjectFormat,
) -> Vec<u8> ⓘ
pub fn encode_for( &self, ctx: &FormatContext, libver: LibverBound, format: ObjectFormat, ) -> Vec<u8> ⓘ
The same, at the message version format calls for.