aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-20 20:58:18 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-20 21:08:20 +0000
commit94390aadc8a3997d379bf5e4c0bc00c2a9669a34 (patch)
treea22cb82e8d6450ad034230d77e2db6605e54df8b /src/config.rs
parentdb198936be1a80f1735731d9e95eb6f4c48a5329 (diff)
downloadnitrokey-rs-94390aadc8a3997d379bf5e4c0bc00c2a9669a34.tar.gz
nitrokey-rs-94390aadc8a3997d379bf5e4c0bc00c2a9669a34.tar.bz2
Return Error instead of CommandError
This patch changes all public functions to return the Error enum instead of the CommandError enum. This breaks the tests which will be fixed with the next patch. This patch also adds a placeholder variant Error::CommandError and a placeholder enum CommandError to make the transition to a new nitrokey-test version easier.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/config.rs b/src/config.rs
index 277dc5e..741d67e 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,4 +1,4 @@
-use crate::error::CommandError;
+use crate::error::{CommandError, Error};
/// The configuration for a Nitrokey.
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -35,13 +35,13 @@ fn config_otp_slot_to_option(value: u8) -> Option<u8> {
None
}
-fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, CommandError> {
+fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, Error> {
match value {
Some(value) => {
if value < 3 {
Ok(value)
} else {
- Err(CommandError::InvalidSlot)
+ Err(CommandError::InvalidSlot.into())
}
}
None => Ok(255),
@@ -66,7 +66,7 @@ impl Config {
}
impl RawConfig {
- pub fn try_from(config: Config) -> Result<RawConfig, CommandError> {
+ pub 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)?,