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§
Sourcefn enumerate_device_name(&self, presented_only: bool) -> Result<Vec<String>>
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
Sourcefn device_state(&self, device_name: &str) -> Result<u32>
fn device_state(&self, device_name: &str) -> Result<u32>
Sourcefn wait_plug_event(&self) -> Result<Option<PluginEvent>>
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
Sourcefn cancel_wait_plug_event(&self) -> Result<()>
fn cancel_wait_plug_event(&self) -> Result<()>
Cancel wait for plug event
Sourcefn connect(&self, device_name: &str) -> Result<Box<dyn SkfDevice>>
fn connect(&self, device_name: &str) -> Result<Box<dyn SkfDevice>>
Connect device with device name
[device_name] - The device name
Sourcefn connect_selected(
&self,
selector: fn(Vec<&str>) -> Option<&str>,
) -> Result<Box<dyn SkfDevice>>
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