M CHANGELOG.md => CHANGELOG.md +2 -0
@@ 11,6 11,8 @@ SPDX-License-Identifier: CC0-1.0
- Rename the `numlock`, `capslock`, `scrollock` fields of the `Config` struct
to `num_lock`, `caps_lock`, `scroll_lock`.
- Update the `nitrokey-sys` dependency to v3.6.0.
+ - Use `NK_device_serial_number_as_u32` instead of `NK_device_serial_number`
+ in `Device::get_serial_number`.
# v0.7.1 (2020-08-30)
- Remove the custom `std::error::Error::source` implementation for
M TODO.md => TODO.md +0 -1
@@ 14,7 14,6 @@ SPDX-License-Identifier: CC0-1.0
- New structures:
- `NK_config`
- New functions:
- - `NK_device_serial_number_as_u32`
- `NK_write_config_struct`
- `NK_free_config`
- `NK_read_config_struct`
M src/device/mod.rs => src/device/mod.rs +3 -6
@@ 15,9 15,7 @@ use crate::config::{Config, RawConfig};
use crate::error::{CommunicationError, Error, LibraryError};
use crate::otp::GenerateOtp;
use crate::pws::GetPasswordSafe;
-use crate::util::{
- get_command_result, get_cstring, owned_str_from_ptr, result_or_error, run_with_string,
-};
+use crate::util::{get_command_result, get_cstring, owned_str_from_ptr, result_or_error};
pub use pro::Pro;
pub use storage::{
@@ 375,9 373,8 @@ pub trait Device<'a>: Authenticate<'a> + GetPasswordSafe<'a> + GenerateOtp + fmt
/// # }
/// ```
fn get_serial_number(&self) -> Result<SerialNumber, Error> {
- run_with_string(unsafe { nitrokey_sys::NK_device_serial_number() }, |s| {
- s.parse()
- })
+ let serial_number = unsafe { nitrokey_sys::NK_device_serial_number_as_u32() };
+ result_or_error(SerialNumber::new(serial_number))
}
/// Returns the number of remaining authentication attempts for the user. The total number of