Skip to main content

AttributeEntry

Struct AttributeEntry 

Source
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

Source

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.

Source

pub fn with_creation_index(self, creation_index: Option<u16>) -> Self

This entry with creation_index attached.

Source

pub fn set_creation_index(&mut self, creation_index: Option<u16>)

Attach creation_index in place.

Source

pub fn creation_index(&self) -> Option<u16>

The index this attribute was created with, or None when its object does not track creation order.

Source

pub fn name(&self) -> &str

The attribute’s name, whether or not its payload decoded.

Source

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.

Source

pub fn readable(&self) -> Option<&AttributeMessage>

The decoded message, or None when only the name is known.

Source

pub fn unreadable_reason(&self) -> Option<&str>

Why this attribute cannot be read, or None when it can be.

Source

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.

Source

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.

Source

pub fn encode_for( &self, ctx: &FormatContext, libver: LibverBound, format: ObjectFormat, ) -> Vec<u8> ⓘ

The same, at the message version format calls for.

Trait Implementations§

Source§

impl Clone for AttributeEntry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AttributeEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<AttributeMessage> for AttributeEntry

Source§

fn from(attr: AttributeMessage) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for AttributeEntry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AttributeEntry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.