Struct digest_headers::Digest
[−]
[src]
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 Clone for Digest[src]
fn clone(&self) -> Digest[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for Digest[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl PartialEq for Digest[src]
fn eq(&self, __arg_0: &Digest) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Digest) -> bool[src]
This method tests for !=.
impl Eq for Digest[src]
impl FromStr for Digest[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>[src]
Parses a string s to return a value of this type. Read more