pub struct PublicKey { /* private fields */ }Expand description
An owned public key.
Implementations§
Source§impl PublicKey
impl PublicKey
Sourcepub fn new(algorithm: Algorithm, bytes: Vec<u8>) -> Result<Self>
pub fn new(algorithm: Algorithm, bytes: Vec<u8>) -> Result<Self>
Creates a new PublicKey from an owned Vec<u8> after validating key size.
Sourcepub fn from_bytes(algorithm: Algorithm, bytes: &[u8]) -> Result<Self>
pub fn from_bytes(algorithm: Algorithm, bytes: &[u8]) -> Result<Self>
Creates a new PublicKey by copying the provided bytes after validation.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consumes self and returns the inner byte vector.
Sourcepub fn from_spki(der: &[u8]) -> Result<Self>
pub fn from_spki(der: &[u8]) -> Result<Self>
Decode an SPKI DER-encoded public key into an owned PublicKey.
Sourcepub fn encode_spki_to(&self, out: &mut Vec<u8>)
pub fn encode_spki_to(&self, out: &mut Vec<u8>)
Encode this public key as SPKI DER into the given buffer.
Sourcepub fn encode_der_to(&self, out: &mut Vec<u8>)
pub fn encode_der_to(&self, out: &mut Vec<u8>)
Encode this public key as DER into the given buffer.
Sourcepub fn to_spki(&self) -> Vec<u8> ⓘ
pub fn to_spki(&self) -> Vec<u8> ⓘ
Encode this public key as SPKI DER, returning a new Vec<u8>.
Sourcepub fn from_pem(pem: &str) -> Result<Self>
pub fn from_pem(pem: &str) -> Result<Self>
Decode a PEM-encoded public key into an owned PublicKey.
Sourcepub fn as_key_ref(&self) -> PublicKeyRef<'_>
pub fn as_key_ref(&self) -> PublicKeyRef<'_>
Returns a borrowed PublicKeyRef.
Trait Implementations§
Source§impl<'a> From<PublicKeyRef<'a>> for PublicKey
impl<'a> From<PublicKeyRef<'a>> for PublicKey
Source§fn from(key: PublicKeyRef<'a>) -> Self
fn from(key: PublicKeyRef<'a>) -> Self
Converts to this type from the input type.
impl Eq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnsafeUnpin for PublicKey
impl UnwindSafe for PublicKey
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
Mutably borrows from an owned value. Read more