pub struct CertStore { /* private fields */ }Expand description
A wrapper around an SQL connection to the certificate database.
A connection is made by calling CertStore::open, configuring the
connection with CertStoreConn<P> and calling CertStoreConn::connect
which returns an instance of CertStore with an active connection.
See the crate root examples on how to open the store.
Implementations§
Source§impl CertStore
impl CertStore
Sourcepub fn open<P: AsRef<Path>>(path: P) -> CertStoreConn<P>
pub fn open<P: AsRef<Path>>(path: P) -> CertStoreConn<P>
Returns a CertStoreConn<P> which can be used to configure the
connection to the underlying SQL database.
Supplying an empty path (either "" or Path::new("")) results in
the store being open in memory (without persistence).
Sourcepub fn insert(&self, cert: LazyCert) -> Result<()>
pub fn insert(&self, cert: LazyCert) -> Result<()>
Inserts a LazyCert to the store. If there is a fingerprint clash,
the new certificate overwrites the old one.
For now this method takes ownership of cert, but this is subject to
change in the future.
§Errors
StoreError::SQLiteFail- if the SQLite call failed.
Sourcepub fn get(&self, fpr: &Fingerprint) -> Result<LazyCert>
pub fn get(&self, fpr: &Fingerprint) -> Result<LazyCert>
Finds a certificate with the given fingerprint. If a certificate is not found, this method will return an error since the SQLite call failed.
Returns an owned LazyCert which is probably why
CertStore::insert takes ownership of cert.
§Errors
StoreError::SQLiteFail- if the SQLite call failed.
Sourcepub fn remove(&self, fpr: &Fingerprint) -> Result<()>
pub fn remove(&self, fpr: &Fingerprint) -> Result<()>
Removes a certificate with fingerprint fpr from the store. If the
certificate is not found, this method will return an error since
the SQLite call failed.
§Errors
StoreError::SQLiteFail- if the SQLite call failed.
Sourcepub fn certs(&self) -> Result<Vec<LazyCert>>
pub fn certs(&self) -> Result<Vec<LazyCert>>
Returns a Vec<LazyCert> of all certificates in the store.
Returning an iterator of LazyCerts is planned, but doing this is
quite difficult.
§Errors
StoreError::SQLiteFail- if the SQLite call failed.
Sourcepub fn uids(&self) -> Result<Vec<(Fingerprint, String)>>
pub fn uids(&self) -> Result<Vec<(Fingerprint, String)>>
A “lighter” alternative to CertStore::certs, which returns pairs
of fingerprints and user ids for easy lookup and filtering.
§Errors
StoreError::SQLiteFail- if the SQLite call failed.