Skip to main content

Hdf5File

Struct Hdf5File 

Source
pub struct Hdf5File { /* private fields */ }
Expand description

An HDF5 file held as a logical graph and (re)serialized to bytes on demand.

Implementations§

Source§

impl Hdf5File

Source

pub fn create() -> Self

Empty file with a root group. Writes superblock version 2 on Self::to_bytes.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Parse a complete HDF5 file image. Returns HDF5Error::InvalidSignature if the format signature is missing.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>>

Serialize to a standard HDF5 superblock-v2 file image.

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open an existing file from a filesystem path.

Errors: HDF5Error::Io, plus every error Self::from_bytes can return.

Source

pub fn create_file<P: AsRef<Path>>(_path: P) -> Result<Self>

Create an empty file object (does not write until Self::save).

Source

pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>

Write the current image to path.

Errors: HDF5Error::Io and encode failures.

Source

pub fn list_datasets(&self) -> Vec<String>

Dataset paths (no leading slash), sorted.

Source

pub fn list_groups(&self) -> Vec<String>

Group paths. Root is "/".

Source

pub fn dataset_shape(&self, path: &str) -> Result<Vec<usize>>

Dataspace dimensions of path.

Errors: HDF5Error::NotFound. Shape is reported for chunked and filtered datasets; reading those still returns a named error.

Source

pub fn dataset_dtype(&self, path: &str) -> Result<HDF5DType>

Datatype of path.

Errors: HDF5Error::NotFound. Chunked datasets still report a type.

Source

pub fn create_group(&mut self, path: &str) -> Result<()>

Create a group. Parent must exist (root always does).

Errors: HDF5Error::NotFound, HDF5Error::NameTooLong.

Source

pub fn write_f64( &mut self, path: &str, shape: &[usize], bits: &[u64], ) -> Result<()>

Write IEEE binary64 little-endian lanes. bits.len() must equal the product of shape (empty shape is a scalar, one element). Rank 0 through HDF5_MAX_DIMS.

Errors: HDF5Error::ShapeMismatch, HDF5Error::RankNotSupported, HDF5Error::NameTooLong.

Source

pub fn write_ieee64( &mut self, path: &str, shape: &[usize], bits: &[u64], ) -> Result<()>

IEEE binary64 little-endian lanes. Same as Self::write_f64.

Named for callers whose sources cannot contain hardware float tokens.

Source

pub fn write_f32( &mut self, path: &str, shape: &[usize], bits: &[u32], ) -> Result<()>

Write IEEE binary32 little-endian lanes.

Errors: same as Self::write_f64.

Source

pub fn write_ieee32( &mut self, path: &str, shape: &[usize], bits: &[u32], ) -> Result<()>

IEEE binary32 little-endian lanes. Same as Self::write_f32.

Source

pub fn write_opaque( &mut self, path: &str, shape: &[usize], elem_size: usize, data: &[u8], ) -> Result<()>

Write opaque records of elem_size bytes. data.len() must equal shape.product() * elem_size.

Errors: same as Self::write_f64.

Source

pub fn write_i8( &mut self, path: &str, shape: &[usize], bits: &[i8], ) -> Result<()>

Write signed 8-bit lanes.

Source

pub fn write_i16( &mut self, path: &str, shape: &[usize], bits: &[i16], ) -> Result<()>

Write signed 16-bit little-endian lanes.

Source

pub fn write_i32( &mut self, path: &str, shape: &[usize], bits: &[i32], ) -> Result<()>

Write signed 32-bit little-endian lanes.

Source

pub fn write_i64( &mut self, path: &str, shape: &[usize], bits: &[i64], ) -> Result<()>

Write signed 64-bit little-endian lanes.

Source

pub fn write_u8( &mut self, path: &str, shape: &[usize], bits: &[u8], ) -> Result<()>

Write unsigned 8-bit lanes.

Source

pub fn write_u16( &mut self, path: &str, shape: &[usize], bits: &[u16], ) -> Result<()>

Write unsigned 16-bit little-endian lanes.

Source

pub fn write_u32( &mut self, path: &str, shape: &[usize], bits: &[u32], ) -> Result<()>

Write unsigned 32-bit little-endian lanes.

Source

pub fn write_u64( &mut self, path: &str, shape: &[usize], bits: &[u64], ) -> Result<()>

Write unsigned 64-bit little-endian lanes.

Source

pub fn read_f64(&self, path: &str) -> Result<(Vec<usize>, Vec<u64>)>

Source

pub fn read_ieee64(&self, path: &str) -> Result<(Vec<usize>, Vec<u64>)>

IEEE binary64 lanes and dataspace shape. Same as Self::read_f64.

Source

pub fn read_f32(&self, path: &str) -> Result<(Vec<usize>, Vec<u32>)>

Read IEEE binary32 lanes and the dataspace shape.

Errors: same as Self::read_f64.

