summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-11 13:51:04 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-11 14:54:54 +0100
commitdef4c3cc3cdffc966eeca3b58605da0e7fe12cca (patch)
tree72444978c865c3f49687fbb0534fdbf962f0c844
parentd2f9e204aacc13c6205a3d0f1022d4fd17073a7b (diff)
downloadnitrokey-rs-def4c3cc3cdffc966eeca3b58605da0e7fe12cca.tar.gz
nitrokey-rs-def4c3cc3cdffc966eeca3b58605da0e7fe12cca.tar.bz2
Add the wink method to the Storage struct
This patch adds the wink method to the Storage struct that lets the Nitrokey device blink until reconnected. We do not test this method as it does not change the state that we can observe.
-rw-r--r--CHANGELOG.md3
-rw-r--r--TODO.md1
-rw-r--r--src/device.rs6
3 files changed, 7 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6d561d..b475168 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
# Unreleased
- Make three additional error codes known: `CommandError::StringTooLong`,
`CommandError::InvalidHexString` and `CommandError::TargetBufferTooSmall`.
-- Add the `get_library_version` method to query the libnitrokey version.
+- Add the `get_library_version` function to query the libnitrokey version.
+- Add the `wink` method to the `Storage` struct.
# v0.3.1 (2019-01-07)
- Use `nitrokey-test` to select and execute the unit tests.
diff --git a/TODO.md b/TODO.md
index 110b9a2..2fc40d3 100644
--- a/TODO.md
+++ b/TODO.md
@@ -17,7 +17,6 @@
- `NK_connect_with_ID`
- `NK_get_device_model`
- `NK_get_storage_production_info`
- - `NK_wink`
- Fix timing issues with the `totp_no_pin` and `totp_pin` test cases.
- Clear passwords from memory.
- Find a nicer syntax for the `write_config` test.
diff --git a/src/device.rs b/src/device.rs
index 2eee08e..e047975 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -89,7 +89,6 @@ impl fmt::Display for Model {
/// ```
///
/// [`connect`]: fn.connect.html
-// TODO: add example for Storage-specific code
#[derive(Debug)]
pub enum DeviceWrapper {
/// A Nitrokey Storage device.
@@ -1102,6 +1101,11 @@ impl Storage {
let result = get_command_result(raw_result);
result.and(Ok(StorageStatus::from(raw_status)))
}
+
+ /// Blinks the red and green LED alternatively and infinitely until the device is reconnected.
+ pub fn wink(&self) -> Result<(), CommandError> {
+ get_command_result(unsafe { nitrokey_sys::NK_wink() })
+ }
}
impl Drop for Storage {