[−][src]Enum nitrokey::DeviceWrapper
A wrapper for a Nitrokey device of unknown type.
Use the connect
method to obtain a wrapped instance. The wrapper implements all traits
that are shared between all Nitrokey devices so that the shared functionality can be used
without knowing the type of the underlying device. If you want to use functionality that is
not available for all devices, you have to extract the device.
Examples
Authentication with error handling:
use nitrokey::{Authenticate, DeviceWrapper, User}; fn perform_user_task<'a>(device: &User<'a, DeviceWrapper<'a>>) {} fn perform_other_task(device: &DeviceWrapper) {} let mut manager = nitrokey::take()?; let device = manager.connect()?; let device = match device.authenticate_user("123456") { Ok(user) => { perform_user_task(&user); user.device() }, Err((device, err)) => { eprintln!("Could not authenticate as user: {}", err); device }, }; perform_other_task(&device);
Device-specific commands:
use nitrokey::{DeviceWrapper, Storage}; fn perform_common_task(device: &DeviceWrapper) {} fn perform_storage_task(device: &Storage) {} let mut manager = nitrokey::take()?; let device = manager.connect()?; perform_common_task(&device); match device { DeviceWrapper::Storage(storage) => perform_storage_task(&storage), _ => (), };
Variants
Storage(Storage<'a>)
A Nitrokey Storage device.
Pro(Pro<'a>)
A Nitrokey Pro device.
Trait Implementations
impl<'a> Authenticate<'a> for DeviceWrapper<'a>
[src]
fn authenticate_user(
self,
password: &str
) -> Result<User<'a, Self>, (Self, Error)>
[src]
self,
password: &str
) -> Result<User<'a, Self>, (Self, Error)>
fn authenticate_admin(
self,
password: &str
) -> Result<Admin<'a, Self>, (Self, Error)>
[src]
self,
password: &str
) -> Result<Admin<'a, Self>, (Self, Error)>
impl<'a> Debug for DeviceWrapper<'a>
[src]
impl<'a> Device<'a> for DeviceWrapper<'a>
[src]
fn into_manager(self) -> &'a mut Manager
[src]
fn get_model(&self) -> Model
[src]
fn get_status(&self) -> Result<Status, Error>
[src]
fn get_serial_number(&self) -> Result<String, Error>
[src]
fn get_user_retry_count(&self) -> Result<u8, Error>
[src]
fn get_admin_retry_count(&self) -> Result<u8, Error>
[src]
fn get_firmware_version(&self) -> Result<FirmwareVersion, Error>
[src]
fn get_config(&self) -> Result<Config, Error>
[src]
fn change_admin_pin(&mut self, current: &str, new: &str) -> Result<(), Error>
[src]
fn change_user_pin(&mut self, current: &str, new: &str) -> Result<(), Error>
[src]
fn unlock_user_pin(
&mut self,
admin_pin: &str,
user_pin: &str
) -> Result<(), Error>
[src]
&mut self,
admin_pin: &str,
user_pin: &str
) -> Result<(), Error>
fn lock(&mut self) -> Result<(), Error>
[src]
fn factory_reset(&mut self, admin_pin: &str) -> Result<(), Error>
[src]
fn build_aes_key(&mut self, admin_pin: &str) -> Result<(), Error>
[src]
impl<'a> From<Pro<'a>> for DeviceWrapper<'a>
[src]
impl<'a> From<Storage<'a>> for DeviceWrapper<'a>
[src]
impl<'a> GenerateOtp for DeviceWrapper<'a>
[src]
fn get_hotp_slot_name(&self, slot: u8) -> Result<String, Error>
[src]
fn get_totp_slot_name(&self, slot: u8) -> Result<String, Error>
[src]
fn get_hotp_code(&mut self, slot: u8) -> Result<String, Error>
[src]
fn get_totp_code(&self, slot: u8) -> Result<String, Error>
[src]
fn set_time(&mut self, time: u64, force: bool) -> Result<(), Error>
[src]
impl<'a> GetPasswordSafe<'a> for DeviceWrapper<'a>
[src]
fn get_password_safe(
&mut self,
user_pin: &str
) -> Result<PasswordSafe<'_, 'a>, Error>
[src]
&mut self,
user_pin: &str
) -> Result<PasswordSafe<'_, 'a>, Error>
Auto Trait Implementations
impl<'a> RefUnwindSafe for DeviceWrapper<'a>
impl<'a> Send for DeviceWrapper<'a>
impl<'a> Sync for DeviceWrapper<'a>
impl<'a> Unpin for DeviceWrapper<'a>
impl<'a> !UnwindSafe for DeviceWrapper<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,