pub struct Dataset<'f> { /* private fields */ }Expand description
A lightweight handle to an HDF5 dataset.
Implementations§
Source§impl<'f> Dataset<'f>
impl<'f> Dataset<'f>
Sourcepub const fn chunk_cache_config(&self) -> ChunkCacheConfig
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.
Sourcepub fn chunk_cache_stats(&self) -> ChunkCacheStats
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.
Sourcepub fn read_string(&self) -> Result<Vec<String>, Error>
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.
Sourcepub fn vlen_string_payload_size(&self) -> Result<u64, Error>
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.
Sourcepub fn read_vlen_strings(
&self,
options: VlenStringReadOptions,
) -> Result<Vec<String>, Error>
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.
Sourcepub fn visit_vlen_strings<F>(
&self,
options: VlenStringReadOptions,
visitor: F,
) -> Result<(), Error>
pub fn visit_vlen_strings<F>( &self, options: VlenStringReadOptions, visitor: F, ) -> Result<(), Error>
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.
Sourcepub fn attrs(&self) -> Result<HashMap<String, AttrValue>, Error>
pub fn attrs(&self) -> Result<HashMap<String, AttrValue>, Error>
Read all attributes of this dataset.
Sourcepub fn datatype(&self) -> Result<Datatype, Error>
pub fn datatype(&self) -> Result<Datatype, Error>
Returns the exact HDF5 datatype, including compound field offsets and total record size.
Sourcepub fn read_raw(&self) -> Result<Vec<u8>, Error>
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.
Sourcepub fn dereference(&self) -> Result<Vec<Object<'f>>, Error>
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
FormatError::TypeMismatchif this dataset’s datatype is not an object reference.FormatError::InvalidObjectReferenceif an element is a null or undefined reference, or does not point at a group or dataset.
Sourcepub fn read_compound<T: CompoundType>(&self) -> Result<Vec<T>, Error>
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<'_>
impl Dataset<'_>
Sourcepub fn read<T: H5Element>(&self) -> Result<Vec<T>, Error>
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).