1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
use std::marker::PhantomData; use ffi; use utils::{self, StrResult}; bitflags! { flags Flags: ffi::gpgme_sig_notation_flags_t { const HUMAN_READABLE = ffi::GPGME_SIG_NOTATION_HUMAN_READABLE, const CRITICAL = ffi::GPGME_SIG_NOTATION_CRITICAL, } } pub struct SignatureNotation<'a, T: 'a> { raw: ffi::gpgme_sig_notation_t, phantom: PhantomData<&'a T>, } impl<'a, T> SignatureNotation<'a, T> { pub unsafe fn from_raw<'b>(raw: ffi::gpgme_sig_notation_t) -> SignatureNotation<'b, T> { debug_assert!(!raw.is_null()); SignatureNotation { raw: raw, phantom: PhantomData, } } pub fn raw(&self) -> ffi::gpgme_sig_notation_t { self.raw } pub fn is_human_readable(&self) -> bool { unsafe { (*self.raw).human_readable() } } pub fn is_critical(&self) -> bool { unsafe { (*self.raw).critical() } } pub fn flags(&self) -> Flags { unsafe { Flags::from_bits_truncate((*self.raw).flags) } } pub fn name(&self) -> StrResult<'a> { unsafe { utils::from_cstr((*self.raw).name) } } pub fn value(&self) -> StrResult<'a> { unsafe { utils::from_cstr((*self.raw).value) } } } pub struct SignatureNotationIter<'a, T: 'a> { current: ffi::gpgme_sig_notation_t, phantom: PhantomData<&'a T>, } impl<'a, T> SignatureNotationIter<'a, T> { pub unsafe fn from_list<'b>(list: ffi::gpgme_sig_notation_t) -> SignatureNotationIter<'b, T> { SignatureNotationIter { current: list, phantom: PhantomData, } } } impl<'a, T> Iterator for SignatureNotationIter<'a, T> { list_iterator!(SignatureNotation<'a, T>, SignatureNotation::from_raw); }