aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-30 16:02:49 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-02-02 10:21:25 +0000
commiteef2118717878f3543248ebf2d099aebbedceacf (patch)
treefef3eadac198a21862c856e5aca106c7badc62d0
parente97ccf213eec4e2d056c2f72079e4eeb7ac66f3f (diff)
downloadnitrokey-rs-eef2118717878f3543248ebf2d099aebbedceacf.tar.gz
nitrokey-rs-eef2118717878f3543248ebf2d099aebbedceacf.tar.bz2
Add device_mut method to DeviceWrapper
To prepare the mutability refactoring, we add a device_mut method to DeviceWrapper that can be used to obtain a mutable reference to the wrapped device.
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/device.rs7
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fcba0f3..718b796 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,7 @@ SPDX-License-Identifier: MIT
- Add `set_encrypted_volume_mode` to `Storage`.
- Use mutability to represent changes to the device status:
- Implement `DerefMut` for `User<T>` and `Admin<T>`.
+ - Add `device_mut` method to `DeviceWrapper`.
# v0.3.4 (2019-01-20)
- Fix authentication methods that assumed that `char` is signed.
diff --git a/src/device.rs b/src/device.rs
index c985802..462e9dc 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -728,6 +728,13 @@ impl DeviceWrapper {
DeviceWrapper::Pro(ref pro) => pro,
}
}
+
+ fn device_mut(&mut self) -> &mut dyn Device {
+ match *self {
+ DeviceWrapper::Storage(ref mut storage) => storage,
+ DeviceWrapper::Pro(ref mut pro) => pro,
+ }
+ }
}
impl From<Pro> for DeviceWrapper {