CertStore

Struct CertStore 

Source
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

Source

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).

Source

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
Source

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
Source

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
Source

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
Source

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.