pub struct SampleReader<R> { /* private fields */ }Expand description
Streams frames of samples out of a Read source.
See SampleWriter for an example.
Implementations§
Source§impl<R: Read> SampleReader<R>
impl<R: Read> SampleReader<R>
Sourcepub fn new(
reader: R,
datatype: Datatype,
channel_count: usize,
) -> Result<Self, SigmfError>
pub fn new( reader: R, datatype: Datatype, channel_count: usize, ) -> Result<Self, SigmfError>
Creates a reader that decodes channel_count-channel frames of
datatype from reader.
§Errors
Returns SigmfError::InvalidMetadata if channel_count is zero or
the frame size overflows.
Sourcepub fn read_frames(
&mut self,
maximum_frames: usize,
) -> Result<Option<Vec<SampleValue>>, SigmfError>
pub fn read_frames( &mut self, maximum_frames: usize, ) -> Result<Option<Vec<SampleValue>>, SigmfError>
Reads and decodes up to maximum_frames frames.
Short and interrupted reads are retried until maximum_frames frames
are available or the source reaches end of input. Returns
Ok(Some(samples)) with between one and maximum_frames frames (one
SampleValue per channel per frame), or Ok(None) once the source is
exhausted. A buffer for maximum_frames frames is allocated on each
call.
§Errors
Returns SigmfError::InvalidRange if maximum_frames is zero,
SigmfError::ResourceLimit if the block size overflows,
SigmfError::InvalidMetadata if the source ends with an incomplete
frame, or SigmfError::Io if reading fails.
Auto Trait Implementations§
impl<R> Freeze for SampleReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for SampleReader<R>where
R: RefUnwindSafe,
impl<R> Send for SampleReader<R>where
R: Send,
impl<R> Sync for SampleReader<R>where
R: Sync,
impl<R> Unpin for SampleReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for SampleReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for SampleReader<R>where
R: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more