[−][src]Enum nitrokey::DeviceWrapper
A wrapper for a Nitrokey device of unknown type.
Use the function connect
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(device: &User<DeviceWrapper>) {} fn perform_other_task(device: &DeviceWrapper) {} let device = nitrokey::connect()?; let device = match device.authenticate_user("123456") { Ok(user) => { perform_user_task(&user); user.device() }, Err((device, err)) => { println!("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 device = nitrokey::connect()?; perform_common_task(&device); match device { DeviceWrapper::Storage(storage) => perform_storage_task(&storage), _ => (), };
Variants
Storage(Storage)
A Nitrokey Storage device.
Pro(Pro)
A Nitrokey Pro device.
Trait Implementations
impl Authenticate for DeviceWrapper
[src]
fn authenticate_user(
self,
password: &str
) -> Result<User<Self>, (Self, CommandError)>
[src]
self,
password: &str
) -> Result<User<Self>, (Self, CommandError)>
fn authenticate_admin(
self,
password: &str
) -> Result<Admin<Self>, (Self, CommandError)>
[src]
self,
password: &str
) -> Result<Admin<Self>, (Self, CommandError)>
impl Debug for DeviceWrapper
[src]
impl Device for DeviceWrapper
[src]
fn get_model(&self) -> Model
[src]
fn get_serial_number(&self) -> Result<String, CommandError>
[src]
fn get_user_retry_count(&self) -> u8
[src]
fn get_admin_retry_count(&self) -> u8
[src]
fn get_major_firmware_version(&self) -> i32
[src]
fn get_minor_firmware_version(&self) -> i32
[src]
fn get_config(&self) -> Result<Config, CommandError>
[src]
fn change_admin_pin(&self, current: &str, new: &str) -> Result<(), CommandError>
[src]
fn change_user_pin(&self, current: &str, new: &str) -> Result<(), CommandError>
[src]
fn unlock_user_pin(
&self,
admin_pin: &str,
user_pin: &str
) -> Result<(), CommandError>
[src]
&self,
admin_pin: &str,
user_pin: &str
) -> Result<(), CommandError>
fn lock(&self) -> Result<(), CommandError>
[src]
fn factory_reset(&self, admin_pin: &str) -> Result<(), CommandError>
[src]
fn build_aes_key(&self, admin_pin: &str) -> Result<(), CommandError>
[src]
impl GenerateOtp for DeviceWrapper
[src]
fn get_hotp_slot_name(&self, slot: u8) -> Result<String, CommandError>
[src]
fn get_totp_slot_name(&self, slot: u8) -> Result<String, CommandError>
[src]
fn get_hotp_code(&self, slot: u8) -> Result<String, CommandError>
[src]
fn get_totp_code(&self, slot: u8) -> Result<String, CommandError>
[src]
fn set_time(&self, time: u64, force: bool) -> Result<(), CommandError>
[src]
impl GetPasswordSafe for DeviceWrapper
[src]
fn get_password_safe(
&self,
user_pin: &str
) -> Result<PasswordSafe, CommandError>
[src]
&self,
user_pin: &str
) -> Result<PasswordSafe, CommandError>
Auto Trait Implementations
impl RefUnwindSafe for DeviceWrapper
impl Send for DeviceWrapper
impl Sync for DeviceWrapper
impl Unpin for DeviceWrapper
impl UnwindSafe for DeviceWrapper
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>,