Struct r2d2_cryptoki::SessionManager

source ·
pub struct SessionManager { /* private fields */ }
Expand description

Manager holding all information necessary for opening new connections

Implementations§

source§

impl SessionManager

source

pub fn new(pkcs11: Pkcs11, slot: Slot, session_type: SessionType) -> Self

§Example
 let pkcs11 = Pkcs11::new("libsofthsm2.so").unwrap();
 pkcs11 .initialize(CInitializeArgs::OsThreads).unwrap();
 let slots = pkcs11.get_slots_with_token().unwrap();
 let slot = slots.first().unwrap();
 let manager = SessionManager::new(pkcs11, *slot, SessionType::RwUser(AuthPin::new("abcd".to_string())));
source

pub fn max_size(&self, maximum: u32) -> Result<Option<u32>, Error>

Returns the maximum number of sessions supported by the HSM.

Arguments:

  • maximum: A maximum number of sessions as max_size can return u32::max_value() which is probably more than what your application should use.
§Example
 let pool_builder = r2d2::Pool::builder();
 let pool_builder = if let Some(max_size) = manager.max_size(100).unwrap() {
    pool_builder.max_size(max_size)
 } else {
    pool_builder
 };
 let pool = pool_builder.build(manager).unwrap();

Trait Implementations§

source§

impl Clone for SessionManager

source§

fn clone(&self) -> SessionManager

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for SessionManager

source§

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

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

impl ManageConnection for SessionManager

§

type Connection = Session

The connection type this manager deals with.
§

type Error = Error

The error type returned by Connections.
source§

fn connect(&self) -> Result<Self::Connection, Self::Error>

Attempts to create a new connection.
source§

fn is_valid(&self, session: &mut Self::Connection) -> Result<(), Self::Error>

Determines if the connection is still connected to the database. Read more
source§

fn has_broken(&self, _session: &mut Self::Connection) -> bool

Quickly determines if the connection is no longer usable. Read more

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> 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> ToOwned for T
where T: Clone,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.