Struct der::SecretDocument
source · [−]pub struct SecretDocument(_);
alloc
and zeroize
only.Expand description
Secret Document
type.
Useful for formats which represent potentially secret data, such as cryptographic keys.
This type provides additional hardening such as ensuring that the contents are zeroized-on-drop, and also using more restrictive file permissions when writing files to disk.
Implementations
sourceimpl SecretDocument
impl SecretDocument
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Borrow the inner serialized bytes of this document.
sourcepub fn to_bytes(&self) -> Zeroizing<Vec<u8>>
pub fn to_bytes(&self) -> Zeroizing<Vec<u8>>
Return an allocated ASN.1 DER serialization as a byte vector.
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 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.
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.
sourcepub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding
) -> Result<Zeroizing<String>>
Available on crate feature pem
only.
pub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding
) -> Result<Zeroizing<String>>
pem
only.Encode ASN.1 DER document as a PEM string.
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
sourceimpl Clone for SecretDocument
impl Clone for SecretDocument
sourcefn clone(&self) -> SecretDocument
fn clone(&self) -> SecretDocument
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SecretDocument
impl Debug for SecretDocument
sourceimpl Drop for SecretDocument
impl Drop for SecretDocument
sourceimpl From<Document> for SecretDocument
impl From<Document> for SecretDocument
sourcefn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
Converts to this type from the input type.
impl ZeroizeOnDrop for SecretDocument
Auto Trait Implementations
impl RefUnwindSafe for SecretDocument
impl Send for SecretDocument
impl Sync for SecretDocument
impl Unpin for SecretDocument
impl UnwindSafe for SecretDocument
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more