pub struct SwmrFileReader { /* private fields */ }Expand description
SWMR reader for monitoring a streaming HDF5 file.
Opens a file being written by a concurrent SwmrFileWriter and
periodically calls refresh to pick up new data.
use rust_hdf5::swmr::SwmrFileReader;
let mut reader = SwmrFileReader::open("stream.h5").unwrap();
loop {
reader.refresh().unwrap();
let names = reader.dataset_names();
if let Some(shape) = reader.dataset_shape("frames").ok() {
println!("frames shape: {:?}", shape);
if shape[0] > 0 {
let data = reader.read_dataset_raw("frames").unwrap();
println!("got {} bytes", data.len());
break;
}
}
std::thread::sleep(std::time::Duration::from_millis(100));
}Implementations§
Source§impl SwmrFileReader
impl SwmrFileReader
Sourcepub fn refresh(&mut self) -> Result<()>
pub fn refresh(&mut self) -> Result<()>
Re-read the superblock and dataset metadata from disk.
Call this periodically to pick up new data written by the concurrent SWMR writer.
Sourcepub fn dataset_names(&self) -> Vec<String>
pub fn dataset_names(&self) -> Vec<String>
Return the names of all datasets.
Sourcepub fn dataset_shape(&self, name: &str) -> Result<Vec<u64>>
pub fn dataset_shape(&self, name: &str) -> Result<Vec<u64>>
Return the current shape of a dataset.
Auto Trait Implementations§
impl Freeze for SwmrFileReader
impl RefUnwindSafe for SwmrFileReader
impl Send for SwmrFileReader
impl Sync for SwmrFileReader
impl Unpin for SwmrFileReader
impl UnsafeUnpin for SwmrFileReader
impl UnwindSafe for SwmrFileReader
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