alpm_types

Struct OpenPGPv4Fingerprint

source
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

source

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.

source

pub fn as_str(&self) -> &str

Returns a reference to the inner OpenPGP v4 fingerprint as a &str.

source

pub fn into_inner(self) -> String

Consumes the OpenPGPv4Fingerprint and returns the inner String.

Trait Implementations§

source§

impl Clone for OpenPGPv4Fingerprint

source§

fn clone(&self) -> OpenPGPv4Fingerprint

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for OpenPGPv4Fingerprint

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for OpenPGPv4Fingerprint

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Converts the OpenPGPv4Fingerprint to a uppercase String.

source§

impl FromStr for OpenPGPv4Fingerprint

source§

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§

type Err = Error

The associated error which can be returned from parsing.
source§

impl PartialEq for OpenPGPv4Fingerprint

source§

fn eq(&self, other: &OpenPGPv4Fingerprint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for OpenPGPv4Fingerprint

source§

impl StructuralPartialEq for OpenPGPv4Fingerprint

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T