Base64OpenPGPSignature

Struct Base64OpenPGPSignature 

Source
pub struct Base64OpenPGPSignature(String);
Expand description

A base64 encoded OpenPGP detached signature.

Wraps a String representing a base64 encoded OpenPGP detached signature ensuring it consists of valid base64 characters.

§Examples

use std::str::FromStr;

use alpm_types::{Error, Base64OpenPGPSignature};

// Create Base64OpenPGPSignature from a valid base64 String
let sig = Base64OpenPGPSignature::from_str("iHUEABYKAB0WIQRizHP4hOUpV7L92IObeih9mi7GCAUCaBZuVAAKCRCbeih9mi7GCIlMAP9ws/jU4f580ZRQlTQKvUiLbAZOdcB7mQQj83hD1Nc/GwD/WIHhO1/OQkpMERejUrLo3AgVmY3b4/uGhx9XufWEbgE=")?;

// Attempting to create a Base64OpenPGPSignature from an invalid base64 String will fail
assert!(Base64OpenPGPSignature::from_str("!@#$^&*").is_err());

// Format as String
assert_eq!(
    format!("{}", sig),
    "iHUEABYKAB0WIQRizHP4hOUpV7L92IObeih9mi7GCAUCaBZuVAAKCRCbeih9mi7GCIlMAP9ws/jU4f580ZRQlTQKvUiLbAZOdcB7mQQj83hD1Nc/GwD/WIHhO1/OQkpMERejUrLo3AgVmY3b4/uGhx9XufWEbgE="
);

Tuple Fields§

§0: String

Implementations§

Source§

impl Base64OpenPGPSignature

Source

pub fn new(signature: String) -> Result<Self, Error>

Creates a new Base64OpenPGPSignature instance.

See Base64OpenPGPSignature::from_str for more information on how the OpenPGP signature is validated.

Source

pub fn as_str(&self) -> &str

Returns a reference to the inner OpenPGP signature as a &str.

Source

pub fn into_inner(self) -> String

Consumes the Base64OpenPGPSignature and returns the inner String.

Trait Implementations§

Source§

impl AsRef<str> for Base64OpenPGPSignature

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Base64OpenPGPSignature

Source§

fn clone(&self) -> Base64OpenPGPSignature

Returns a duplicate 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 Base64OpenPGPSignature

Source§

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

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

impl<'de> Deserialize<'de> for Base64OpenPGPSignature

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Base64OpenPGPSignature

Source§

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

Converts the Base64OpenPGPSignature to a String.

Source§

impl FromStr for Base64OpenPGPSignature

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Creates a new Base64OpenPGPSignature instance after validating that it follows the correct format.

A valid OpenPGP signature should consist only of base64 characters (A-Z, a-z, 0-9, +, /) and may include padding characters (=) at the end.

§Errors

Returns an error if the OpenPGP signature is not valid.

Source§

type Err = Error

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

impl PartialEq for Base64OpenPGPSignature

Source§

fn eq(&self, other: &Base64OpenPGPSignature) -> 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 Serialize for Base64OpenPGPSignature

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Base64OpenPGPSignature

Source§

impl StructuralPartialEq for Base64OpenPGPSignature

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,