pub struct Attribute {
pub name: String,
pub datatype: Datatype,
pub shape: Vec<u64>,
pub raw_data: Vec<u8>,
}Expand description
A parsed, high-level HDF5 attribute.
Fields§
§name: String§datatype: Datatype§shape: Vec<u64>§raw_data: Vec<u8>Implementations§
Source§impl Attribute
impl Attribute
Sourcepub fn from_message(msg: AttributeMessage) -> Self
pub fn from_message(msg: AttributeMessage) -> Self
Create from a parsed attribute message.
Sourcepub fn from_message_with_context(
msg: AttributeMessage,
file_data: Option<&[u8]>,
offset_size: u8,
) -> Self
pub fn from_message_with_context( msg: AttributeMessage, file_data: Option<&[u8]>, offset_size: u8, ) -> Self
Create from a parsed attribute message with optional file context for resolving variable-length byte attributes stored in the global heap.
Sourcepub fn num_elements(&self) -> u64
pub fn num_elements(&self) -> u64
Total number of elements.
Sourcepub fn read_scalar<T: H5Type>(&self) -> Result<T>
pub fn read_scalar<T: H5Type>(&self) -> Result<T>
Read the attribute value as a scalar of the given type.
Sourcepub fn read_1d<T: H5Type>(&self) -> Result<Vec<T>>
pub fn read_1d<T: H5Type>(&self) -> Result<Vec<T>>
Read the attribute as a 1-D vector of the given type.
Sourcepub fn read_string(&self) -> Result<String>
pub fn read_string(&self) -> Result<String>
Read the attribute as a string (for string-typed attributes).
For variable-length strings, use read_vlen_string() with the file data
and offset_size — this method will return an error directing you there.
Sourcepub fn read_vlen_string(
&self,
file_data: &[u8],
offset_size: u8,
) -> Result<String>
pub fn read_vlen_string( &self, file_data: &[u8], offset_size: u8, ) -> Result<String>
Read a variable-length string attribute from the global heap.
Variable-length strings in HDF5 are stored as references into a global
heap collection. Each reference is: seq_len(u32) + heap_addr(offset_size) + index(u32).
Sourcepub fn read_vlen_strings(
&self,
file_data: &[u8],
offset_size: u8,
) -> Result<Vec<String>>
pub fn read_vlen_strings( &self, file_data: &[u8], offset_size: u8, ) -> Result<Vec<String>>
Read an array of variable-length strings from the global heap.
Sourcepub fn read_strings(&self) -> Result<Vec<String>>
pub fn read_strings(&self) -> Result<Vec<String>>
Read the attribute as a vector of strings.
Sourcepub fn read_as_f64(&self) -> Result<f64>
pub fn read_as_f64(&self) -> Result<f64>
Read an attribute as f64 (with automatic promotion from int types).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Attribute
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnsafeUnpin for Attribute
impl UnwindSafe for Attribute
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more