Trait DeviceManager

Source
pub trait DeviceManager {
    // Required methods
    fn enumerate_device_name(&self, presented_only: bool) -> Result<Vec<String>>;
    fn device_state(&self, device_name: &str) -> Result<u32>;
    fn wait_plug_event(&self) -> Result<Option<PluginEvent>>;
    fn cancel_wait_plug_event(&self) -> Result<()>;
    fn connect(&self, device_name: &str) -> Result<Box<dyn SkfDevice>>;
    fn connect_selected(
        &self,
        selector: fn(Vec<&str>) -> Option<&str>,
    ) -> Result<Box<dyn SkfDevice>>;
}

Required Methods§

Source

fn enumerate_device_name(&self, presented_only: bool) -> Result<Vec<String>>

Enumerate all devices

[presented_only] - Enumerate only presented devices,false means list all supported devices by underlying driver

Source

fn device_state(&self, device_name: &str) -> Result<u32>

Get device state

[device_name] - The device name

§state value
Source

fn wait_plug_event(&self) -> Result<Option<PluginEvent>>

Wait for plug event,This function will block current thread

If error happens, Error will be returned,otherwise Some(PluginEvent) will be returned

Ok(None) means no event

Source

fn cancel_wait_plug_event(&self) -> Result<()>

Cancel wait for plug event

Source

fn connect(&self, device_name: &str) -> Result<Box<dyn SkfDevice>>

Connect device with device name

[device_name] - The device name

Source

fn connect_selected( &self, selector: fn(Vec<&str>) -> Option<&str>, ) -> Result<Box<dyn SkfDevice>>

Connect to device by enumerate all devices and select one,if no device matches the selector, None will be returned

[selector] - The device selector,if device list is not empty, the selector will be invoked to select one

§error
  • Error::NotFound returned means there is no device to connect,or the selector returns None

Implementors§