pub struct CertStoreConn<P: AsRef<Path>> { /* private fields */ }Expand description
A CertStore connection builder.
An instance of this struct is returned by CertStore::open and can be
configured using exposed methods. In simple terms:
CertStoreConn::with_params- changes the Argon2 parameters used for password hashing (only applicable if using encryption),CertStoreConn::with_passphrase- enables encryption. The user supplies a password and a salt,CertStoreConn::connect- starts the connection to the underlying SQL database.
§Example
Start a connection with custom password hashing parameters.
use pyrus_cert_store::CertStore;
let store = CertStore::open("certstore.db3")
// 20 blocks of memory used, 3 threads, 4 iterations
.with_params(20 * 1024, 3, 4)
.with_passphrase(String::from("password123"), b"use a better password and salt")
.connect()?;Implementations§
Source§impl<P: AsRef<Path>> CertStoreConn<P>
impl<P: AsRef<Path>> CertStoreConn<P>
Sourcepub fn with_params(self, memory: u32, threads: u32, iterations: u32) -> Self
pub fn with_params(self, memory: u32, threads: u32, iterations: u32) -> Self
Modifies the parameters used for the Argon2 password hashing
algorithm. For detailed information about these parameters
read the argon2 crate documentation.
In simple terms:
memory- the number of 1 KiB memory blocks,threads- the number of threads used for calculations,iterations- the number of passes through the algorithm.
Sourcepub fn with_passphrase<S: AsRef<[u8]>>(
self,
passphrase: String,
salt: S,
) -> Self
pub fn with_passphrase<S: AsRef<[u8]>>( self, passphrase: String, salt: S, ) -> Self
Sets a passphrase to be used for the connection. Not calling this
method is equivalent to not enabling encryption for the CertStore.
§Example
Using a wrong password results in an error
let store_file = Path::new("certstore.db3");
{
let store = CertStore::open(store_file)
.with_passphrase(String::from("1234"), b"saltysalt")
.connect()?;
} // drops the connection
{
// reconnect with a wrong password
let store = CertStore::open(store_file)
.with_passphrase(String::from("banana"), b"saltysalt")
.connect();
assert!(store.is_err());
}Sourcepub fn connect(self) -> Result<CertStore>
pub fn connect(self) -> Result<CertStore>
Attempts the connection to the underlying SQL database. If the database does not exist, it is created and initialized.
§Errors
StoreError::InvalidPathwhen the store path cannot be converted to a C-compatible string.StoreError::SQLiteFailwhen any otherrusqliteerror occured.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for CertStoreConn<P>where
P: Freeze,
impl<P> RefUnwindSafe for CertStoreConn<P>where
P: RefUnwindSafe,
impl<P> Send for CertStoreConn<P>where
P: Send,
impl<P> Sync for CertStoreConn<P>where
P: Sync,
impl<P> Unpin for CertStoreConn<P>where
P: Unpin,
impl<P> UnwindSafe for CertStoreConn<P>where
P: UnwindSafe,
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