diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:20:38 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-18 15:22:51 +0200 |
commit | e1270c0fbdb1faa209061330fe7d5850fec8e12d (patch) | |
tree | 9e4cf43948a97bd87381b75c4783455e47323d81 /openpgp-ffi/src | |
parent | 212202e5bec054cc3b2b83edffdd8b83db5bf011 (diff) |
openpgp: Combine TPK::alive and its _at variant.
- Combine TPK::alive and TPK::alive_at.
- Use an Into<Option<time::Tm>> to distinguish the two previous
cases: the current time (None), and a specific time (a time::Tm).
Diffstat (limited to 'openpgp-ffi/src')
-rw-r--r-- | openpgp-ffi/src/tpk.rs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/openpgp-ffi/src/tpk.rs b/openpgp-ffi/src/tpk.rs index 7729b7f5..0d59bf00 100644 --- a/openpgp-ffi/src/tpk.rs +++ b/openpgp-ffi/src/tpk.rs @@ -333,21 +333,19 @@ fn pgp_tpk_expired(tpk: *const TPK, when: time_t) -> c_int { tpk.expired(t) as c_int } -/// Returns whether the TPK is alive. -#[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_tpk_alive(tpk: *const TPK) - -> c_int { - let tpk = tpk.ref_raw(); - - tpk.alive() as c_int -} - /// Returns whether the TPK is alive at the specified time. +/// +/// If `when` is 0, then the current time is used. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn pgp_tpk_alive_at(tpk: *const TPK, when: time_t) +fn pgp_tpk_alive(tpk: *const TPK, when: time_t) -> c_int { let tpk = tpk.ref_raw(); - tpk.alive_at(time::at(time::Timespec::new(when as i64, 0))) as c_int + let t = if when == 0 { + None + } else { + Some(time::at(time::Timespec::new(when as i64, 0))) + }; + tpk.alive(t) as c_int } /// Changes the TPK's expiration. |