aboutsummaryrefslogtreecommitdiff
path: root/src/device.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/device.rs')
-rw-r--r--src/device.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/device.rs b/src/device.rs
index 51551c2..653c5d1 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -647,15 +647,9 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp + fmt::Debug {
/// ```
///
/// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
+#[deprecated(since = "0.4.0", note = "use `nitrokey::Manager::connect` instead")]
pub fn connect() -> Result<DeviceWrapper, Error> {
- if unsafe { nitrokey_sys::NK_login_auto() } == 1 {
- match get_connected_device() {
- Some(wrapper) => Ok(wrapper),
- None => Err(CommunicationError::NotConnected.into()),
- }
- } else {
- Err(CommunicationError::NotConnected.into())
- }
+ crate::take()?.connect().map_err(Into::into)
}
/// Connects to a Nitrokey device of the given model.
@@ -702,7 +696,7 @@ fn create_device_wrapper(model: Model) -> DeviceWrapper {
}
}
-fn get_connected_device() -> Option<DeviceWrapper> {
+pub(crate) fn get_connected_device() -> Option<DeviceWrapper> {
get_connected_model().map(create_device_wrapper)
}