aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-12-30 00:04:49 +0100
committerRobin Krahl <robin.krahl@ireas.org>2018-12-30 00:04:49 +0100
commit1c6b4d4dfd498c4127a076c48b6c37e05eaacb62 (patch)
treeacd8c4935c1894a4e26ffd2d6c23a435c07931ec /src
parent62d698db4941c06905cb08bdbe4cc35ad54132d5 (diff)
downloadnitrokey-rs-1c6b4d4dfd498c4127a076c48b6c37e05eaacb62.tar.gz
nitrokey-rs-1c6b4d4dfd498c4127a076c48b6c37e05eaacb62.tar.bz2
Derive Clone and Copy for CommandError, LogLevel, OtpMode
As these three enums are scalar values, this patch derives the Clone and Copy traits for them. This should avoid unnecessary allocations and reduce the memory footprint.
Diffstat (limited to 'src')
-rw-r--r--src/otp.rs2
-rw-r--r--src/util.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/otp.rs b/src/otp.rs
index 801f52c..6f6bd80 100644
--- a/src/otp.rs
+++ b/src/otp.rs
@@ -5,7 +5,7 @@ use nitrokey_sys;
use crate::util::{get_command_result, get_cstring, result_from_string, CommandError};
/// Modes for one-time password generation.
-#[derive(Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OtpMode {
/// Generate one-time passwords with six digits.
SixDigits,
diff --git a/src/util.rs b/src/util.rs
index d98e675..a2e957e 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -6,7 +6,7 @@ use libc::{c_void, free};
use rand::Rng;
/// Error types returned by Nitrokey device or by the library.
-#[derive(Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CommandError {
/// A packet with a wrong checksum has been sent or received.
WrongCrc,
@@ -43,7 +43,7 @@ pub enum CommandError {
///
/// Setting the log level to a lower level enables all output from higher levels too. Currently,
/// only the log levels `Warning`, `DebugL1`, `Debug` and `DebugL2` are actually used.
-#[derive(Debug, PartialEq)]
+#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LogLevel {
/// Error messages. Currently not used.
Error,