Source

pub fn read_ieee32(&self, path: &str) -> Result<(Vec<usize>, Vec<u32>)>

IEEE binary32 lanes and dataspace shape. Same as Self::read_f32.

Source

pub fn read_opaque(&self, path: &str) -> Result<(Vec<usize>, usize, Vec<u8>)>

Read opaque payload, shape, and element size.

Errors: HDF5Error::NotFound, HDF5Error::ChunkedNotSupported, HDF5Error::TypeMismatch.

Source

pub fn compound_fields(&self, path: &str) -> Result<Vec<CompoundField>>

Compound field layout for path, or empty if not a compound dataset.

Errors: HDF5Error::NotFound.

Source

pub fn read_raw(&self, path: &str) -> Result<(Vec<usize>, usize, Vec<u8>)>

Raw element bytes for any dataset whose storage was materialized (including compound / Other). Does not reinterpret lanes.

Returns (shape, element_size, bytes).

Errors: HDF5Error::NotFound, HDF5Error::ChunkedNotSupported, HDF5Error::FilteredNotSupported.

Source

pub fn read_i8(&self, path: &str) -> Result<(Vec<usize>, Vec<i8>)>

Read signed 8-bit lanes.

Source

pub fn read_i16(&self, path: &str) -> Result<(Vec<usize>, Vec<i16>)>

Read signed 16-bit little-endian lanes.

Source

pub fn read_i32(&self, path: &str) -> Result<(Vec<usize>, Vec<i32>)>

Read signed 32-bit little-endian lanes.

Source

pub fn read_i64(&self, path: &str) -> Result<(Vec<usize>, Vec<i64>)>

Read signed 64-bit little-endian lanes.

Source

pub fn read_u8(&self, path: &str) -> Result<(Vec<usize>, Vec<u8>)>

Read unsigned 8-bit lanes.

Source

pub fn read_u16(&self, path: &str) -> Result<(Vec<usize>, Vec<u16>)>

Read unsigned 16-bit little-endian lanes.

Source

pub fn read_u32(&self, path: &str) -> Result<(Vec<usize>, Vec<u32>)>

Read unsigned 32-bit little-endian lanes.

Source

pub fn read_u64(&self, path: &str) -> Result<(Vec<usize>, Vec<u64>)>

Read unsigned 64-bit little-endian lanes.

Source

pub fn read_f64_slice( &self, path: &str, row_start: usize, row_end: usize, ) -> Result<(Vec<usize>, Vec<u64>)>

Rows [row_start, row_end) along the first axis of an IEEE binary64 dataset.

Errors: HDF5Error::NotFound, HDF5Error::ChunkedNotSupported, HDF5Error::TypeMismatch, HDF5Error::ShapeMismatch.

Source

pub fn append_f64( &mut self, path: &str, shape: &[usize], bits: &[u64], ) -> Result<()>

Append rows to an existing IEEE binary64 dataset. Trailing dimensions must match. Rank-1 appends to the single axis.

Errors: HDF5Error::NotFound, HDF5Error::ShapeMismatch, HDF5Error::TypeMismatch, HDF5Error::ChunkedNotSupported.

Source

pub fn append_ieee64( &mut self, path: &str, shape: &[usize], bits: &[u64], ) -> Result<()>

Append IEEE binary64 rows. Same as Self::append_f64.

Source

pub fn append_f32( &mut self, path: &str, shape: &[usize], bits: &[u32], ) -> Result<()>

Append IEEE binary32 rows.

Source

pub fn append_ieee32( &mut self, path: &str, shape: &[usize], bits: &[u32], ) -> Result<()>

Append IEEE binary32 rows. Same as Self::append_f32.

Source

pub fn append_i32( &mut self, path: &str, shape: &[usize], bits: &[i32], ) -> Result<()>

Append signed 32-bit rows.

Source

pub fn append_u64( &mut self, path: &str, shape: &[usize], bits: &[u64], ) -> Result<()>

Append unsigned 64-bit rows.

Source

pub fn append_opaque( &mut self, path: &str, shape: &[usize], data: &[u8], ) -> Result<()>

Append opaque records. data.len() must equal shape.product() * elem_size of the existing dataset.

Source

pub fn read_attr_str(&self, path: &str, name: &str) -> Result<String>

Read a string attribute on a dataset.

Errors: HDF5Error::NotFound.

Source

pub fn list_attrs(&self, path: &str) -> Result<Vec<(String, String)>>

String attributes on path (name, value), in file order.

Source

pub fn write_attr_str( &mut self, path: &str, name: &str, value: &str, ) -> Result<()>

Write or replace a string attribute on a dataset.

Errors: HDF5Error::NotFound, HDF5Error::NameTooLong.

Trait Implementations§

Source§

impl Clone for Hdf5File

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 Hdf5File

Source§

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

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

impl Default for Hdf5File

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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.