aboutsummaryrefslogtreecommitdiff
path: root/src/otp.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-28 14:24:12 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-02-02 10:25:02 +0000
commit0972bbe82623c3d9649b6023d8f50d304aa0cde6 (patch)
tree5f9c2a3cd1981ae2b04cd07ba466f2a8d8f74f0c /src/otp.rs
parentf49e61589e32217f97c94aa86d826f6b65170fba (diff)
downloadnitrokey-rs-0972bbe82623c3d9649b6023d8f50d304aa0cde6.tar.gz
nitrokey-rs-0972bbe82623c3d9649b6023d8f50d304aa0cde6.tar.bz2
Refactor User and Admin to use a mutable reference
In the initial nitrokey-rs implementation, the Admin and the User struct take the Device by value to make sure that the user cannot initiate a second authentication while this first is still active (which would invalidate the temporary password). Now we realized that this is not necessary – taking a mutable reference has the same effect, but leads to a much cleaner API. This patch refactors the Admin and User structs – and all dependent code – to use a mutable reference instead of a Device value.
Diffstat (limited to 'src/otp.rs')
-rw-r--r--src/otp.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/otp.rs b/src/otp.rs
index ee142c7..a8dd20b 100644
--- a/src/otp.rs
+++ b/src/otp.rs
@@ -35,7 +35,7 @@ pub trait ConfigureOtp {
/// # use nitrokey::Error;
///
/// # fn try_main() -> Result<(), Error> {
- /// let device = nitrokey::connect()?;
+ /// let mut device = nitrokey::connect()?;
/// let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::SixDigits);
/// match device.authenticate_admin("12345678") {
/// Ok(mut admin) => {
@@ -44,7 +44,7 @@ pub trait ConfigureOtp {
/// Err(err) => eprintln!("Could not write slot: {}", err),
/// }
/// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
+ /// Err(err) => eprintln!("Could not authenticate as admin: {}", err),
/// }
/// # Ok(())
/// # }
@@ -71,7 +71,7 @@ pub trait ConfigureOtp {
/// # use nitrokey::Error;
///
/// # fn try_main() -> Result<(), Error> {
- /// let device = nitrokey::connect()?;
+ /// let mut device = nitrokey::connect()?;
/// let slot_data = OtpSlotData::new(1, "test", "01234567890123456689", OtpMode::EightDigits);
/// match device.authenticate_admin("12345678") {
/// Ok(mut admin) => {
@@ -80,7 +80,7 @@ pub trait ConfigureOtp {
/// Err(err) => eprintln!("Could not write slot: {}", err),
/// }
/// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
+ /// Err(err) => eprintln!("Could not authenticate as admin: {}", err),
/// }
/// # Ok(())
/// # }
@@ -104,7 +104,7 @@ pub trait ConfigureOtp {
/// # use nitrokey::Error;
///
/// # fn try_main() -> Result<(), Error> {
- /// let device = nitrokey::connect()?;
+ /// let mut device = nitrokey::connect()?;
/// match device.authenticate_admin("12345678") {
/// Ok(mut admin) => {
/// match admin.erase_hotp_slot(1) {
@@ -112,7 +112,7 @@ pub trait ConfigureOtp {
/// Err(err) => eprintln!("Could not erase slot: {}", err),
/// }
/// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
+ /// Err(err) => eprintln!("Could not authenticate as admin: {}", err),
/// }
/// # Ok(())
/// # }
@@ -134,7 +134,7 @@ pub trait ConfigureOtp {
/// # use nitrokey::Error;
///
/// # fn try_main() -> Result<(), Error> {
- /// let device = nitrokey::connect()?;
+ /// let mut device = nitrokey::connect()?;
/// match device.authenticate_admin("12345678") {
/// Ok(mut admin) => {
/// match admin.erase_totp_slot(1) {
@@ -142,7 +142,7 @@ pub trait ConfigureOtp {
/// Err(err) => eprintln!("Could not erase slot: {}", err),
/// }
/// },
- /// Err((_, err)) => eprintln!("Could not authenticate as admin: {}", err),
+ /// Err(err) => eprintln!("Could not authenticate as admin: {}", err),
/// }
/// # Ok(())
/// # }