From 77ff522ba2ebee17eb56f52921f127fba2fbd7fb Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 10 Jan 2019 23:15:41 +0000 Subject: 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 for nitrokey::Model to be able to convert our model enum to nitrokey's model enum. --- nitrocli/src/args.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nitrocli/src/args.rs') diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs index 6f02832..246490e 100644 --- a/nitrocli/src/args.rs +++ b/nitrocli/src/args.rs @@ -64,6 +64,15 @@ Enum! {DeviceModel, [ Storage => "storage" ]} +impl From for nitrokey::Model { + fn from(model: DeviceModel) -> nitrokey::Model { + match model { + DeviceModel::Pro => nitrokey::Model::Pro, + DeviceModel::Storage => nitrokey::Model::Storage, + } + } +} + /// A top-level command for nitrocli. Enum! {Command, [ Config => "config", -- cgit v1.2.1