[−][src]Function nitrokey::list_devices
pub fn list_devices() -> Result<Vec<DeviceInfo>, Error>
List all connected Nitrokey devices.
This functions returns a vector with DeviceInfo
structs that contain information about
all connected Nitrokey devices. It will even list unsupported models, although you cannot
connect to them. To connect to a supported model, call the connect_path
function.
Errors
NotConnected
if a Nitrokey device has been disconnected during enumerationUtf8Error
if the USB path or the serial number returned by libnitrokey are invalid UTF-8 strings
Example
let devices = nitrokey::list_devices()?; if devices.is_empty() { println!("No connected Nitrokey devices found."); } else { println!("model\tpath\tserial number"); for device in devices { match device.model { Some(model) => print!("{}", model), None => print!("unsupported"), } print!("\t{}\t", device.path); match device.serial_number { Some(serial_number) => println!("{}", serial_number), None => println!("unknown"), } } }