[][src]Struct sequoia_openpgp::serialize::TSK

pub struct TSK<'a> { /* fields omitted */ }

A reference to a TPK that allows serialization of secret keys.

To avoid accidental leakage TPK::serialize() skips secret keys. To serialize TPKs with secret keys, use TPK::as_tsk() to create a TSK, which is a shim on top of the TPK, and serialize this.


let (tpk, _) = TPKBuilder::new().generate()?;

let mut buf = Vec::new();
tpk.as_tsk().serialize(&mut buf)?;

let tpk_ = TPK::from_bytes(&buf)?;
assert_eq!(tpk, tpk_);


impl<'a> TSK<'a>[src]

pub fn set_filter<P>(self, predicate: P) -> Self where
    P: 'a + Fn(&'a Key) -> bool

Filters which secret keys to export using the given predicate.

Note that the given filter replaces any existing filter.


let (tpk, _) = TPKBuilder::new().add_signing_subkey().generate()?;
assert_eq!(tpk.keys_valid().secret(true).count(), 2);

// Only write out the primary key's secret.
let mut buf = Vec::new();
tpk.as_tsk().set_filter(|k| k == tpk.primary()).serialize(&mut buf)?;

let tpk_ = TPK::from_bytes(&buf)?;
assert_eq!(tpk_.keys_valid().secret(true).count(), 1);

Trait Implementations

impl<'a> Serialize for TSK<'a>[src]

impl<'a> SerializeInto for TSK<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for TSK<'a>

impl<'a> !Send for TSK<'a>

impl<'a> !Sync for TSK<'a>

impl<'a> Unpin for TSK<'a>

impl<'a> !UnwindSafe for TSK<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.