pub struct OpenPGPv4Fingerprint(String);
Expand description
An OpenPGP v4 fingerprint.
The OpenPGPv4Fingerprint
type wraps a String
representing an OpenPGP v4 fingerprint,
ensuring that it consists of exactly 40 uppercase hexadecimal characters.
§Note
This type supports constructing from both uppercase and lowercase hexadecimal characters but guarantees to return the fingerprint in uppercase.
§Examples
use std::str::FromStr;
use alpm_types::{Error, OpenPGPv4Fingerprint};
// Create OpenPGPv4Fingerprint from a valid OpenPGP v4 fingerprint
let key = OpenPGPv4Fingerprint::from_str("4A0C4DFFC02E1A7ED969ED231C2358A25A10D94E")?;
assert_eq!(key.as_str(), "4A0C4DFFC02E1A7ED969ED231C2358A25A10D94E");
// Attempting to create a OpenPGPv4Fingerprint from an invalid fingerprint will fail
assert!(OpenPGPv4Fingerprint::from_str("INVALIDKEY").is_err());
// Format as String
assert_eq!(
format!("{}", key),
"4A0C4DFFC02E1A7ED969ED231C2358A25A10D94E"
);
Tuple Fields§
§0: String
Implementations§
source§impl OpenPGPv4Fingerprint
impl OpenPGPv4Fingerprint
sourcepub fn new(fingerprint: String) -> Result<Self, Error>
pub fn new(fingerprint: String) -> Result<Self, Error>
Creates a new OpenPGPv4Fingerprint
instance
See OpenPGPv4Fingerprint::from_str
for more information on how the OpenPGP v4
fingerprint is validated.
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns a reference to the inner OpenPGP v4 fingerprint as a &str
.
sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consumes the OpenPGPv4Fingerprint
and returns the inner String
.
Trait Implementations§
source§impl Clone for OpenPGPv4Fingerprint
impl Clone for OpenPGPv4Fingerprint
source§fn clone(&self) -> OpenPGPv4Fingerprint
fn clone(&self) -> OpenPGPv4Fingerprint
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for OpenPGPv4Fingerprint
impl Debug for OpenPGPv4Fingerprint
source§impl Display for OpenPGPv4Fingerprint
impl Display for OpenPGPv4Fingerprint
source§impl FromStr for OpenPGPv4Fingerprint
impl FromStr for OpenPGPv4Fingerprint
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Creates a new OpenPGPv4Fingerprint
instance after validating that it follows the correct
format.
A valid OpenPGP v4 fingerprint should be exactly 40 characters long and consist only
of digits (0-9
) and hexadecimal letters (A-F
).
§Errors
Returns an error if the OpenPGP v4 fingerprint is not valid.
source§impl PartialEq for OpenPGPv4Fingerprint
impl PartialEq for OpenPGPv4Fingerprint
impl Eq for OpenPGPv4Fingerprint
impl StructuralPartialEq for OpenPGPv4Fingerprint
Auto Trait Implementations§
impl Freeze for OpenPGPv4Fingerprint
impl RefUnwindSafe for OpenPGPv4Fingerprint
impl Send for OpenPGPv4Fingerprint
impl Sync for OpenPGPv4Fingerprint
impl Unpin for OpenPGPv4Fingerprint
impl UnwindSafe for OpenPGPv4Fingerprint
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
)