diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-09-25 02:06:00 +0200 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2020-10-11 14:58:35 -0700 |
commit | 6fce98ec044241abd1d0f54dca307af6cd9f648f (patch) | |
tree | 1c184d6f5d04ab2e2729c7b33c9a2be089c41684 /src/args.rs | |
parent | dc99d8ffabcd51bc549981998c5d53b1fba789e9 (diff) | |
download | nitrocli-6fce98ec044241abd1d0f54dca307af6cd9f648f.tar.gz nitrocli-6fce98ec044241abd1d0f54dca307af6cd9f648f.tar.bz2 |
Update nitrokey to v0.8.0
This patch updates the nitrokey dependency to version 0.8.0 and applies
all breaking changes (Config fields renaming, DeviceWrapper and Model
non-exhaustiveness, changed Display implementation for Model).
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs index 8af38ca..e4bc77d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -3,6 +3,8 @@ // Copyright (C) 2020 The Nitrocli Developers // SPDX-License-Identifier: GPL-3.0-or-later +use std::convert; + /// Provides access to a Nitrokey device #[derive(Debug, structopt::StructOpt)] #[structopt(name = "nitrocli")] @@ -59,6 +61,18 @@ impl From<DeviceModel> for nitrokey::Model { } } +impl convert::TryFrom<nitrokey::Model> for DeviceModel { + type Error = anyhow::Error; + + fn try_from(model: nitrokey::Model) -> Result<DeviceModel, anyhow::Error> { + match model { + nitrokey::Model::Pro => Ok(DeviceModel::Pro), + nitrokey::Model::Storage => Ok(DeviceModel::Storage), + _ => Err(anyhow::anyhow!("Unsupported device model: {}", model)), + } + } +} + impl<'de> serde::Deserialize<'de> for DeviceModel { fn deserialize<D>(deserializer: D) -> Result<DeviceModel, D::Error> where |