pub trait Decodable: Send + Sync + 'static {
type DecoderItem: Sample + Send + Sync;
type Decoder: Source<Item = Self::DecoderItem> + Send + Iterator;
// Required method
fn decoder(&self) -> Self::Decoder;
}Expand description
A type implementing this trait can be converted to a rodio::Source type.
It must be Send and Sync in order to be registered.
Types that implement this trait usually contain raw sound data that can be converted into an iterator of samples.
This trait is implemented for AudioSource.
Check the example decodable for how to implement this trait on a custom type.
Required Associated Types§
sourcetype DecoderItem: Sample + Send + Sync
type DecoderItem: Sample + Send + Sync
The type of the audio samples.
Usually a u16, i16 or f32, as those implement rodio::Sample.
Other types can implement the rodio::Sample trait as well.
sourcetype Decoder: Source<Item = Self::DecoderItem> + Send + Iterator
type Decoder: Source<Item = Self::DecoderItem> + Send + Iterator
The type of the iterator of the audio samples,
which iterates over samples of type Self::DecoderItem.
Must be a rodio::Source so that it can provide information on the audio it is iterating over.
Required Methods§
sourcefn decoder(&self) -> Self::Decoder
fn decoder(&self) -> Self::Decoder
Build and return a Self::Decoder of the implementing type