pub struct Document { /* private fields */ }alloc only.Expand description
ASN.1 DER-encoded document.
This type wraps an encoded ASN.1 DER message. The document checked to
ensure it contains a valid DER-encoded SEQUENCE.
It implements common functionality related to encoding/decoding such documents, such as PEM encapsulation as well as reading/writing documents from/to the filesystem.
The SecretDocument provides a wrapper for this type with additional
hardening applied.
Implementations§
Source§impl Document
impl Document
Sourcepub fn into_secret(self) -> SecretDocument
Available on crate feature zeroize only.
pub fn into_secret(self) -> SecretDocument
zeroize only.Convert to a SecretDocument.
Sourcepub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result<T>
pub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result<T>
Try to decode the inner ASN.1 DER message contained in this
Document as the given type.
Sourcepub fn encode_msg<T: Encode>(msg: &T) -> Result<Self>
pub fn encode_msg<T: Encode>(msg: &T) -> Result<Self>
Encode the provided type as ASN.1 DER, storing the resulting encoded DER
as a Document.
Sourcepub fn from_pem(pem: &str) -> Result<(&str, Self)>
Available on crate feature pem only.
pub fn from_pem(pem: &str) -> Result<(&str, Self)>
pem only.Decode ASN.1 DER document from PEM.
Returns the PEM label and decoded Document on success.
Sourcepub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding,
) -> Result<String>
Available on crate feature pem only.
pub fn to_pem( &self, label: &'static str, line_ending: LineEnding, ) -> Result<String>
pem only.Encode ASN.1 DER document as a PEM string with encapsulation boundaries
containing the provided PEM type label (e.g. CERTIFICATE).
Sourcepub fn read_der_file(path: impl AsRef<Path>) -> Result<Self>
Available on crate feature std only.
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Self>
std only.Read ASN.1 DER document from a file.
Sourcepub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<()>
Available on crate feature std only.
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<()>
std only.Write ASN.1 DER document to a file.
Sourcepub fn read_pem_file(path: impl AsRef<Path>) -> Result<(String, Self)>
Available on crate features pem and std only.
pub fn read_pem_file(path: impl AsRef<Path>) -> Result<(String, Self)>
pem and std only.Read PEM-encoded ASN.1 DER document from a file.
Sourcepub fn write_pem_file(
&self,
path: impl AsRef<Path>,
label: &'static str,
line_ending: LineEnding,
) -> Result<()>
Available on crate features pem and std only.
pub fn write_pem_file( &self, path: impl AsRef<Path>, label: &'static str, line_ending: LineEnding, ) -> Result<()>
pem and std only.Write PEM-encoded ASN.1 DER document to a file.
Trait Implementations§
Source§impl Encode for Document
impl Encode for Document
Source§fn encoded_len(&self) -> Result<Length>
fn encoded_len(&self) -> Result<Length>
Source§fn encode(&self, writer: &mut impl Writer) -> Result<()>
fn encode(&self, writer: &mut impl Writer) -> Result<()>
Writer.Source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Source§impl From<Document> for SecretDocument
Available on crate feature zeroize only.
impl From<Document> for SecretDocument
zeroize only.Source§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DecodeOwned for Twhere
T: for<'a> Decode<'a>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes