Trait digest_headers::prelude::AsDigest
[−]
[src]
pub trait AsDigest: Sized { type Error; fn as_digest(self, sha_size: ShaSize) -> Result<(Self, Digest), Self::Error>; }
The AsDigest
trait provides a method to retrieve a Digest
from a given type.
Associated Types
type Error
The Error
type defines any error that may occur in the creation of the Digest
.
Required Methods
fn as_digest(self, sha_size: ShaSize) -> Result<(Self, Digest), Self::Error>
Retrieve a Digest
from a given type, returning Self and the Digest.
An Example with Hyper
let uri = "http://example.com".parse().unwrap(); let json = r#"{"Library":"Hyper"}"#; let mut req: Request<Body> = Request::new(Method::Post, uri); req.set_body(json); let (mut req, digest) = req.as_digest(ShaSize::TwoFiftySix)?; req.headers_mut().set(DigestHeader(digest));
Implementations on Foreign Types
impl AsDigest for Request<Body>
[src]
type Error = Error
fn as_digest(self, sha_size: ShaSize) -> Result<(Self, Digest), Self::Error>
[src]
We need to consume the body Stream in order to access it, but we can set the body again after we've concatenated the whole body together, since getting a Digest is non-destructive.
Do not call this method from the context of an asyncronous executor unless you are certain that the body in the Request is a single item. It will block waiting for all items.