diff options
Diffstat (limited to 'src/device.rs')
-rw-r--r-- | src/device.rs | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/device.rs b/src/device.rs index d24bf51..277218e 100644 --- a/src/device.rs +++ b/src/device.rs @@ -140,9 +140,8 @@ pub struct Admin<T: Device> { /// This trait provides the commands that can be executed without authentication and that are /// present on all supported Nitrokey devices. pub trait Device: GenerateOtp { - /// Sets the time on the Nitrokey. This command may set the time to - /// arbitrary values. `time` is the number of seconds since January 1st, - /// 1970 (Unix timestamp). + /// Sets the time on the Nitrokey. This command may set the time to arbitrary values. `time` + /// is the number of seconds since January 1st, 1970 (Unix timestamp). /// /// The time is used for TOTP generation (see [`get_totp_code`][]). /// @@ -177,8 +176,8 @@ pub trait Device: GenerateOtp { unsafe { CommandStatus::from(nitrokey_sys::NK_totp_set_time(time)) } } - /// Returns the serial number of the Nitrokey device. The serial number - /// is the string representation of a hex number. + /// Returns the serial number of the Nitrokey device. The serial number is the string + /// representation of a hex number. /// /// # Example /// @@ -199,8 +198,8 @@ pub trait Device: GenerateOtp { unsafe { result_from_string(nitrokey_sys::NK_device_serial_number()) } } - /// Returns the number of remaining authentication attempts for the user. The - /// total number of available attempts is three. + /// Returns the number of remaining authentication attempts for the user. The total number of + /// available attempts is three. /// /// # Example /// @@ -219,8 +218,8 @@ pub trait Device: GenerateOtp { unsafe { nitrokey_sys::NK_get_user_retry_count() } } - /// Returns the number of remaining authentication attempts for the admin. The - /// total number of available attempts is three. + /// Returns the number of remaining authentication attempts for the admin. The total number of + /// available attempts is three. /// /// # Example /// @@ -261,8 +260,7 @@ pub trait Device: GenerateOtp { unsafe { nitrokey_sys::NK_get_major_firmware_version() } } - /// Returns the minor part of the firmware version (for example 8 for - /// version 0.8). + /// Returns the minor part of the firmware version (for example 8 for version 0.8). /// /// # Example /// @@ -401,8 +399,8 @@ trait AuthenticatedDevice<T> { fn new(device: T, temp_password: Vec<u8>) -> Self; } -/// Connects to a Nitrokey device. This method can be used to connect to any -/// connected device, both a Nitrokey Pro and a Nitrokey Storage. +/// Connects to a Nitrokey device. This method can be used to connect to any connected device, +/// both a Nitrokey Pro and a Nitrokey Storage. /// /// # Example /// @@ -579,18 +577,17 @@ impl<T: Device + 'static> AsRef<Device> for User<T> { } impl<T: Device> User<T> { - /// Forgets the user authentication and returns an unauthenticated - /// device. This method consumes the authenticated device. It does not - /// perform any actual commands on the Nitrokey. + /// Forgets the user authentication and returns an unauthenticated device. This method + /// consumes the authenticated device. It does not perform any actual commands on the + /// Nitrokey. pub fn device(self) -> T { self.device } } impl<T: Device> GenerateOtp for User<T> { - /// Generates an HOTP code on the given slot. This operation may not - /// require user authorization, depending on the device configuration (see - /// [`get_config`][]). + /// Generates an HOTP code on the given slot. This operation may not require user + /// authorization, depending on the device configuration (see [`get_config`][]). /// /// # Errors /// @@ -626,12 +623,11 @@ impl<T: Device> GenerateOtp for User<T> { } } - /// Generates a TOTP code on the given slot. This operation may not - /// require user authorization, depending on the device configuration (see - /// [`get_config`][]). + /// Generates a TOTP code on the given slot. This operation may not require user + /// authorization, depending on the device configuration (see [`get_config`][]). /// - /// To make sure that the Nitrokey’s time is in sync, consider calling - /// [`set_time`][] before calling this method. + /// To make sure that the Nitrokey’s time is in sync, consider calling [`set_time`][] before + /// calling this method. /// /// # Errors /// @@ -697,9 +693,9 @@ impl<T: Device + 'static> AsRef<Device> for Admin<T> { } impl<T: Device> Admin<T> { - /// Forgets the user authentication and returns an unauthenticated - /// device. This method consumes the authenticated device. It does not - /// perform any actual commands on the Nitrokey. + /// Forgets the user authentication and returns an unauthenticated device. This method + /// consumes the authenticated device. It does not perform any actual commands on the + /// Nitrokey. pub fn device(self) -> T { self.device } @@ -708,8 +704,7 @@ impl<T: Device> Admin<T> { /// /// # Errors /// - /// - [`InvalidSlot`][] if the provided numlock, capslock or scrolllock - /// slot is larger than two + /// - [`InvalidSlot`][] if the provided numlock, capslock or scrolllock slot is larger than two /// /// # Example /// |