aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs52
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,
}
}