logo
pub trait Document<'a>: AsRef<[u8]> + Sized + TryFrom<Vec<u8>, Error = Error> {
    type Message: Decodable<'a> + Encodable + Sized;

    const SENSITIVE: bool;
    fn as_der(&self) -> &[u8]
Notable traits for &'_ mut [u8]
impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
{ ... }
fn to_der(&self) -> Box<[u8]> { ... }
fn decode(&'a self) -> Self::Message { ... }
fn from_der(bytes: &[u8]) -> Result<Self> { ... }
fn from_msg(msg: &Self::Message) -> Result<Self> { ... }
fn from_pem(s: &str) -> Result<Self>
    where
        Self: PemLabel
, { ... }
fn to_pem(&self, line_ending: LineEnding) -> Result<String>
    where
        Self: PemLabel
, { ... }
fn read_der_file(path: impl AsRef<Path>) -> Result<Self> { ... }
fn read_pem_file(path: impl AsRef<Path>) -> Result<Self>
    where
        Self: PemLabel
, { ... }
fn write_der_file(&self, path: impl AsRef<Path>) -> Result<()> { ... }
fn write_pem_file(
        &self,
        path: impl AsRef<Path>,
        line_ending: LineEnding
    ) -> Result<()>
    where
        Self: PemLabel
, { ... } }
This is supported on crate feature alloc only.
Expand description

ASN.1 DER-encoded document.

This trait is intended to impl on types which contain an ASN.1 DER-encoded document which is guaranteed to encode as the associated Message type.

It implements common functionality related to encoding/decoding such documents, such as PEM encapsulation as well as reading/writing documents from/to the filesystem.

Associated Types

ASN.1 message type this document decodes to.

Associated Constants

Does this type contain potentially sensitive data?

This enables hardened file permissions when persisting data to disk.

Provided methods

Borrow the inner serialized bytes of this document.

Return an allocated ASN.1 DER serialization as a boxed slice.

Decode this document as ASN.1 DER.

Create a new document from the provided ASN.1 DER bytes.

Encode the provided type as ASN.1 DER.

This is supported on crate feature pem only.

Decode ASN.1 DER document from PEM.

This is supported on crate feature pem only.

Encode ASN.1 DER document as a PEM string.

This is supported on crate feature std only.

Read ASN.1 DER document from a file.

This is supported on crate features pem and std only.

Read PEM-encoded ASN.1 DER document from a file.

This is supported on crate feature std only.

Write ASN.1 DER document to a file.

This is supported on crate features pem and std only.

Write PEM-encoded ASN.1 DER document to a file.

Implementors