Skip to main content

SwmrFileWriter

Struct SwmrFileWriter 

Source
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

Source

pub fn create<P: AsRef<Path>>(path: P) -> Result<Self>

Create a new HDF5 file for SWMR streaming.

Source

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.

Source

pub fn start_swmr(&mut self) -> Result<()>

Signal the start of SWMR mode.

Source

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

Source

pub fn flush(&mut self) -> Result<()>

Flush all dataset index structures to disk with SWMR ordering.

Source

pub fn close(self) -> Result<()>

Close and finalize the file.

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.