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
impl H5Group
Sourcepub fn new_dataset<T: H5Type>(&self) -> DatasetBuilder<T>
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.
Sourcepub fn create_group(&self, name: &str) -> Result<H5Group>
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.
Sourcepub fn link(&self, link_name: &str, target_path: &str) -> Result<()>
pub fn link(&self, link_name: &str, target_path: &str) -> Result<()>
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();Sourcepub fn group(&self, name: &str) -> Result<H5Group>
pub fn group(&self, name: &str) -> Result<H5Group>
Open an existing sub-group by name (read mode).
Sourcepub fn dataset_names(&self) -> Result<Vec<String>>
pub fn dataset_names(&self) -> Result<Vec<String>>
List dataset names that are direct children of this group.
Sourcepub fn write_vlen_strings(
&self,
name: &str,
strings: &[&str],
) -> Result<H5Dataset>
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.
Sourcepub fn write_vlen_bytes(&self, name: &str, items: &[&[u8]]) -> Result<H5Dataset>
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.
Sourcepub fn write_vlen_strings_compressed(
&self,
name: &str,
strings: &[&str],
chunk_size: usize,
pipeline: FilterPipeline,
) -> Result<H5Dataset>
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.
Sourcepub fn create_appendable_vlen_dataset(
&self,
name: &str,
chunk_size: usize,
pipeline: Option<FilterPipeline>,
) -> Result<H5Dataset>
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.
Sourcepub fn append_vlen_strings(&self, name: &str, strings: &[&str]) -> Result<()>
pub fn append_vlen_strings(&self, name: &str, strings: &[&str]) -> Result<()>
Append variable-length strings to an existing chunked vlen string dataset.
Sourcepub fn dataset_writer(&self, name: &str) -> Result<H5Dataset>
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.
Sourcepub fn group_names(&self) -> Result<Vec<String>>
pub fn group_names(&self) -> Result<Vec<String>>
List sub-group names that are direct children of this group.
Sourcepub fn set_attr_string(&self, name: &str, value: &str) -> Result<()>
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.
Sourcepub fn set_attr_numeric<T: H5Type>(&self, name: &str, value: &T) -> Result<()>
pub fn set_attr_numeric<T: H5Type>(&self, name: &str, value: &T) -> Result<()>
Add (or replace) a numeric scalar attribute on this group.
Sourcepub fn set_attr_array_numeric<T: H5Type>(
&self,
name: &str,
values: &[T],
) -> Result<()>
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.
Sourcepub fn set_attr_string_array(&self, name: &str, values: &[&str]) -> Result<()>
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.
Sourcepub fn attr_names(&self) -> Result<Vec<String>>
pub fn attr_names(&self) -> Result<Vec<String>>
List this group’s attribute names (read mode).
Sourcepub fn attr_string(&self, name: &str) -> Result<String>
pub fn attr_string(&self, name: &str) -> Result<String>
Read one of this group’s attributes as a string (read mode).