pub struct SwmrFileWriter { /* private fields */ }Expand description
SWMR writer for streaming frame-based data to an HDF5 file.
Usage:
use rust_hdf5::swmr::SwmrFileWriter;
let mut writer = SwmrFileWriter::create("stream.h5").unwrap();
let ds = writer.create_streaming_dataset::<f32>("frames", &[256, 256]).unwrap();
writer.start_swmr().unwrap();
// Write frames
let frame_data = vec![0.0f32; 256 * 256];
let raw: Vec<u8> = frame_data.iter()
.flat_map(|v| v.to_le_bytes())
.collect();
writer.append_frame(ds, &raw).unwrap();
writer.flush().unwrap();
writer.close().unwrap();Implementations§
Source§impl SwmrFileWriter
impl SwmrFileWriter
Sourcepub fn create<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn create<P: AsRef<Path>>(path: P) -> Result<Self>
Create a new HDF5 file for SWMR streaming.
Sourcepub fn create_streaming_dataset<T: H5Type>(
&mut self,
name: &str,
frame_dims: &[u64],
) -> Result<usize>
pub fn create_streaming_dataset<T: H5Type>( &mut self, name: &str, frame_dims: &[u64], ) -> Result<usize>
Create a streaming dataset.
The dataset will have shape [0, frame_dims...] initially, with
chunk dimensions [1, frame_dims...] and unlimited first dimension.
Returns the dataset index for use with append_frame.
Sourcepub fn start_swmr(&mut self) -> Result<()>
pub fn start_swmr(&mut self) -> Result<()>
Signal the start of SWMR mode.
Sourcepub fn append_frame(&mut self, ds_index: usize, data: &[u8]) -> Result<()>
pub fn append_frame(&mut self, ds_index: usize, data: &[u8]) -> Result<()>
Append a frame of raw data to a streaming dataset.
The data size must match one frame (product of frame_dims * element_size).
Auto Trait Implementations§
impl Freeze for SwmrFileWriter
impl RefUnwindSafe for SwmrFileWriter
impl Send for SwmrFileWriter
impl Sync for SwmrFileWriter
impl Unpin for SwmrFileWriter
impl UnsafeUnpin for SwmrFileWriter
impl UnwindSafe for SwmrFileWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more