diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-09-22 00:05:53 +0200 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2020-09-22 00:05:53 +0200 |
commit | 6a94c70a2224212e2310927aec7b512d562ee455 (patch) | |
tree | 6d205fbee84f2786abb00c1da5c7b2549e39f260 /src/config.rs | |
parent | 5df790a77a8c81b58e7507e8da5d9ac4975a64f8 (diff) | |
download | nitrokey-rs-6a94c70a2224212e2310927aec7b512d562ee455.tar.gz nitrokey-rs-6a94c70a2224212e2310927aec7b512d562ee455.tar.bz2 |
Rename *lock fields of the Config structnext
libnitrokey calls the configuration fields that set bindings for the Num
Lock, Caps Lock and Scroll Lock keys numlock, capslock, scrolllock. Due
to a typo, scrolllock with three l was renamed to scrollock with two l
in nitrokey-rs.
To make the field names easier to read (and type) and consistent with
the typical names for these keys, this patch changes them to num_lock,
caps_lock and scroll_lock. In the doc comments, we now use the spelling
“Num Lock”, “Caps Lock” and “Scroll Lock”.
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/config.rs b/src/config.rs index 120a51b..bc935d7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,15 +8,15 @@ use crate::error::{Error, LibraryError}; /// The configuration for a Nitrokey. #[derive(Clone, Copy, Debug, PartialEq)] pub struct Config { - /// If set, the stick will generate a code from the HOTP slot with the given number if numlock + /// If set, the stick will generate a code from the HOTP slot with the given number if Num Lock /// is pressed. The slot number must be 0, 1 or 2. - pub numlock: Option<u8>, - /// If set, the stick will generate a code from the HOTP slot with the given number if capslock - /// is pressed. The slot number must be 0, 1 or 2. - pub capslock: Option<u8>, - /// If set, the stick will generate a code from the HOTP slot with the given number if - /// scrollock is pressed. The slot number must be 0, 1 or 2. - pub scrollock: Option<u8>, + pub num_lock: Option<u8>, + /// If set, the stick will generate a code from the HOTP slot with the given number if Caps + /// Lock is pressed. The slot number must be 0, 1 or 2. + pub caps_lock: Option<u8>, + /// If set, the stick will generate a code from the HOTP slot with the given number if Scroll + /// Lock is pressed. The slot number must be 0, 1 or 2. + pub scroll_lock: Option<u8>, /// If set, OTP generation using [`get_hotp_code`][] or [`get_totp_code`][] requires user /// authentication. Otherwise, OTPs can be generated without authentication. /// @@ -27,9 +27,9 @@ pub struct Config { #[derive(Debug)] pub struct RawConfig { - pub numlock: u8, - pub capslock: u8, - pub scrollock: u8, + pub num_lock: u8, + pub caps_lock: u8, + pub scroll_lock: u8, pub user_password: bool, } @@ -56,15 +56,15 @@ fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, Error> { impl Config { /// Constructs a new instance of this struct. pub fn new( - numlock: Option<u8>, - capslock: Option<u8>, - scrollock: Option<u8>, + num_lock: Option<u8>, + caps_lock: Option<u8>, + scroll_lock: Option<u8>, user_password: bool, ) -> Config { Config { - numlock, - capslock, - scrollock, + num_lock, + caps_lock, + scroll_lock, user_password, } } @@ -75,9 +75,9 @@ impl convert::TryFrom<Config> for RawConfig { fn try_from(config: Config) -> Result<RawConfig, Error> { Ok(RawConfig { - numlock: option_to_config_otp_slot(config.numlock)?, - capslock: option_to_config_otp_slot(config.capslock)?, - scrollock: option_to_config_otp_slot(config.scrollock)?, + num_lock: option_to_config_otp_slot(config.num_lock)?, + caps_lock: option_to_config_otp_slot(config.caps_lock)?, + scroll_lock: option_to_config_otp_slot(config.scroll_lock)?, user_password: config.user_password, }) } @@ -86,9 +86,9 @@ impl convert::TryFrom<Config> for RawConfig { impl From<&nitrokey_sys::NK_status> for RawConfig { fn from(status: &nitrokey_sys::NK_status) -> Self { Self { - numlock: status.config_numlock, - capslock: status.config_capslock, - scrollock: status.config_scrolllock, + num_lock: status.config_numlock, + caps_lock: status.config_capslock, + scroll_lock: status.config_scrolllock, user_password: status.otp_user_password, } } @@ -97,9 +97,9 @@ impl From<&nitrokey_sys::NK_status> for RawConfig { impl Into<Config> for RawConfig { fn into(self) -> Config { Config { - numlock: config_otp_slot_to_option(self.numlock), - capslock: config_otp_slot_to_option(self.capslock), - scrollock: config_otp_slot_to_option(self.scrollock), + num_lock: config_otp_slot_to_option(self.num_lock), + caps_lock: config_otp_slot_to_option(self.caps_lock), + scroll_lock: config_otp_slot_to_option(self.scroll_lock), user_password: self.user_password, } } |