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
impl SessionManager
sourcepub fn new(pkcs11: Pkcs11, slot: Slot, session_type: SessionType) -> Self
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())));
sourcepub fn max_size(&self, maximum: u32) -> Result<Option<u32>, Error>
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 asmax_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
impl Clone for SessionManager
source§fn clone(&self) -> SessionManager
fn clone(&self) -> SessionManager
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SessionManager
impl Debug for SessionManager
source§impl ManageConnection for SessionManager
impl ManageConnection for SessionManager
§type Connection = Session
type Connection = Session
The connection type this manager deals with.
source§fn connect(&self) -> Result<Self::Connection, Self::Error>
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>
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
fn has_broken(&self, _session: &mut Self::Connection) -> bool
Quickly determines if the connection is no longer usable. Read more
Auto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl !UnwindSafe for SessionManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more