Skip to main content

H5Group

Struct H5Group 

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

A handle to an HDF5 group.

Groups are containers for datasets and other groups. The root group is always available via H5File::root_group.

Implementations§

Source§

impl H5Group

Source

pub fn name(&self) -> &str

Return the name (path) of this group.

Source

pub fn new_dataset<T: H5Type>(&self) -> DatasetBuilder<T>

Start building a new dataset in this group.

The dataset will be registered as a child of this group in the HDF5 file hierarchy.

Source

pub fn create_group(&self, name: &str) -> Result<H5Group>

Create a sub-group within this group.

Creates a real HDF5 group with its own object header.

Create a hard link in this group: an additional name link_name for the object that already exists at target_path.

No data is copied — the link and its target share one object, just as h5py / libhdf5 hard links do. target_path may be given with or without a leading / and must name an existing dataset or group. This is the NeXus-style way to expose a dataset at a second canonical location (e.g. /entry/data/data) without duplicating it.

use rust_hdf5::H5File;

let file = H5File::create("nexus.h5").unwrap();
let inst = file.root_group().create_group("instrument").unwrap();
inst.new_dataset::<f32>().shape(&[10]).create("data").unwrap();
let data = file.root_group().create_group("data").unwrap();
// /data/data is now a hard link to /instrument/data — no copy.
data.link("data", "/instrument/data").unwrap();
Source

pub fn group(&self, name: &str) -> Result<H5Group>

Open an existing sub-group by name (read mode).

Source

pub fn dataset_names(&self) -> Result<Vec<String>>

List dataset names that are direct children of this group.

Source

pub fn write_vlen_strings( &self, name: &str, strings: &[&str], ) -> Result<H5Dataset>

Create a variable-length string dataset and write data within this group.

Returns a writer-mode handle to the created dataset so attributes can be attached to it (e.g. units, descriptions) just like a dataset created via new_dataset.

Source

pub fn write_vlen_bytes(&self, name: &str, items: &[&[u8]]) -> Result<H5Dataset>

Create a variable-length byte-array dataset and write data within this group.

Each &[u8] becomes one element of variable length, stored as a vlen sequence of u8. h5py reads it back as an array of uint8 arrays. Returns a writer-mode handle so attributes can be attached, like write_vlen_strings.

Source

pub fn write_vlen_strings_compressed( &self, name: &str, strings: &[&str], chunk_size: usize, pipeline: FilterPipeline, ) -> Result<H5Dataset>

Create a chunked, compressed variable-length string dataset within this group.

Returns a writer-mode handle to the created dataset so attributes can be attached to it, like write_vlen_strings.

Source

pub fn create_appendable_vlen_dataset( &self, name: &str, chunk_size: usize, pipeline: Option<FilterPipeline>, ) -> Result<H5Dataset>

Create an empty chunked vlen string dataset ready for incremental appends.

Returns a writer-mode handle to the created dataset so attributes can be attached before or between append_vlen_strings calls.

Source

pub fn append_vlen_strings(&self, name: &str, strings: &[&str]) -> Result<()>

Append variable-length strings to an existing chunked vlen string dataset.

Source

pub fn dataset_writer(&self, name: &str) -> Result<H5Dataset>

Reopen a writer-mode handle to a dataset in this group by name.

Mirrors H5File::dataset_writer but resolves name relative to this group, so a dataset created here (including via the vlen-string helpers) can be reopened to attach attributes or append chunks. name is the link name within this group.

Source

pub fn group_names(&self) -> Result<Vec<String>>

List sub-group names that are direct children of this group.

Source

pub fn set_attr_string(&self, name: &str, value: &str) -> Result<()>

Add (or replace) a string attribute on this group.

This is the standard way to mark a NeXus class, e.g. grp.set_attr_string("NX_class", "NXdetector"). The value is stored as a variable-length UTF-8 string (read back as a Python str by h5py), not a fixed-length string.

Source

pub fn set_attr_numeric<T: H5Type>(&self, name: &str, value: &T) -> Result<()>

Add (or replace) a numeric scalar attribute on this group.

Source

pub fn set_attr_array_numeric<T: H5Type>( &self, name: &str, values: &[T], ) -> Result<()>

Add (or replace) a numeric (or bool) array attribute on this group.

The values are written as a 1-D HDF5 array attribute (simple dataspace [values.len()]), read back by h5py as a numpy array — the array counterpart of set_attr_numeric. For a multi-dimensional shape use set_attr_array_numeric_nd.

Source

pub fn set_attr_array_numeric_nd<T: H5Type>( &self, name: &str, values: &[T], shape: &[usize], ) -> Result<()>

Add (or replace) a numeric (or bool) N-dimensional array attribute on this group.

shape gives the dataspace dimensions; values is the row-major data and its length must equal the product of shape (an empty shape is a scalar, requiring exactly one value). Read back by h5py as a numpy array of that shape. set_attr_array_numeric is the 1-D convenience form.

Source

pub fn set_attr_string_array(&self, name: &str, values: &[&str]) -> Result<()>

Add (or replace) a variable-length UTF-8 string array attribute on this group, read back by h5py as a 1-D array of str — the array counterpart of set_attr_string. For a multi-dimensional shape use set_attr_string_array_nd.

Source

pub fn set_attr_string_array_nd( &self, name: &str, values: &[&str], shape: &[usize], ) -> Result<()>

Add (or replace) a variable-length UTF-8 string N-dimensional array attribute on this group.

shape gives the dataspace dimensions; values is the row-major data and its length must equal the product of shape (an empty shape is a scalar, requiring exactly one value). Read back by h5py as a numpy array of Python str with that shape. set_attr_string_array is the 1-D convenience form.

Source

pub fn attr_names(&self) -> Result<Vec<String>>

List this group’s attribute names (read mode).

Source

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

Read one of this group’s attributes as a string (read mode).

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