[][src]Struct bandsocks::ContentDigest

pub struct ContentDigest { /* fields omitted */ }

A digest securely identifies the specific contents of a binary object

Digests include the hash format, which is currently always sha256

Implementations

impl ContentDigest[src]

pub fn as_str(&self) -> &str[src]

Returns a reference to the existing string representation of a ContentDigest

This string always has a single colon. After the colon is 32 or more characters which will always be lowercase hexadecimal digits. The format specifier before this colon is alphanumeric, with plus, dash, underscore, or dot characters allowed as separators between valid groups of alphanumeric characters.

pub fn from_parts<T: LowerHex>(
    format_part: &str,
    hex_part: &T
) -> Result<Self, ImageError>
[src]

Create a new ContentDigest from parts

The format string and hex string are assembled and parsed.

pub fn from_content(content_bytes: &[u8]) -> Self[src]

Create a new ContentDigest from content data

This hashes the content using the the sha256 algorithm.

let digest = ContentDigest::from_content(b"cat");
assert_eq!(digest.as_str(), "sha256:77af778b51abd4a3c51c5ddd97204a9c3ae614ebccb75a606c3b6865aed6744e");

pub fn parse(s: &str) -> Result<Self, ImageError>[src]

Parse a str as a ContentDigest

let digest = ContentDigest::parse("format:00112233445566778899aabbccddeeff").unwrap();
assert_eq!(digest.format_str(), "format");
assert_eq!(digest.hex_str(), "00112233445566778899aabbccddeeff")

pub fn format_str(&self) -> &str[src]

Return a reference to the format string portion of this digest.

Currently this is sha256 for all digests we create or recognize.

pub fn hex_str(&self) -> &str[src]

Return a reference to the hexadecimal string portion of this digest.

This is guaranteed to be a string of at least 32 hex digits.

Trait Implementations

impl Clone for ContentDigest[src]

impl Debug for ContentDigest[src]

impl Display for ContentDigest[src]

impl Eq for ContentDigest[src]

impl FromStr for ContentDigest[src]

type Err = ImageError

The associated error which can be returned from parsing.

impl Hash for ContentDigest[src]

impl Ord for ContentDigest[src]

impl PartialEq<ContentDigest> for ContentDigest[src]

impl PartialOrd<ContentDigest> for ContentDigest[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,