pub trait Source {
// Required methods
fn format(&self) -> PcmFormat;
fn total_frames(&self) -> Option<u64>;
fn read(&mut self, out: &mut [i16]) -> Result<usize, Error>;
// Provided method
fn rewind_to(&mut self, frame: u64) -> Result<(), Error> { ... }
}Expand description
Something that yields whole frames on request, as a decoder working through a file does. A caller decides how much it holds at once: a read never fills more than the buffer it is given.
Required Methods§
Sourcefn total_frames(&self) -> Option<u64>
fn total_frames(&self) -> Option<u64>
How many frames it yields from its start, if that is known without decoding.
Sourcefn read(&mut self, out: &mut [i16]) -> Result<usize, Error>
fn read(&mut self, out: &mut [i16]) -> Result<usize, Error>
Fills out with the next whole frames, interleaved, and says how many
frames that was. 0 means it has ended. Short of the end it gives at
least one, and a buffer without room for one is Error::NoRoom.
A source that mustn’t keep its reader waiting gives Error::Underrun when
it has no frame ready yet.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".