summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-23 04:09:26 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-23 05:10:51 +0100
commit5ef83ad507d1e5f51152b20628314936b4fb833c (patch)
tree5299fdc0445f363e870355e5d12053af92561cc1 /src
parent425010284341fcc745072dcd39b9fa398ae8db69 (diff)
downloadnitrokey-rs-5ef83ad507d1e5f51152b20628314936b4fb833c.tar.gz
nitrokey-rs-5ef83ad507d1e5f51152b20628314936b4fb833c.tar.bz2
Implement From<Pro> and From<Storage> for DeviceWrapper
Diffstat (limited to 'src')
-rw-r--r--src/device.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/device.rs b/src/device.rs
index 2abf801..ad75a44 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -707,12 +707,8 @@ fn get_connected_model() -> Option<Model> {
fn create_device_wrapper(model: Model) -> DeviceWrapper {
match model {
- Model::Pro => DeviceWrapper::Pro(Pro {
- marker: marker::PhantomData,
- }),
- Model::Storage => DeviceWrapper::Storage(Storage {
- marker: marker::PhantomData,
- }),
+ Model::Pro => Pro::new().into(),
+ Model::Storage => Storage::new().into(),
}
}
@@ -737,6 +733,18 @@ impl DeviceWrapper {
}
}
+impl From<Pro> for DeviceWrapper {
+ fn from(device: Pro) -> Self {
+ DeviceWrapper::Pro(device)
+ }
+}
+
+impl From<Storage> for DeviceWrapper {
+ fn from(device: Storage) -> Self {
+ DeviceWrapper::Storage(device)
+ }
+}
+
impl GenerateOtp for DeviceWrapper {
fn get_hotp_slot_name(&self, slot: u8) -> Result<String, Error> {
self.device().get_hotp_slot_name(slot)