pub struct DigestStream { /* private fields */ }
Expand description
A Rust-friendly wrapper around the non-standard crypto.DigestStream API
Example usage:
let digest_stream = DigestStream::new(DigestStreamAlgorithm::Sha256);
// create a ReadableStream from a string
let mut req_init = web_sys::RequestInit::new();
req_init.method("POST");
req_init.body(Some(&JsValue::from_str("foo")));
let req = web_sys::Request::new_with_str_and_init("http://internal", &req_init).unwrap();
let body = req.body().unwrap();
// just kick the promise off to the background, we'll await the digest itself
// since this is piped to a JS readable stream, call .raw() to get the underlying JS object
let _ = body.pipe_to(digest_stream.raw());
let bytes:Vec<u8> = digest_stream.digest().await.unwrap().to_vec();
Implementations§
Source§impl DigestStream
impl DigestStream
pub fn new(algo: DigestStreamAlgorithm) -> Self
pub async fn digest(&self) -> Result<Uint8Array, Error>
pub fn raw(&self) -> &DigestStream
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DigestStream
impl RefUnwindSafe for DigestStream
impl !Send for DigestStream
impl !Sync for DigestStream
impl Unpin for DigestStream
impl UnwindSafe for DigestStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more