aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 817ee0a..1548950 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -329,30 +329,6 @@ static TEMPORARY_PASSWORD_LENGTH: usize = 25;
/// [`get_hotp_code`]: #method.get_hotp_code
/// [`get_totp_code`]: #method.get_totp_code
pub trait Device {
- /// Closes the connection to this device. This method consumes the device.
- ///
- /// # Example
- ///
- /// ```no_run
- /// use nitrokey::Device;
- /// # use nitrokey::CommandError;
- ///
- /// # fn try_main() -> Result<(), CommandError> {
- /// let device = nitrokey::connect()?;
- /// // perform tasks ...
- /// device.disconnect();
- /// # Ok(())
- /// # }
- /// ```
- fn disconnect(self)
- where
- Self: std::marker::Sized,
- {
- unsafe {
- nitrokey_sys::NK_logout();
- }
- }
-
/// Sets the time on the Nitrokey. This command may set the time to
/// arbitrary values. `time` is the number of seconds since January 1st,
/// 1970 (Unix timestamp).
@@ -1110,6 +1086,12 @@ impl UnauthenticatedDevice {
}
}
+impl Drop for UnauthenticatedDevice {
+ fn drop(&mut self) {
+ unsafe { nitrokey_sys::NK_logout(); }
+ }
+}
+
impl Device for UnauthenticatedDevice {}
impl UserAuthenticatedDevice {