Skip to main content

TokenSelector

Struct TokenSelector 

Source
pub struct TokenSelector {
    pub backend: Option<String>,
    pub slot: Option<u64>,
    pub token_label: Option<String>,
    pub token_serial_number: Option<String>,
}
Expand description

Selects tokens with the specified identifier.

Fields§

§backend: Option<String>

Selects the named backend.

Backends are usually specified by their full path, e.g., /usr/lib/x86_64-linux-gnu/libykcs11.so.2. This matches on the full path, on the filename, the filename with each trailing component stripped, i.e., libykcs11.so.2, libykcs11.so, and libykcs11, and the filename with any initial lib prefix and all trailing components striped, i.e., ykcs11.

§slot: Option<u64>

Selects the token in the specified slot.

§token_label: Option<String>

Selects tokens with the specified label.

The user normally sets the token’s label when it is initialized.

The value of the restriction is compared to both the token’s raw label and the label encoded in hex. This allows matching labels with non-printable characters.

§token_serial_number: Option<String>

Selects tokens with the specified serial number.

The serial number is set when the token is initialized.

The value of the restriction is compared to both the token’s raw serial number and the serial number encoded in hex. This allows matching serial numbers with non-printable characters.

Implementations§

Source§

impl TokenSelector

Source

pub fn unconstrained() -> Self

Returns an unconstrained TokenSelector.

This matches all tokens.

Source

pub fn args(&self) -> String

Returns the argument and value as a string, e.g., --slot 1.

Source

pub fn has_backend_restrictions(&self) -> bool

Returns true if the selector has any restrictions on the backend.

A selector without restrictions matches everything.

Source

pub fn has_token_restrictions(&self) -> bool

Returns true if the selector has any restrictions on the token.

A selector without restrictions matches everything.

Source

pub fn has_restrictions(&self) -> bool

Returns true if the selector has any restrictions.

A selector without restrictions matches everything.

Source

pub fn backend(&self) -> Option<&str>

Returns the backend restriction, if any.

Source

pub fn backend_matches(&self, backend: &Backend) -> bool

Returns true if the selector matches the backend.

If the selector does not restrict the backend, then this returns true.

Source

pub fn slot(&self) -> Option<u64>

Returns the slot restriction, if any.

Source

pub fn slot_matches(&self, slot: u64) -> bool

Returns true if the selector matches the specified slot.

If the selector does not restrict the slot, then this returns true.

Source

pub fn token_label(&self) -> Option<&str>

Returns the token label restriction, if any.

Source

pub fn token_label_matches(&self, label: &str) -> bool

Returns true if the selector matches the specified token’s label.

If the selector does not restrict the token’s label, then this returns true.

The value of the restriction is compared to both the object’s raw label and the label encoded in hex. This allows matching labels with non-printable characters.

Source

pub fn token_serial_number(&self) -> Option<&str>

Returns the token’s serial number restriction, if any.

Source

pub fn token_serial_number_matches(&self, serial_number: &str) -> bool

Returns true if the selector matches the specified token’s serial number.

If the selector does not restrict the token’s serial number, then this returns true.

The value of the restriction is compared to both the token’s raw serial number and the serial number encoded in hex. This allows matching on serial numbers with non-printable characters.

Trait Implementations§

Source§

impl Clone for TokenSelector

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenSelector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&Token> for TokenSelector

Source§

fn from(token: &Token) -> TokenSelector

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.