From 6a94c70a2224212e2310927aec7b512d562ee455 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 22 Sep 2020 00:05:53 +0200 Subject: Rename *lock fields of the Config struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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”. --- src/config.rs | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'src/config.rs') 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, - /// 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, - /// 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, + pub num_lock: Option, + /// 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, + /// 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, /// 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) -> Result { impl Config { /// Constructs a new instance of this struct. pub fn new( - numlock: Option, - capslock: Option, - scrollock: Option, + num_lock: Option, + caps_lock: Option, + scroll_lock: Option, user_password: bool, ) -> Config { Config { - numlock, - capslock, - scrollock, + num_lock, + caps_lock, + scroll_lock, user_password, } } @@ -75,9 +75,9 @@ impl convert::TryFrom for RawConfig { fn try_from(config: Config) -> Result { 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 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 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, } } -- cgit v1.2.1