From 248f8b209b0150e70e82ab15b73bf32b0f47341d Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 3 Jan 2019 00:23:13 +0000 Subject: Remove CommandError::RngError We switched to rand::thread_rng() which cannot fail. Therefore the CommandError::RngError is no longer needed and removed in this patch. --- src/util.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/util.rs') diff --git a/src/util.rs b/src/util.rs index a2e957e..ccec5e6 100644 --- a/src/util.rs +++ b/src/util.rs @@ -35,8 +35,6 @@ pub enum CommandError { InvalidString, /// You passed an invalid slot. InvalidSlot, - /// An error occured during random number generation. - RngError, } /// Log level for libnitrokey. @@ -99,10 +97,10 @@ pub fn get_last_error() -> CommandError { }; } -pub fn generate_password(length: usize) -> std::io::Result> { +pub fn generate_password(length: usize) -> Vec { let mut data = vec![0u8; length]; rand::thread_rng().fill(&mut data[..]); - return Ok(data); + return data; } pub fn get_cstring>>(s: T) -> Result { @@ -127,7 +125,6 @@ impl fmt::Display for CommandError { CommandError::Unknown => "An unknown error occured", CommandError::InvalidString => "You passed a string containing a null byte", CommandError::InvalidSlot => "The given slot is invalid", - CommandError::RngError => "An error occured during random number generation", }; write!(f, "{}", msg) } -- cgit v1.2.1