diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-10 23:15:41 +0000 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-26 22:04:29 -0800 |
commit | 77ff522ba2ebee17eb56f52921f127fba2fbd7fb (patch) | |
tree | f818d6b2441cb3c735e92bee5f63a377ec38a7eb /nitrocli/src/commands.rs | |
parent | fbb307551de0d26e612d1b00f386ccf45d84b066 (diff) | |
download | nitrocli-77ff522ba2ebee17eb56f52921f127fba2fbd7fb.tar.gz nitrocli-77ff522ba2ebee17eb56f52921f127fba2fbd7fb.tar.bz2 |
Refactor get_device to use nitrokey::connect_model
nitrokey 0.3.1 introduced the connect_model function that connects to a
specific model given by an enum variant and returns a DeviceWrapper.
This new function allows us to remove the manual selection of a
connection method from the get_device function. We only have to
implement From<DeviceModel> for nitrokey::Model to be able to convert
our model enum to nitrokey's model enum.
Diffstat (limited to 'nitrocli/src/commands.rs')
-rw-r--r-- | nitrocli/src/commands.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index ed3c2c4..b37f9c5 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -59,12 +59,7 @@ fn get_device(ctx: &mut args::ExecCtx<'_>) -> Result<nitrokey::DeviceWrapper> { set_log_level(ctx); match ctx.model { - Some(model) => match model { - args::DeviceModel::Pro => nitrokey::Pro::connect().map(nitrokey::DeviceWrapper::Pro), - args::DeviceModel::Storage => { - nitrokey::Storage::connect().map(nitrokey::DeviceWrapper::Storage) - } - }, + Some(model) => nitrokey::connect_model(model.into()), None => nitrokey::connect(), } .map_err(|_| Error::Error("Nitrokey device not found".to_string())) |