Skip to main content

Dataset

Struct Dataset 

Source
pub struct Dataset<'f> { /* private fields */ }
Expand description

A lightweight handle to an HDF5 dataset.

Implementations§

Source§

impl<'f> Dataset<'f>

Source

pub const fn chunk_cache_config(&self) -> ChunkCacheConfig

The effective raw chunk-cache configuration for this dataset.

This reflects the per-dataset DatasetAccessOptions override when one was supplied to File::dataset_with_options / Group::dataset_with_options, otherwise the file-wide default. It is the read-side analogue of HDF5’s H5Pget_chunk_cache.

Source

pub fn chunk_cache_stats(&self) -> ChunkCacheStats

A point-in-time snapshot of this dataset handle’s chunk-cache occupancy.

Lets callers confirm a chunk-cache configuration (set with FileAccessOptions::with_chunk_cache) is taking effect: after a chunked read, an enabled cache reports a loaded index and retained chunks; a disabled one (or one over its budget) reports fewer or none. The cache is per-handle, so a freshly opened Dataset reports an empty snapshot until its first read.

Source

pub fn shape(&self) -> Result<Vec<u64>, Error>

Returns the shape (dimensions) of the dataset.

Source

pub fn dtype(&self) -> Result<DType, Error>

Returns the simplified datatype of the dataset.

Source

pub fn read_f64(&self) -> Result<Vec<f64>, Error>

Read all data as f64 values.

Source

pub fn read_f32(&self) -> Result<Vec<f32>, Error>

Read all data as f32 values.

Source

pub fn read_i32(&self) -> Result<Vec<i32>, Error>

Read all data as i32 values.

Source

pub fn read_i64(&self) -> Result<Vec<i64>, Error>

Read all data as i64 values.

Source

pub fn read_u64(&self) -> Result<Vec<u64>, Error>

Read all data as u64 values.

Source

pub fn read_u8(&self) -> Result<Vec<u8>, Error>

Read all data as u8 values.

Source

pub fn read_i8(&self) -> Result<Vec<i8>, Error>

Read all data as i8 values.

Source

pub fn read_i16(&self) -> Result<Vec<i16>, Error>

Read all data as i16 values.

Source

pub fn read_u16(&self) -> Result<Vec<u16>, Error>

Read all data as u16 values.

Source

pub fn read_u32(&self) -> Result<Vec<u32>, Error>

Read all data as u32 values.

Source

pub fn read_string(&self) -> Result<Vec<String>, Error>

Read all data as String values.

Fixed-length and variable-length HDF5 string datasets are both supported. Use read_vlen_strings when variable-length allocation limits are required.

Source

pub fn vlen_string_payload_size(&self) -> Result<u64, Error>

Return the total bytes referenced by this VL string dataset.

This is the payload equivalent of HDF5’s H5Dvlen_get_buf_size: it excludes Vec<String> and String allocation metadata.

Source

pub fn read_vlen_strings( &self, options: VlenStringReadOptions, ) -> Result<Vec<String>, Error>

Read a VL string dataset with explicit allocation limits.

Both limits are checked before any string payload is materialized.

Source

pub fn visit_vlen_strings<F>( &self, options: VlenStringReadOptions, visitor: F, ) -> Result<(), Error>
where F: FnMut(&str),

Visit a VL string dataset one element at a time.

The string slice passed to visitor is valid only for the duration of that callback. This avoids retaining all decoded string payloads at once.

Source

pub fn attrs(&self) -> Result<HashMap<String, AttrValue>, Error>

Read all attributes of this dataset.

Source

pub fn datatype(&self) -> Result<Datatype, Error>

Returns the exact HDF5 datatype, including compound field offsets and total record size.

Source

pub fn read_raw(&self) -> Result<Vec<u8>, Error>

Read the dataset’s exact unfiltered element bytes.

For compound datasets this preserves all file padding and uses the offsets reported by datatype.

Source

pub fn dereference(&self) -> Result<Vec<Object<'f>>, Error>

Interpret this dataset as an array of HDF5 object references (H5R_OBJECT) and resolve each, in storage order, to the Object it points at.

MATLAB cell arrays and the #subsystem# machinery store their members this way: the dataset holds one object-header address per element, each naming an object elsewhere in the file (conventionally under the hidden #refs# group).

§Errors
Source

pub fn read_compound<T: CompoundType>(&self) -> Result<Vec<T>, Error>

Decode all elements of a compound dataset field by field.

Built-in implementations support numeric tuples with one through twelve fields. Decoding uses the file’s field offsets rather than Rust’s tuple memory layout, so padded compound records are supported safely.

Source§

impl Dataset<'_>

Source

pub fn read<T: H5Element>(&self) -> Result<Vec<T>, Error>

Read the dataset into a Vec<T> for any supported scalar type, in row-major order.

This is the generic counterpart of the type-specific read_* methods (e.g. read_f64). The element type is usually inferred from the binding, so a call site reads as let v: Vec<f64> = ds.read()?;, or you can name it with turbofish: ds.read::<i32>()?.

T is the type you want the elements delivered as, not an assertion about the dataset’s stored type. The stored bytes are coerced into T using the same rules as read_f64 and its siblings, so the conversion can be lossy: reading an f64 dataset as i32 truncates, and reading an i32 dataset as f64 widens. There is no check that T matches the on-disk datatype, so pick T to match the stored type when you need an exact, lossless read.

§Errors

Propagates any error from the underlying typed read (see read_f64).

Trait Implementations§

Source§

impl<'f> Debug for Dataset<'f>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'f> !Freeze for Dataset<'f>

§

impl<'f> !RefUnwindSafe for Dataset<'f>

§

impl<'f> !UnwindSafe for Dataset<'f>

§

impl<'f> Send for Dataset<'f>

§

impl<'f> Sync for Dataset<'f>

§

impl<'f> Unpin for Dataset<'f>

§

impl<'f> UnsafeUnpin for Dataset<'f>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.