From 9d962e6f16d059fb0ed58e278513a311189772bb Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 12 Jan 2019 15:30:54 +0000 Subject: 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. --- src/device.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/device.rs') 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 -- cgit v1.2.1