pub struct SinkController {
pub handler: Handler,
}
Fields§
§handler: Handler
Implementations§
Source§impl SinkController
impl SinkController
Sourcepub fn create() -> Result<Self, ControllerError>
pub fn create() -> Result<Self, ControllerError>
Examples found in repository?
examples/change_device_vol.rs (line 10)
8fn main() {
9 // create handler that calls functions on playback devices and apps
10 let mut handler = SinkController::create().unwrap();
11 let devices = handler
12 .list_devices()
13 .expect("Could not get list of playback devices");
14
15 println!("Playback Devices");
16 for dev in devices.clone() {
17 println!(
18 "[{}] {}, [Volume: {}]",
19 dev.index,
20 dev.description.as_ref().unwrap(),
21 dev.volume.print()
22 );
23 }
24 let mut selection = String::new();
25
26 io::stdin()
27 .read_line(&mut selection)
28 .expect("error: unable to read user input");
29 for dev in devices.clone() {
30 if let true = selection.trim() == dev.index.to_string() {
31 handler.increase_device_volume_by_percent(dev.index, 0.05);
32 }
33 }
34}
pub fn get_server_info(&mut self) -> Result<ServerInfo, ControllerError>
Trait Implementations§
Source§impl AppControl<ApplicationInfo> for SinkController
impl AppControl<ApplicationInfo> for SinkController
fn list_applications(&mut self) -> Result<Vec<ApplicationInfo>, ControllerError>
fn get_app_by_index( &mut self, index: u32, ) -> Result<ApplicationInfo, ControllerError>
fn increase_app_volume_by_percent(&mut self, index: u32, delta: f64)
fn decrease_app_volume_by_percent(&mut self, index: u32, delta: f64)
fn move_app_by_index( &mut self, stream_index: u32, device_index: u32, ) -> Result<bool, ControllerError>
fn move_app_by_name( &mut self, stream_index: u32, device_name: &str, ) -> Result<bool, ControllerError>
fn set_app_mute( &mut self, index: u32, mute: bool, ) -> Result<bool, ControllerError>
Source§impl DeviceControl<DeviceInfo> for SinkController
impl DeviceControl<DeviceInfo> for SinkController
fn get_default_device(&mut self) -> Result<DeviceInfo, ControllerError>
fn set_default_device(&mut self, name: &str) -> Result<bool, ControllerError>
fn list_devices(&mut self) -> Result<Vec<DeviceInfo>, ControllerError>
fn get_device_by_index( &mut self, index: u32, ) -> Result<DeviceInfo, ControllerError>
fn get_device_by_name( &mut self, name: &str, ) -> Result<DeviceInfo, ControllerError>
fn set_device_volume_by_index(&mut self, index: u32, volume: &ChannelVolumes)
fn set_device_volume_by_name(&mut self, name: &str, volume: &ChannelVolumes)
fn set_device_mute_by_index(&mut self, index: u32, mute: bool)
fn set_device_mute_by_name(&mut self, name: &str, mute: bool)
fn increase_device_volume_by_percent(&mut self, index: u32, delta: f64)
fn decrease_device_volume_by_percent(&mut self, index: u32, delta: f64)
Auto Trait Implementations§
impl Freeze for SinkController
impl !RefUnwindSafe for SinkController
impl !Send for SinkController
impl !Sync for SinkController
impl Unpin for SinkController
impl !UnwindSafe for SinkController
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
Mutably borrows from an owned value. Read more