diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-08-03 16:46:19 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-08-03 17:35:41 +0200 |
commit | ad9dac7d5a68f9a6dd2bcae67a405eb9f2756b58 (patch) | |
tree | 2e8ffc431139a9a6abf429d5ae20358ff5fc8f33 | |
parent | dfc3f2bd8f383e64b87a08b6820effc4b2c339cb (diff) |
openpgp: Add a getter to CertBuilder to return the creation time.
- Add a getter to `CertBuilder` to return the configured creation
time.
- This is useful when gradually building up a `CertBuilder` and you
want to set an absolute expiration time.
-rw-r--r-- | openpgp/src/cert/builder.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index 8cf54d0c..ebe42d69 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -330,6 +330,34 @@ impl CertBuilder { self } + /// Returns the configured creation time, if any. + /// + /// # Examples + /// + /// ``` + /// use std::time::SystemTime; + /// + /// use sequoia_openpgp as openpgp; + /// use openpgp::cert::prelude::*; + /// + /// # fn main() -> openpgp::Result<()> { + /// let mut builder = CertBuilder::new(); + /// assert!(builder.creation_time().is_none()); + /// + /// let now = std::time::SystemTime::now(); + /// builder = builder.set_creation_time(Some(now)); + /// assert_eq!(builder.creation_time(), Some(now)); + /// + /// builder = builder.set_creation_time(None); + /// assert!(builder.creation_time().is_none()); + /// # Ok(()) + /// # } + /// ``` + pub fn creation_time(&self) -> Option<std::time::SystemTime> + { + self.creation_time + } + /// Sets the default asymmetric algorithms. /// /// This method controls the set of algorithms that is used to |