1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! [`WebTransportWriter`]
//!
//! <https://w3c.github.io/webtransport/#web-transport-writer-interface>
use js_sys::Object;
use wasm_bindgen::prelude::*;
use web_sys::{DomException, WritableStreamDefaultWriter};
#[wasm_bindgen]
extern "C" {
///The `WebTransportWriter` interface.
///
/// <https://w3c.github.io/webtransport/#webtransportwriter>
#[wasm_bindgen(extends = WritableStreamDefaultWriter, extends = Object)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub type WebTransportWriter;
/// ```webidl
/// Promise<undefined> atomicWrite(optional any chunk);
/// ```
///
/// <https://w3c.github.io/webtransport/#dom-webtransportwriter-atomicwrite>
///
/// The atomicWrite method will reject if the chunk given to it could
/// not be sent in its entirety within the flow control window that is
/// current at the time of sending.
/// This behavior is designed to satisfy niche transactional applications
/// sensitive to flow control deadlocks ([RFC9308] Section 4.4).
///
/// NOTE: atomicWrite can still reject after sending some data.
/// Though it provides atomicity with respect to flow control,
/// other errors may occur.
/// atomicWrite does not prevent data from being split between packets or
/// being interleaved with other data.
/// Only the sender learns if atomicWrite fails due to lack of available
/// flow control credit.
///
/// NOTE: Atomic writes can still block if queued behind non-atomic writes.
/// If the atomic write is rejected, everything queued behind it at that
/// moment will be rejected as well.
/// Any non-atomic writes rejected in this way will error the stream.
/// Applications are therefore encouraged to always await atomic writes.
#[wasm_bindgen(method, js_name = atomicWrite, catch)]
pub async fn atomic_write(this: &WebTransportWriter) -> Result<(), DomException>;
/// ```webidl
/// Promise<undefined> atomicWrite(optional any chunk);
/// ```
///
/// <https://w3c.github.io/webtransport/#dom-webtransportwriter-atomicwrite>
///
/// The atomicWrite method will reject if the chunk given to it could
/// not be sent in its entirety within the flow control window that is
/// current at the time of sending.
/// This behavior is designed to satisfy niche transactional applications
/// sensitive to flow control deadlocks ([RFC9308] Section 4.4).
///
/// NOTE: atomicWrite can still reject after sending some data.
/// Though it provides atomicity with respect to flow control,
/// other errors may occur.
/// atomicWrite does not prevent data from being split between packets or
/// being interleaved with other data.
/// Only the sender learns if atomicWrite fails due to lack of available
/// flow control credit.
///
/// NOTE: Atomic writes can still block if queued behind non-atomic writes.
/// If the atomic write is rejected, everything queued behind it at that
/// moment will be rejected as well.
/// Any non-atomic writes rejected in this way will error the stream.
/// Applications are therefore encouraged to always await atomic writes.
#[wasm_bindgen(method, js_name = atomicWrite, catch)]
pub async fn atomic_write_with_chunk(
this: &WebTransportWriter,
chunk: &JsValue,
) -> Result<(), DomException>;
}