Skip to main content

DeviceEnumerator

Struct DeviceEnumerator 

Source
pub struct DeviceEnumerator { /* private fields */ }
Expand description

Struct wrapping an IMMDeviceEnumerator

Implementations§

Source§

impl DeviceEnumerator

Source

pub fn new() -> Result<DeviceEnumerator, WasapiError>

Create a new DeviceEnumerator

Source

pub fn get_device_collection( &self, direction: &Direction, ) -> Result<DeviceCollection, WasapiError>

Get an [IMMDeviceCollection] of all active playback or capture devices

Source

pub fn get_default_device( &self, direction: &Direction, ) -> Result<Device, WasapiError>

Get the default playback or capture device for the console role

Source

pub fn get_default_device_for_role( &self, direction: &Direction, role: &Role, ) -> Result<Device, WasapiError>

Get the default playback or capture device for a specific role

Source

pub fn get_device(&self, device_id: &str) -> Result<Device, WasapiError>

Get the device of a given Id. The Id can be obtained by calling Device::get_id()

Source

pub fn register_notification_callback( &self, callbacks: DeviceEventCallbacks, ) -> Result<DeviceEventRegistration, WasapiError>

Register to receive notifications when audio endpoint devices are added or removed, when the state or properties of a device change, or when a different device becomes the default. Returns a DeviceEventRegistration struct. The notifications are unregistered when this struct is dropped. Make sure to store the DeviceEventRegistration in a variable that remains in scope for as long as the event notifications are needed.

The function takes ownership of the provided DeviceEventCallbacks.

The callbacks are called from a thread owned by the Windows audio system. They should return quickly, and must not call back into the DeviceEnumerator that they were registered on.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.