diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-23 04:02:51 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-01-23 04:02:51 +0000 |
commit | 425010284341fcc745072dcd39b9fa398ae8db69 (patch) | |
tree | 2113f1f26302d8558905dff689f0756d5ba332f6 /src | |
parent | 5540ca5e76ffe5efe27d8819efb9e62066a10219 (diff) | |
download | nitrokey-rs-425010284341fcc745072dcd39b9fa398ae8db69.tar.gz nitrokey-rs-425010284341fcc745072dcd39b9fa398ae8db69.tar.bz2 |
Add Pro::new and Storage::new functions
Diffstat (limited to 'src')
-rw-r--r-- | src/device.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/device.rs b/src/device.rs index 287268b..2abf801 100644 --- a/src/device.rs +++ b/src/device.rs @@ -788,12 +788,16 @@ impl Pro { pub fn connect() -> Result<Pro, Error> { // TODO: maybe Option instead of Result? match connect_enum(Model::Pro) { - true => Ok(Pro { - marker: marker::PhantomData, - }), + true => Ok(Pro::new()), false => Err(CommunicationError::NotConnected.into()), } } + + fn new() -> Pro { + Pro { + marker: marker::PhantomData, + } + } } impl Drop for Pro { @@ -836,13 +840,17 @@ impl Storage { pub fn connect() -> Result<Storage, Error> { // TODO: maybe Option instead of Result? match connect_enum(Model::Storage) { - true => Ok(Storage { - marker: marker::PhantomData, - }), + true => Ok(Storage::new()), false => Err(CommunicationError::NotConnected.into()), } } + fn new() -> Storage { + Storage { + marker: marker::PhantomData, + } + } + /// Changes the update PIN. /// /// The update PIN is used to enable firmware updates. Unlike the user and the admin PIN, the |