From f035857d9a9dc14c85e6bdf22cbe72528235657d Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 7 Jun 2018 03:03:29 +0200 Subject: Use Result<(), CommandError> instead of CommandStatus The Result enum is more idiomatic and easier to use than our custom CommandStatus enum with the same structure. This is especially true for the try operator ?. --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 432ce4e..aa44706 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,7 +37,7 @@ //! Configure an HOTP slot: //! //! ```no_run -//! use nitrokey::{Authenticate, CommandStatus, ConfigureOtp, OtpMode, OtpSlotData}; +//! use nitrokey::{Authenticate, ConfigureOtp, OtpMode, OtpSlotData}; //! # use nitrokey::CommandError; //! //! # fn try_main() -> Result<(), (CommandError)> { @@ -46,8 +46,8 @@ //! match device.authenticate_admin("12345678") { //! Ok(admin) => { //! match admin.write_hotp_slot(slot_data, 0) { -//! CommandStatus::Success => println!("Successfully wrote slot."), -//! CommandStatus::Error(err) => println!("Could not write slot: {:?}", err), +//! Ok(()) => println!("Successfully wrote slot."), +//! Err(err) => println!("Could not write slot: {:?}", err), //! } //! }, //! Err((_, err)) => println!("Could not authenticate as admin: {:?}", err), @@ -102,7 +102,7 @@ pub use config::Config; pub use device::{connect, Device, DeviceWrapper, Pro, Storage}; pub use otp::{ConfigureOtp, GenerateOtp, OtpMode, OtpSlotData}; pub use pws::{GetPasswordSafe, PasswordSafe, SLOT_COUNT}; -pub use util::{CommandError, CommandStatus, LogLevel}; +pub use util::{CommandError, LogLevel}; /// Enables or disables debug output. Calling this method with `true` is equivalent to setting the /// log level to `Debug`; calling it with `false` is equivalent to the log level `Error` (see -- cgit v1.2.1