Struct openpgp_cert_d::CertD
source · pub struct CertD { /* private fields */ }Expand description
A certificate store.
This is a handle to an on-disk certificate store that can be used to lookup and insert certificates.
Implementations§
source§impl CertD
impl CertD
sourcepub fn new() -> Result<CertD>
pub fn new() -> Result<CertD>
Opens the default certificate store.
If not explicitly requested otherwise, an application SHOULD
use the default store. To use a store with a different
location, use CertD::with_base_dir.
sourcepub fn with_base_dir<P: AsRef<Path>>(base: P) -> Result<CertD>
pub fn with_base_dir<P: AsRef<Path>>(base: P) -> Result<CertD>
Opens a store with an explicit location.
Note: If not explicitly requested otherwise, an application
SHOULD use the default store using CertD::new.
sourcepub fn get_base_dir(&self) -> &Path
pub fn get_base_dir(&self) -> &Path
Get the this Certd’s base path.
sourcepub fn get(&self, name: &str) -> Result<Option<(Tag, Data)>>
pub fn get(&self, name: &str) -> Result<Option<(Tag, Data)>>
Looks up a certificate in the store by an name, i.e. a fingerprint or a special name.
If the certificate exists, this function returns Ok(Some((tag, cert))). See Tag for how this can be used to cache lookups.
If the certificate does not exist, this function returns Ok(None).
If an I/O error occurs, or the name was invalid, this function returns
an Error.
sourcepub fn get_if_changed(
&self,
since: Tag,
name: &str
) -> Result<Option<(Tag, Data)>>
pub fn get_if_changed( &self, since: Tag, name: &str ) -> Result<Option<(Tag, Data)>>
Looks up a certificate in the store by an name, i.e. a fingerprint
or a special name, with the Tag from the previous lookup.
If the certificate has changed, this function returns Ok(Some((cert, tag))). The tag can be used in subsequent calls to this function.
If the certificate has not changed or does not exist, this function
returns Ok(None).
If an I/O error occurs, or the name was invalid, this function returns
an Error.
sourcepub fn insert<M>(&self, data: Data, merge: M) -> Result<(Tag, Data)>
pub fn insert<M>(&self, data: Data, merge: M) -> Result<(Tag, Data)>
Inserts or updates a cert.
Requires the fingerprint and a callback function. The callback is
invoked with an Option<Data> of the existing cert data (if any),
and is expected to merge the two copies of the certificate together.
The returned Data is written to the store.
(Note: The function may decide to omit (parts of) the existing data,
but this should be done with great care as not to lose any vital
information.)
Acquires lock to the store, blocking the current thread until it’s able to do so.
The insertion method returns the merged certificate data and the tag.
See Tag for how this can be used to cache lookups.
sourcepub fn try_insert<M>(&self, data: Data, merge: M) -> Result<(Tag, Data)>
pub fn try_insert<M>(&self, data: Data, merge: M) -> Result<(Tag, Data)>
Inserts or updates a cert, non-blocking variant.
Requires the fingerprint and a callback function. The callback is
invoked with an Option<Data> of the existing cert data (if any),
and is expected to merge the two copies of the certificate together.
The returned Data is written to the store.
(Note: The function may decide to omit (parts of) the existing data,
but this should be done with great care as not to lose any vital
information.)
Attempts to lock the store. Does not block, instead returns an
Error::IoError with an std::io::ErrorKind::WouldBlock
if the lock cannot be acquired.
The insertion method returns the merged certificate data and the tag.
See Tag for how this can be used to cache lookups.
sourcepub fn insert_special<M>(
&self,
special_name: &str,
data: Data,
merge: M
) -> Result<(Tag, Data)>
pub fn insert_special<M>( &self, special_name: &str, data: Data, merge: M ) -> Result<(Tag, Data)>
Inserts or updates the cert or key stored under a special name.
Requires the special name, the cert or key in binary format and a
callback function. The callback is invoked with an Option<Data> of
the existing data (if any), and is expected to merge the two copies
together. The returned Data is written to the
store under the special name. (Note: The function may decide to omit
(parts of) the existing data, but this should be done with great care as
not to lose any vital information.)
Acquires lock to the store, blocking the current thread until it’s able to do so.
The insertion method returns the merged data and the tag.
See Tag for how this can be used to cache lookups.
sourcepub fn try_insert_special<M>(
&self,
special_name: &str,
data: Data,
merge: M
) -> Result<(Tag, Data)>
pub fn try_insert_special<M>( &self, special_name: &str, data: Data, merge: M ) -> Result<(Tag, Data)>
Inserts or updates the cert or key stored under a special name, non-blocking variant.
Requires the special name, the cert or key in binary format and a
callback function. The callback is invoked with an Option<Data> of
the existing data (if any), and is expected to merge the two copies
together. The returned Data is written to the
store under the special name. (Note: The function may decide to omit
(parts of) the existing data, but this should be done with great care as
not to lose any vital information.)
Attempts to lock the store. Does not block, instead returns an
Error::IoError with an std::io::ErrorKind::WouldBlock
if the lock cannot be acquired.
The insertion method returns the merged data and the tag.
See Tag for how this can be used to cache lookups.
sourcepub fn iter_fingerprints(&self) -> Result<impl Iterator<Item = String> + '_>
pub fn iter_fingerprints(&self) -> Result<impl Iterator<Item = String> + '_>
Iterates over the certs in the store returning their fingerprints.