[−][src]Struct nitrokey::SerialNumber
Serial number of a Nitrokey device.
The serial number can be formatted as a string using the ToString
trait, and it can be
parsed from a string using the FromStr
trait. It can also be represented as a 32-bit
unsigned integer using as_u32
. This integer is the ID of the smartcard of the Nitrokey
device.
Neither the format of the string representation nor the integer representation are guaranteed to stay the same for new firmware versions.
Methods
impl SerialNumber
[src]
pub fn empty() -> Self
[src]
Creates an emtpty serial number.
This function can be used to create a placeholder value or to compare a SerialNumber
instance with an empty serial number.
pub fn as_u32(&self) -> u32
[src]
Returns the integer reprensentation of this serial number.
This integer currently is the ID of the smartcard of the Nitrokey device. Upcoming firmware versions might change the meaning of this representation, or add additional components to the serial number.
Trait Implementations
impl Clone for SerialNumber
[src]
fn clone(&self) -> SerialNumber
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for SerialNumber
[src]
impl Debug for SerialNumber
[src]
impl Display for SerialNumber
[src]
impl FromStr for SerialNumber
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<SerialNumber, Error>
[src]
Try to parse a serial number from a hex string.
The input string must be a valid hex string. Optionally, it can include a 0x
prefix.
Errors
InvalidHexString
if the given string is not a valid hex string
Example
use std::convert::TryFrom; use nitrokey::{DeviceInfo, Error, SerialNumber}; fn find_device(serial_number: &str) -> Result<Option<DeviceInfo>, Error> { let serial_number: SerialNumber = serial_number.parse()?; Ok(nitrokey::list_devices()? .into_iter() .filter(|device| device.serial_number == Some(serial_number)) .next()) }
impl PartialEq<SerialNumber> for SerialNumber
[src]
fn eq(&self, other: &SerialNumber) -> bool
[src]
fn ne(&self, other: &SerialNumber) -> bool
[src]
impl StructuralPartialEq for SerialNumber
[src]
Auto Trait Implementations
impl RefUnwindSafe for SerialNumber
impl Send for SerialNumber
impl Sync for SerialNumber
impl Unpin for SerialNumber
impl UnwindSafe for SerialNumber
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,