[−][src]Struct sequoia_openpgp::serialize::TSK
A reference to a Cert that allows serialization of secret keys.
To avoid accidental leakage, secret keys are not serialized when a
serializing a Cert
. To serialize Cert
s with secret keys,
use Cert::as_tsk()
to create a TSK
, which is a shim on top
of the Cert
, and serialize this.
Example
let (cert, _) = CertBuilder::new().generate()?; assert!(cert.is_tsk()); let mut buf = Vec::new(); cert.as_tsk().serialize(&mut buf)?; let cert_ = Cert::from_bytes(&buf)?; assert!(cert_.is_tsk()); assert_eq!(cert, cert_);
Implementations
impl<'a> TSK<'a>
[src]
pub fn set_filter<P>(self, predicate: P) -> Self where
P: 'a + Fn(&'a Key<SecretParts, UnspecifiedRole>) -> bool,
[src]
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.
Example
use sequoia_openpgp::policy::StandardPolicy; let p = &StandardPolicy::new(); let (cert, _) = CertBuilder::new().add_signing_subkey().generate()?; assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false).secret().count(), 2); // Only write out the primary key's secret. let mut buf = Vec::new(); cert.as_tsk() .set_filter(|k| k.fingerprint() == cert.fingerprint()) .serialize(&mut buf)?; let cert_ = Cert::from_bytes(&buf)?; assert_eq!(cert_.keys().with_policy(p, None).alive().revoked(false).secret().count(), 1); assert!(cert_.primary_key().has_secret());
Trait Implementations
impl<'a> Marshal for TSK<'a>
[src]
fn serialize(&self, o: &mut dyn Write) -> Result<()>
[src]
fn export(&self, o: &mut dyn Write) -> Result<()>
[src]
impl<'a> MarshalInto for TSK<'a>
[src]
fn serialized_len(&self) -> usize
[src]
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
[src]
fn export_into(&self, buf: &mut [u8]) -> Result<usize>
[src]
fn to_vec(&self) -> Result<Vec<u8>>
[src]
fn export_to_vec(&self) -> Result<Vec<u8>>
[src]
impl<'a> Serialize for TSK<'a>
[src]
fn serialize(&self, o: &mut dyn Write) -> Result<()>
[src]
fn export(&self, o: &mut dyn Write) -> Result<()>
[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,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,