Trait sequoia_openpgp::serialize::MarshalInto

source ·
pub trait MarshalInto: Sealed {
    // Required methods
    fn serialized_len(&self) -> usize;
    fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>;

    // Provided methods
    fn to_vec(&self) -> Result<Vec<u8>> { ... }
    fn export_into(&self, buf: &mut [u8]) -> Result<usize> { ... }
    fn export_to_vec(&self) -> Result<Vec<u8>> { ... }
}
Expand description

Serializes OpenPGP data structures into pre-allocated buffers.

This trait provides the same interface as SerializeInto, but is implemented for all data structures that can be serialized.

In general, you should prefer the SerializeInto trait, as it is only implemented for data structures that are normally exported. See the documentation for Serialize for more details.

§Sealed trait

This trait is sealed and cannot be implemented for types outside this crate. Therefore it can be extended in a non-breaking way. If you want to implement the trait inside the crate you also need to implement the seal::Sealed marker trait.

Required Methods§

source

fn serialized_len(&self) -> usize

Computes the maximal length of the serialized representation.

§Errors

If serialization would fail, this function underestimates the length.

source

fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>

Serializes into the given buffer.

Returns the length of the serialized representation.

§Errors

If the length of the given slice is smaller than the maximal length computed by serialized_len(), this function returns Error::InvalidArgument.

Provided Methods§

source

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

Serializes the packet to a vector.

source

fn export_into(&self, buf: &mut [u8]) -> Result<usize>

Exports into the given buffer.

This is similar to serialize_into(..), with these exceptions:

  • It is an error to export a Signature if it is marked as non-exportable.
  • When exporting a Cert, non-exportable signatures are not exported, and any component bound merely by non-exportable signatures is not exported.

Returns the length of the serialized representation.

§Errors

If the length of the given slice is smaller than the maximal length computed by serialized_len(), this function returns Error::InvalidArgument.

source

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

Exports to a vector.

This is similar to to_vec(), with these exceptions:

  • It is an error to export a Signature if it is marked as non-exportable.
  • When exporting a Cert, non-exportable signatures are not exported, and any component bound merely by non-exportable signatures is not exported.

Implementors§

source§

impl MarshalInto for S2K

source§

impl MarshalInto for Ciphertext

source§

impl MarshalInto for PublicKey

source§

impl MarshalInto for SecretKeyMaterial

source§

impl MarshalInto for sequoia_openpgp::crypto::mpi::Signature

source§

impl MarshalInto for Fingerprint

source§

impl MarshalInto for KeyID

source§

impl MarshalInto for Packet

source§

impl MarshalInto for AED

source§

impl MarshalInto for OnePassSig

source§

impl MarshalInto for PKESK

source§

impl MarshalInto for SEIP

source§

impl MarshalInto for SKESK

source§

impl MarshalInto for sequoia_openpgp::packet::Signature

source§

impl MarshalInto for BodyLength

source§

impl MarshalInto for CTB

source§

impl MarshalInto for SubpacketValue

source§

impl MarshalInto for Image

source§

impl MarshalInto for sequoia_openpgp::packet::user_attribute::Subpacket

source§

impl MarshalInto for MPI

source§

impl MarshalInto for ProtectedMPI

source§

impl MarshalInto for AED1

source§

impl MarshalInto for CTBNew

source§

impl MarshalInto for CTBOld

source§

impl MarshalInto for Header

source§

impl MarshalInto for OnePassSig3

source§

impl MarshalInto for PKESK3

source§

impl MarshalInto for Signature3

source§

impl MarshalInto for Signature4

source§

impl MarshalInto for sequoia_openpgp::packet::signature::subpacket::Subpacket

source§

impl MarshalInto for SubpacketArea

source§

impl MarshalInto for SKESK4

source§

impl MarshalInto for SKESK5

source§

impl MarshalInto for CompressedData

source§

impl MarshalInto for Literal

source§

impl MarshalInto for MDC

source§

impl MarshalInto for Marker

source§

impl MarshalInto for Trust

source§

impl MarshalInto for Unknown

source§

impl MarshalInto for UserID

source§

impl MarshalInto for UserAttribute

source§

impl MarshalInto for Cert

source§

impl MarshalInto for Message

source§

impl MarshalInto for PacketPile

source§

impl MarshalInto for RevocationKey

source§

impl<'a> MarshalInto for TSK<'a>

source§

impl<P, R> MarshalInto for Key4<P, R>
where P: KeyParts, R: KeyRole,

source§

impl<P: KeyParts, R: KeyRole> MarshalInto for Key<P, R>