aboutsummaryrefslogtreecommitdiff
path: root/src/device.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-12 15:30:54 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-12 18:15:43 +0100
commit9d962e6f16d059fb0ed58e278513a311189772bb (patch)
tree324a8f917a6988ed3eacebb2ec9dd6a9862599f7 /src/device.rs
parent87e742b4746e1dc261825f0ca87c64a1ea454b1d (diff)
downloadnitrokey-rs-9d962e6f16d059fb0ed58e278513a311189772bb.tar.gz
nitrokey-rs-9d962e6f16d059fb0ed58e278513a311189772bb.tar.bz2
Introduce VolumeMode enum in device
The VolumeMode enum will be used when setting the access mode for the unencrypted volume. It can also be used when refactoring the VolumeStatus enum in a future release.
Diffstat (limited to 'src/device.rs')
-rw-r--r--src/device.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/device.rs b/src/device.rs
index e047975..792ac2f 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -33,6 +33,24 @@ impl fmt::Display for Model {
}
}
+/// The access mode of a volume on the Nitrokey Storage.
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub enum VolumeMode {
+ /// A read-only volume.
+ ReadOnly,
+ /// A read-write volume.
+ ReadWrite,
+}
+
+impl fmt::Display for VolumeMode {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match *self {
+ VolumeMode::ReadOnly => f.write_str("read-only"),
+ VolumeMode::ReadWrite => f.write_str("read-write"),
+ }
+ }
+}
+
/// A wrapper for a Nitrokey device of unknown type.
///
/// Use the function [`connect`][] to obtain a wrapped instance. The wrapper implements all traits