aboutsummaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-07-14 22:00:13 +0200
committerRobin Krahl <robin.krahl@ireas.org>2020-07-14 22:00:13 +0200
commit3810761847717676d91900c422d9c8b634f56d77 (patch)
tree0974cefb5662b5bf37b1d27c17ce73e07a126dc1 /src/device
parenta3dd6afb8c23c8975737d1484e152d530a975c11 (diff)
parent8f72f038cab8e61fb162c12c4bd4cbaa243faa2d (diff)
downloadnitrokey-rs-3810761847717676d91900c422d9c8b634f56d77.tar.gz
nitrokey-rs-3810761847717676d91900c422d9c8b634f56d77.tar.bz2
Merge branch 'release-0.7.0'
Diffstat (limited to 'src/device')
-rw-r--r--src/device/mod.rs7
-rw-r--r--src/device/pro.rs2
-rw-r--r--src/device/storage.rs2
3 files changed, 2 insertions, 9 deletions
diff --git a/src/device/mod.rs b/src/device/mod.rs
index 067fdf6..c84faa1 100644
--- a/src/device/mod.rs
+++ b/src/device/mod.rs
@@ -10,8 +10,6 @@ use std::ffi;
use std::fmt;
use std::str;
-use nitrokey_sys;
-
use crate::auth::Authenticate;
use crate::config::{Config, RawConfig};
use crate::error::{CommunicationError, Error, LibraryError};
@@ -225,9 +223,8 @@ fn get_hidapi_serial_number(serial_number: &str) -> Option<SerialNumber> {
return None;
}
- let iter = serial_number.char_indices().rev();
- let first_non_null = iter.skip_while(|(_, c)| *c == '0').next();
- if let Some((i, _)) = first_non_null {
+ let mut iter = serial_number.char_indices().rev();
+ if let Some((i, _)) = iter.find(|(_, c)| *c != '0') {
let substr = if len - i < 8 {
// The last eight characters contain at least one non-zero character --> use them
serial_number.split_at(len - 8).1
diff --git a/src/device/pro.rs b/src/device/pro.rs
index 591b730..0d5443e 100644
--- a/src/device/pro.rs
+++ b/src/device/pro.rs
@@ -1,8 +1,6 @@
// Copyright (C) 2018-2019 Robin Krahl <robin.krahl@ireas.org>
// SPDX-License-Identifier: MIT
-use nitrokey_sys;
-
use crate::device::{Device, Model, Status};
use crate::error::Error;
use crate::otp::GenerateOtp;
diff --git a/src/device/storage.rs b/src/device/storage.rs
index 5669a91..a18d94f 100644
--- a/src/device/storage.rs
+++ b/src/device/storage.rs
@@ -5,8 +5,6 @@ use std::convert::TryFrom as _;
use std::fmt;
use std::ops;
-use nitrokey_sys;
-
use crate::device::{Device, FirmwareVersion, Model, SerialNumber, Status};
use crate::error::{CommandError, Error};
use crate::otp::GenerateOtp;