diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-05-08 15:25:36 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-05-09 12:52:23 +0200 |
commit | 0e61680d31c7444d0163708bfd0ddf94072c6c1b (patch) | |
tree | 7f2c57cfb2002b6dd8f6b5e198de46d47a0c2df5 /openpgp-ffi/src/revocation_status.rs | |
parent | 746e8176e9d0c92321d63adcebcd376290bda902 (diff) |
openpgp-ffi: Wrap RevocationStatus.
Diffstat (limited to 'openpgp-ffi/src/revocation_status.rs')
-rw-r--r-- | openpgp-ffi/src/revocation_status.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/openpgp-ffi/src/revocation_status.rs b/openpgp-ffi/src/revocation_status.rs new file mode 100644 index 00000000..03362ec4 --- /dev/null +++ b/openpgp-ffi/src/revocation_status.rs @@ -0,0 +1,30 @@ +//! The revocation status. + +use libc::c_int; + +extern crate sequoia_openpgp as openpgp; + +use RefRaw; + +/// The revocation status. +#[::ffi_wrapper_type(prefix = "pgp_", derive = "Debug")] +pub struct RevocationStatus<'a>(openpgp::RevocationStatus<'a>); + +fn revocation_status_to_int(rs: &openpgp::RevocationStatus) -> c_int { + use self::openpgp::RevocationStatus::*; + match rs { + Revoked(_) => 0, + CouldBe(_) => 1, + NotAsFarAsWeKnow => 2, + } +} + +/// Returns the TPK's revocation status variant. +#[::sequoia_ffi_macros::extern_fn] #[no_mangle] +pub extern "C" fn pgp_revocation_status_variant( + rs: *const RevocationStatus) + -> c_int +{ + revocation_status_to_int(rs.ref_raw()) +} + |