Struct spki::PublicKeyDocument
source · [−]pub struct PublicKeyDocument(_);
alloc
only.Expand description
SPKI public key document.
This type provides storage for SubjectPublicKeyInfo
encoded as ASN.1
DER with the invariant that the contained-document is “well-formed”, i.e.
it will parse successfully according to this crate’s parsing rules.
Trait Implementations
sourceimpl Clone for PublicKeyDocument
impl Clone for PublicKeyDocument
sourcefn clone(&self) -> PublicKeyDocument
fn clone(&self) -> PublicKeyDocument
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 PublicKeyDocument
impl Debug for PublicKeyDocument
sourceimpl DecodePublicKey for PublicKeyDocument
impl DecodePublicKey for PublicKeyDocument
sourcefn from_public_key_der(bytes: &[u8]) -> Result<Self>
fn from_public_key_der(bytes: &[u8]) -> Result<Self>
Deserialize object from ASN.1 DER-encoded SubjectPublicKeyInfo
(binary format). Read more
sourcefn from_public_key_pem(s: &str) -> Result<Self>
fn from_public_key_pem(s: &str) -> Result<Self>
pem
only.Deserialize PEM-encoded SubjectPublicKeyInfo
. Read more
sourcefn read_public_key_der_file(path: impl AsRef<Path>) -> Result<Self>
fn read_public_key_der_file(path: impl AsRef<Path>) -> Result<Self>
std
only.Load public key object from an ASN.1 DER-encoded file on the local filesystem (binary format). Read more
sourcefn read_public_key_pem_file(path: impl AsRef<Path>) -> Result<Self>
fn read_public_key_pem_file(path: impl AsRef<Path>) -> Result<Self>
pem
and std
only.Load public key object from a PEM-encoded file on the local filesystem.
sourcefn from_public_key_doc(doc: &PublicKeyDocument) -> Result<Self>
fn from_public_key_doc(doc: &PublicKeyDocument) -> Result<Self>
alloc
only.Deserialize SPKI public key from a PublicKeyDocument
.
sourceimpl<'a> Document<'a> for PublicKeyDocument
impl<'a> Document<'a> for PublicKeyDocument
type Message = SubjectPublicKeyInfo<'a>
type Message = SubjectPublicKeyInfo<'a>
ASN.1 message type this document decodes to.
sourcefn as_der(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
fn as_der(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Borrow the inner serialized bytes of this document.
sourcefn to_der(&self) -> Box<[u8], Global>
fn to_der(&self) -> Box<[u8], Global>
Return an allocated ASN.1 DER serialization as a boxed slice.
sourcefn from_der(bytes: &[u8]) -> Result<Self, Error>
fn from_der(bytes: &[u8]) -> Result<Self, Error>
Create a new document from the provided ASN.1 DER bytes.
sourcefn from_pem(s: &str) -> Result<Self, Error> where
Self: PemLabel,
fn from_pem(s: &str) -> Result<Self, Error> where
Self: PemLabel,
Decode ASN.1 DER document from PEM.
sourcefn to_pem(&self, line_ending: LineEnding) -> Result<String, Error> where
Self: PemLabel,
fn to_pem(&self, line_ending: LineEnding) -> Result<String, Error> where
Self: PemLabel,
Encode ASN.1 DER document as a PEM string.
sourcefn read_der_file(path: impl AsRef<Path>) -> Result<Self, Error>
fn read_der_file(path: impl AsRef<Path>) -> Result<Self, Error>
Read ASN.1 DER document from a file.
sourcefn read_pem_file(path: impl AsRef<Path>) -> Result<Self, Error> where
Self: PemLabel,
fn read_pem_file(path: impl AsRef<Path>) -> Result<Self, Error> where
Self: PemLabel,
Read PEM-encoded ASN.1 DER document from a file.
sourcefn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER document to a file.
sourcefn write_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding
) -> Result<(), Error> where
Self: PemLabel,
fn write_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding
) -> Result<(), Error> where
Self: PemLabel,
Write PEM-encoded ASN.1 DER document to a file.
sourceimpl EncodePublicKey for PublicKeyDocument
impl EncodePublicKey for PublicKeyDocument
sourcefn to_public_key_der(&self) -> Result<PublicKeyDocument>
fn to_public_key_der(&self) -> Result<PublicKeyDocument>
alloc
only.Serialize a PublicKeyDocument
containing a SPKI-encoded public key.
sourcefn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String>
fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String>
alloc
and pem
only.Serialize this public key as PEM-encoded SPKI with the given LineEnding
.
sourcefn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<()>
fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<()>
alloc
and std
only.Write ASN.1 DER-encoded public key to the given path
sourcefn write_public_key_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding
) -> Result<()>
fn write_public_key_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding
) -> Result<()>
pem
and std
and alloc
only.Write ASN.1 DER-encoded public key to the given path
sourceimpl FromStr for PublicKeyDocument
This is supported on crate feature pem
only.
impl FromStr for PublicKeyDocument
pem
only.sourceimpl PemLabel for PublicKeyDocument
This is supported on crate feature pem
only.
impl PemLabel for PublicKeyDocument
pem
only.sourceconst TYPE_LABEL: &'static str
const TYPE_LABEL: &'static str
Expected PEM type label for a given document, e.g. "PRIVATE KEY"
sourceimpl TryFrom<&'_ SubjectPublicKeyInfo<'_>> for PublicKeyDocument
impl TryFrom<&'_ SubjectPublicKeyInfo<'_>> for PublicKeyDocument
sourcefn try_from(spki: &SubjectPublicKeyInfo<'_>) -> Result<PublicKeyDocument>
fn try_from(spki: &SubjectPublicKeyInfo<'_>) -> Result<PublicKeyDocument>
Performs the conversion.
sourceimpl TryFrom<SubjectPublicKeyInfo<'_>> for PublicKeyDocument
impl TryFrom<SubjectPublicKeyInfo<'_>> for PublicKeyDocument
sourcefn try_from(spki: SubjectPublicKeyInfo<'_>) -> Result<PublicKeyDocument>
fn try_from(spki: SubjectPublicKeyInfo<'_>) -> Result<PublicKeyDocument>
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for PublicKeyDocument
impl Send for PublicKeyDocument
impl Sync for PublicKeyDocument
impl Unpin for PublicKeyDocument
impl UnwindSafe for PublicKeyDocument
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