pub trait AudioDevice {
type Error: Error;
// Required methods
fn name(&self) -> Cow<'_, str>;
fn device_type(&self) -> DeviceType;
fn channel_map(&self) -> impl IntoIterator<Item = Channel<'_>>;
fn is_config_supported(&self, config: &StreamConfig) -> bool;
fn enumerate_configurations(
&self,
) -> Option<impl IntoIterator<Item = StreamConfig>>;
}
Expand description
Trait for types describing audio devices. Audio devices have zero or more inputs and outputs, and depending on the driver, can be duplex devices which can provide both of them at the same time natively.
Required Associated Types§
Required Methods§
Sourcefn device_type(&self) -> DeviceType
fn device_type(&self) -> DeviceType
Device type. Either input, output, or duplex.
Sourcefn channel_map(&self) -> impl IntoIterator<Item = Channel<'_>>
fn channel_map(&self) -> impl IntoIterator<Item = Channel<'_>>
Iterator of the available channels in this device. Channel indices are used when specifying which channels to open when creating an audio stream.
Sourcefn is_config_supported(&self, config: &StreamConfig) -> bool
fn is_config_supported(&self, config: &StreamConfig) -> bool
Not all configuration values make sense for a particular device, and this method tests a configuration to see if it can be used in an audio stream.
Sourcefn enumerate_configurations(
&self,
) -> Option<impl IntoIterator<Item = StreamConfig>>
fn enumerate_configurations( &self, ) -> Option<impl IntoIterator<Item = StreamConfig>>
Enumerate all possible configurations this device supports. If that is not provided by
the device, and not easily generated manually, this will return None
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.