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
).
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 dyn Writer) -> Result<(), Error>
fn encode(&self, writer: &mut dyn 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§fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length, Error>
fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length, 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 TryFrom<&SubjectPublicKeyInfo<'_>> for Document
impl TryFrom<&SubjectPublicKeyInfo<'_>> for Document
source§impl TryFrom<SubjectPublicKeyInfo<'_>> for Document
impl TryFrom<SubjectPublicKeyInfo<'_>> 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§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<'a, T> Choice<'a> for T
impl<'a, T> Choice<'a> for T
source§fn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Tag
decodable as a variant of this CHOICE
?§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)