[][src]Struct digest_headers::Digest

pub struct Digest { /* fields omitted */ }

Defines the Digest type.

This type can be compared to another Digest, or turned into a String for use in request headers.

Methods

impl Digest
[src]

pub fn new(body: &[u8], size: ShaSize) -> Self
[src]

Creates a new Digest from a series of bytes representing a plaintext body and a ShaSize.

Example

let body = "Here's some text!";
let digest = Digest::new(body.as_bytes(), ShaSize::TwoFiftySix);

println!("Digest: {}", digest);

pub fn from_base64_and_size(digest: String, size: ShaSize) -> Self
[src]

Creates a new Digest from a base64-encoded digest String and a ShaSize.

Example

let sha_size = ShaSize::TwoFiftySix;
let digest_str = "bFp1K/TT36l9YQ8frlh/cVGuWuFEy1rCUNpGwQCSEow=";

let digest = Digest::from_base64_and_size(digest_str.to_owned(), sha_size);

println!("Digest: {}", digest);

pub fn sha_size(&self) -> ShaSize
[src]

Get the ShaSize of the current Digest

pub fn as_string(&self) -> String
[src]

Represents the Digest as a String.

This can be used to produce headers for HTTP Requests.

Example

let digest = Digest::new(b"Hello, world!", ShaSize::TwoFiftySix);

println!("Digest: {}", digest.as_string());

pub fn verify(&self, body: &[u8]) -> Result<(), Error>
[src]

Verify a given message body with the digest.

Example

let body = b"Some message body";
let digest = Digest::new(body, ShaSize::TwoFiftySix);

assert!(digest.verify(body).is_ok());

Trait Implementations

impl Eq for Digest
[src]

impl PartialEq<Digest> for Digest
[src]

impl Clone for Digest
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Digest
[src]

impl Display for Digest
[src]

impl FromStr for Digest
[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for Digest

impl Sync for Digest

Blanket Implementations

impl<T> From for T
[src]

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

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

type Owned = T

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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