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

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

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

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


let (cert, _) = CertBuilder::new().generate()?;

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

let cert_ = Cert::from_bytes(&buf)?;
assert_eq!(cert, cert_);


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

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

Filters which secret keys to export using the given predicate.

Note that the given filter replaces any existing filter.


let (cert, _) = CertBuilder::new().add_signing_subkey().generate()?;
assert_eq!(cert.keys().alive().revoked(false).secret().count(), 2);

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

let cert_ = Cert::from_bytes(&buf)?;
assert_eq!(cert_.keys().alive().revoked(false).secret().count(), 1);

Trait Implementations

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

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

fn to_vec(&self) -> Result<Vec<u8>>[src]

Serializes the packet to a vector.

fn export_to_vec(&self) -> Result<Vec<u8>>[src]

Exports to a vector. Read more

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip for T where
    V: MultiLane<T>,