summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2021-03-27 16:10:53 +0100
committerRobin Krahl <robin.krahl@ireas.org>2021-03-27 16:10:53 +0100
commit434e61c231e142b6f5f8d81eb25f4ef97686d85a (patch)
treedb884ec48a50772e29b99cc42ff6b0cca4a79228 /examples
downloadnitrokey-hid-434e61c231e142b6f5f8d81eb25f4ef97686d85a.tar.gz
nitrokey-hid-434e61c231e142b6f5f8d81eb25f4ef97686d85a.tar.bz2
Initial commitHEADmaster
Diffstat (limited to 'examples')
-rw-r--r--examples/list.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/list.rs b/examples/list.rs
new file mode 100644
index 0000000..ee59ceb
--- /dev/null
+++ b/examples/list.rs
@@ -0,0 +1,21 @@
+use nitrokey_hid::features::Basic;
+
+fn main() -> Result<(), nitrokey_hid::Error> {
+ let device = nitrokey_hid::connect()?;
+ let status = device.get_status()?;
+ println!(
+ r#"Status:
+ model: {model:?}
+ serial number: 0x{id:08x}
+ firmware version: {fwv_maj}.{fwv_min}
+ user retry count: {urc}
+ admin retry count: {arc}"#,
+ model = device.get_model(),
+ id = status.serial_number,
+ fwv_maj = status.firmware_version_major,
+ fwv_min = status.firmware_version_minor,
+ urc = device.get_user_retry_count()?,
+ arc = device.get_admin_retry_count()?,
+ );
+ Ok(())
+}