From 9015fcd2593467af128ca4114c3ff02952d1c93b Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sun, 6 Jan 2019 23:16:52 +0000 Subject: Document the Undefined error for the connect methods --- src/device.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 { 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 { // 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 { // TODO: maybe Option instead of Result? match connect_model(Model::Storage) { -- cgit v1.2.3