[][src]Trait sequoia_openpgp::serialize::MarshalInto

pub trait MarshalInto: Sealed {
    pub fn serialized_len(&self) -> usize;
pub fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>; pub fn to_vec(&self) -> Result<Vec<u8>> { ... }
pub fn export_into(&self, buf: &mut [u8]) -> Result<usize> { ... }
pub fn export_to_vec(&self) -> Result<Vec<u8>> { ... } }

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

pub fn serialized_len(&self) -> usize[src]

Computes the maximal length of the serialized representation.

Errors

If serialization would fail, this function underestimates the length.

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

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.

Loading content...

Provided methods

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

Serializes the packet to a vector.

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

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.

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

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.
Loading content...

Implementors

impl MarshalInto for S2K[src]

impl MarshalInto for Ciphertext[src]

impl MarshalInto for PublicKey[src]

impl MarshalInto for SecretKeyMaterial[src]

impl MarshalInto for sequoia_openpgp::crypto::mpi::Signature[src]

impl MarshalInto for Fingerprint[src]

impl MarshalInto for KeyID[src]

impl MarshalInto for AED[src]

impl MarshalInto for OnePassSig[src]

impl MarshalInto for PKESK[src]

impl MarshalInto for SEIP[src]

impl MarshalInto for SKESK[src]

impl MarshalInto for sequoia_openpgp::packet::Signature[src]

impl MarshalInto for BodyLength[src]

impl MarshalInto for CTB[src]

impl MarshalInto for Packet[src]

impl MarshalInto for SubpacketValue[src]

impl MarshalInto for Image[src]

impl MarshalInto for sequoia_openpgp::packet::user_attribute::Subpacket[src]

impl MarshalInto for Cert[src]

impl MarshalInto for MPI[src]

impl MarshalInto for ProtectedMPI[src]

impl MarshalInto for Message[src]

impl MarshalInto for AED1[src]

impl MarshalInto for CTBNew[src]

impl MarshalInto for CTBOld[src]

impl MarshalInto for Header[src]

impl MarshalInto for OnePassSig3[src]

impl MarshalInto for PKESK3[src]

impl MarshalInto for CompressedData[src]

pub fn serialized_len(&self) -> usize[src]

Computes the maximal length of the serialized representation.

The size of the serialized compressed data packet is tricky to predict. First, it depends on the data being compressed. Second, we emit partial body encoded data.

This function tries overestimates the length. However, it may happen that serialize_into() fails.

Errors

If serialization would fail, this function returns 0.

impl MarshalInto for Literal[src]

impl MarshalInto for MDC[src]

impl MarshalInto for Marker[src]

impl MarshalInto for Trust[src]

impl MarshalInto for Unknown[src]

impl MarshalInto for UserID[src]

impl MarshalInto for Signature4[src]

impl MarshalInto for sequoia_openpgp::packet::signature::subpacket::Subpacket[src]

impl MarshalInto for SubpacketArea[src]

impl MarshalInto for SKESK4[src]

impl MarshalInto for SKESK5[src]

impl MarshalInto for UserAttribute[src]

impl MarshalInto for PacketPile[src]

impl MarshalInto for RevocationKey[src]

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

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

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

Loading content...