Type Alias Md5Checksum

Source
pub type Md5Checksum = Checksum<Md5>;
Expand description

A checksum using the Md5 algorithm

Aliased Type§

struct Md5Checksum {
    digest: Vec<u8>,
    _marker: PhantomData<CoreWrapper<Md5Core>>,
}

Fields§

§digest: Vec<u8>§_marker: PhantomData<CoreWrapper<Md5Core>>

Implementations

Source§

impl<D: Digest> Checksum<D>

Source

pub fn calculate_from(input: impl AsRef<[u8]>) -> Self

Calculate a new Checksum for data that may be represented as a list of bytes

§Examples
use alpm_types::{digests::Blake2b512, Checksum};

assert_eq!(
    format!("{}", Checksum::<Blake2b512>::calculate_from("foo\n")),
    "d202d7951df2c4b711ca44b4bcc9d7b363fa4252127e058c1a910ec05b6cd038d71cc21221c031c0359f993e746b07f5965cf8c5c3746a58337ad9ab65278e77",
);
Source

pub fn inner(&self) -> &[u8]

Return a reference to the inner type

Trait Implementations

Source§

impl<D: Clone + Digest> Clone for Checksum<D>

Source§

fn clone(&self) -> Checksum<D>

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<D: Digest> Debug for Checksum<D>

Use Display as Debug impl, since the byte representation and PhantomData field aren’t relevant for debugging purposes.

Source§

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

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

impl<'de, D: Digest> Deserialize<'de> for Checksum<D>

Source§

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

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

impl<D: Digest> Display for Checksum<D>

Source§

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

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

impl<D: Digest> FromStr for Checksum<D>

Source§

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

Create a new Checksum from a hex string and return it in a Result

All whitespaces are removed from the input and it is processed as a lowercase string. An Error is returned, if the input length does not match the output size for the given supported algorithm, or if the provided hex string could not be converted to a list of bytes.

§Examples
use std::str::FromStr;
use alpm_types::{digests::Blake2b512, Checksum};

assert!(Checksum::<Blake2b512>::from_str("d202d7951df2c4b711ca44b4bcc9d7b363fa4252127e058c1a910ec05b6cd038d71cc21221c031c0359f993e746b07f5965cf8c5c3746a58337ad9ab65278e77").is_ok());
assert!(Checksum::<Blake2b512>::from_str("d2 02 d7 95 1d f2 c4 b7 11 ca 44 b4 bc c9 d7 b3 63 fa 42 52 12 7e 05 8c 1a 91 0e c0 5b 6c d0 38 d7 1c c2 12 21 c0 31 c0 35 9f 99 3e 74 6b 07 f5 96 5c f8 c5 c3 74 6a 58 33 7a d9 ab 65 27 8e 77").is_ok());
assert!(Checksum::<Blake2b512>::from_str("d202d7951df2c4b711ca44b4bcc9d7b363fa4252127e058c1a910ec05b6cd038d71cc21221c031c0359f993e746b07f5965cf8c5c3746a58337ad9ab65278e7").is_err());
assert!(Checksum::<Blake2b512>::from_str("d202d7951df2c4b711ca44b4bcc9d7b363fa4252127e058c1a910ec05b6cd038d71cc21221c031c0359f993e746b07f5965cf8c5c3746a58337ad9ab65278e7x").is_err());
Source§

type Err = Error

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

impl<D: Digest> PartialEq for Checksum<D>

Source§

fn eq(&self, other: &Self) -> 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<D: Digest> Serialize for Checksum<D>

Source§

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

Serialize a Checksum into a hex String representation.

We chose hex as byte vectors are imperformant and considered bad practice for non-binary formats like JSON or YAML