Skip to main content

web_wt_sys/webtransport/
web_transport_hash.rs

1//! [`WebTransportHash`]
2//!
3//! <https://w3c.github.io/webtransport/#dictdef-webtransporthash>
4
5use wasm_bindgen::prelude::*;
6
7crate::dictionary_type! {
8    /// ```webidl
9    /// dictionary WebTransportHash {
10    ///   DOMString algorithm;
11    ///   BufferSource value;
12    /// };
13    /// ```
14    ///
15    /// <https://w3c.github.io/webtransport/#dictdef-webtransporthash>
16    pub type WebTransportHash {
17        algorithm_raw: js_sys::JsString => algorithm
18        value_raw: JsValue => value
19    }
20}
21
22impl WebTransportHash {
23    /// Set the algorithm.
24    pub fn set_algorithm(&self, val: &str) {
25        self.set_algorithm_raw(val.into())
26    }
27
28    /// Set the value.
29    pub fn set_value(&self, val: &[u8]) {
30        self.set_value_raw(js_sys::Uint8Array::from(val).into())
31    }
32}