From ad9dac7d5a68f9a6dd2bcae67a405eb9f2756b58 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Mon, 3 Aug 2020 16:46:19 +0200 Subject: 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. --- openpgp/src/cert/builder.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 + { + self.creation_time + } + /// Sets the default asymmetric algorithms. /// /// This method controls the set of algorithms that is used to -- cgit v1.2.3