pub struct Document { /* private fields */ }
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
pub fn into_secret(self) -> SecretDocument
Convert to a SecretDocument
.
sourcepub fn decode_msg<'a, T>(&'a self) -> Result<T, Error>where
T: Decode<'a>,
pub fn decode_msg<'a, T>(&'a self) -> Result<T, Error>where
T: Decode<'a>,
Try to decode the inner ASN.1 DER message contained in this
Document
as the given type.
sourcepub fn encode_msg<T>(msg: &T) -> Result<Document, Error>where
T: Encode,
pub fn encode_msg<T>(msg: &T) -> Result<Document, Error>where
T: Encode,
Encode the provided type as ASN.1 DER, storing the resulting encoded DER
as a Document
.
sourcepub fn from_pem(pem: &str) -> Result<(&str, Document), Error>
pub fn from_pem(pem: &str) -> Result<(&str, Document), Error>
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, Error>
pub fn to_pem( &self, label: &'static str, line_ending: LineEnding, ) -> Result<String, Error>
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<Document, Error>
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Document, Error>
Read ASN.1 DER document from a file.
sourcepub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER document to a file.
sourcepub fn read_pem_file(
path: impl AsRef<Path>,
) -> Result<(String, Document), Error>
pub fn read_pem_file( path: impl AsRef<Path>, ) -> Result<(String, Document), Error>
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<(), Error>
pub fn write_pem_file( &self, path: impl AsRef<Path>, label: &'static str, line_ending: LineEnding, ) -> Result<(), Error>
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, Error>
fn encoded_len(&self) -> Result<Length, Error>
source§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Writer
.source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
source§impl From<Document> for SecretDocument
impl From<Document> for SecretDocument
source§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
source§impl<'a, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Document
impl<'a, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Document
source§impl<'a, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Document
impl<'a, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Document
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> DecodePublicKey for T
impl<T> DecodePublicKey for T
source§fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
SubjectPublicKeyInfo
]
(binary format).source§fn from_public_key_pem(s: &str) -> Result<Self, Error>
fn from_public_key_pem(s: &str) -> Result<Self, Error>
SubjectPublicKeyInfo
]. Read more