aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/device.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/device.rs b/src/device.rs
index 31e14a9..dfc5de1 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -583,6 +583,10 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp {
/// Connects to a Nitrokey device. This method can be used to connect to any connected device,
/// both a Nitrokey Pro and a Nitrokey Storage.
///
+/// # Errors
+///
+/// - [`Undefined`][] if no Nitrokey device is connected
+///
/// # Example
///
/// ```
@@ -595,6 +599,8 @@ pub trait Device: Authenticate + GetPasswordSafe + GenerateOtp {
/// Err(err) => println!("Could not connect to a Nitrokey: {}", err),
/// }
/// ```
+///
+/// [`Undefined`]: enum.CommandError.html#variant.Undefined
pub fn connect() -> Result<DeviceWrapper, CommandError> {
unsafe {
match nitrokey_sys::NK_login_auto() {
@@ -675,6 +681,10 @@ impl Device for DeviceWrapper {
impl Pro {
/// Connects to a Nitrokey Pro.
///
+ /// # Errors
+ ///
+ /// - [`Undefined`][] if no Nitrokey device of the given model is connected
+ ///
/// # Example
///
/// ```
@@ -687,6 +697,8 @@ impl Pro {
/// Err(err) => println!("Could not connect to the Nitrokey Pro: {}", err),
/// }
/// ```
+ ///
+ /// [`Undefined`]: enum.CommandError.html#variant.Undefined
pub fn connect() -> Result<Pro, CommandError> {
// TODO: maybe Option instead of Result?
match connect_model(Model::Pro) {
@@ -715,6 +727,10 @@ impl GenerateOtp for Pro {}
impl Storage {
/// Connects to a Nitrokey Storage.
///
+ /// # Errors
+ ///
+ /// - [`Undefined`][] if no Nitrokey device of the given model is connected
+ ///
/// # Example
///
/// ```
@@ -727,6 +743,8 @@ impl Storage {
/// Err(err) => println!("Could not connect to the Nitrokey Storage: {}", err),
/// }
/// ```
+ ///
+ /// [`Undefined`]: enum.CommandError.html#variant.Undefined
pub fn connect() -> Result<Storage, CommandError> {
// TODO: maybe Option instead of Result?
match connect_model(Model::Storage) {