1#[derive(Debug)]
14pub struct CertHashRef<'a> {
15 pub algorithm: &'a str,
16 pub value: &'a [u8],
17}
18
19impl<'a> From<CertHashRef<'a>> for web_sys::WebTransportHash {
20 fn from(cert_hash: CertHashRef<'a>) -> Self {
21 let mut wt_hash = Self::new();
22
23 wt_hash.algorithm(cert_hash.algorithm);
24 wt_hash.value(&js_sys::Uint8Array::from(cert_hash.value));
25
26 wt_hash
27 }
28}
29
30impl<'a> From<CertHashRef<'a>> for js_sys::Object {
31 fn from(cert_hash: CertHashRef<'a>) -> Self {
32 web_sys::WebTransportHash::from(cert_hash).into()
33 }
34}
35
36impl<'a> From<CertHashRef<'a>> for wasm_bindgen::JsValue {
37 fn from(cert_hash: CertHashRef<'a>) -> Self {
38 web_sys::WebTransportHash::from(cert_hash).into()
39 }
40}
41
42pub fn assign<'a, Iter>(options: &mut web_sys::WebTransportOptions, iter: Iter)
46where
47 Iter: IntoIterator<Item = CertHashRef<'a>>,
48{
49 let array: js_sys::Array = iter.into_iter().map(wasm_bindgen::JsValue::from).collect();
50 options.server_certificate_hashes(&array);
51}