webtransport_stream (webtransport v0.2.6)
View SourceWebTransport stream state management.
This module provides functional state management for individual WebTransport streams. Streams are managed by the session process and don't run as separate processes.
Stream IDs follow these conventions: - Client-initiated bidirectional: 0, 4, 8, ... (4n) - Server-initiated bidirectional: 1, 5, 9, ... (4n+1) - Client-initiated unidirectional: 2, 6, 10, ... (4n+2) - Server-initiated unidirectional: 3, 7, 11, ... (4n+3)
Summary
Functions
Append data to the send buffer without actually sending.
Return the total bytes received on this stream so far.
Return the total bytes sent on this stream so far.
Immediately close both sides of the stream.
Half-close the local (write) side of the stream.
Half-close the remote (read) side of the stream. Equivalent to receive_fin/1.
Return and clear the receive buffer.
Return and clear the send buffer.
Return the stream ID.
Derive the initiator (client or server) from a stream ID.
Return true if the stream or stream ID is bidirectional.
Return true if the stream ID was initiated by the client.
Return true if the stream is not fully closed.
Return true if the remote side can still send data on this stream.
Return true if the stream ID was initiated by the server.
Return true if the stream or stream ID is unidirectional.
Return true if the local side can still write to this stream.
Create a new stream with symmetric send/recv windows.
Create a new stream with separate send and recv window sizes.
Record a STOP_SENDING from the peer, blocking our write side. Returns {error, duplicate} if already received (draft-14 s6.3).
Record received data, updating flow control counters and the recv buffer.
Record that the remote side sent FIN, transitioning the stream state.
Return the pending receive buffer contents.
Return the receive flow-control window size.
Reset the stream with the given error code, discarding the send buffer.
Send data on the stream, respecting flow control. Returns the bytes actually sent.
Return the pending send buffer contents.
Return the send flow-control window size.
Return the current stream state (open, half_closed_local, half_closed_remote, closed).
Record that we sent STOP_SENDING to the peer, shutting our read side.
Derive the stream type (bidi or uni) from a stream ID.
Return the stream type: bidi or uni.
Set a new receive flow-control window size.
Set a new send flow-control window size.
Types
Functions
Append data to the send buffer without actually sending.
-spec bytes_received(stream()) -> non_neg_integer().
Return the total bytes received on this stream so far.
-spec bytes_sent(stream()) -> non_neg_integer().
Return the total bytes sent on this stream so far.
Immediately close both sides of the stream.
Half-close the local (write) side of the stream.
Half-close the remote (read) side of the stream. Equivalent to receive_fin/1.
Return and clear the receive buffer.
Return and clear the send buffer.
-spec id(stream()) -> non_neg_integer().
Return the stream ID.
-spec initiator(non_neg_integer()) -> client | server.
Derive the initiator (client or server) from a stream ID.
-spec is_bidi(non_neg_integer() | stream()) -> boolean().
Return true if the stream or stream ID is bidirectional.
-spec is_client_initiated(non_neg_integer()) -> boolean().
Return true if the stream ID was initiated by the client.
Return true if the stream is not fully closed.
Return true if the remote side can still send data on this stream.
-spec is_server_initiated(non_neg_integer()) -> boolean().
Return true if the stream ID was initiated by the server.
-spec is_uni(non_neg_integer() | stream()) -> boolean().
Return true if the stream or stream ID is unidirectional.
Return true if the local side can still write to this stream.
-spec new(non_neg_integer(), bidi | uni, non_neg_integer()) -> stream().
Create a new stream with symmetric send/recv windows.
-spec new(non_neg_integer(), bidi | uni, non_neg_integer(), non_neg_integer()) -> stream().
Create a new stream with separate send and recv window sizes.
-spec peer_stop_sending(stream(), non_neg_integer()) -> {ok, stream()} | {error, duplicate}.
Record a STOP_SENDING from the peer, blocking our write side. Returns {error, duplicate} if already received (draft-14 s6.3).
Record received data, updating flow control counters and the recv buffer.
Record that the remote side sent FIN, transitioning the stream state.
Return the pending receive buffer contents.
-spec recv_window(stream()) -> non_neg_integer().
Return the receive flow-control window size.
-spec reset(stream(), non_neg_integer()) -> stream().
Reset the stream with the given error code, discarding the send buffer.
Send data on the stream, respecting flow control. Returns the bytes actually sent.
Return the pending send buffer contents.
-spec send_window(stream()) -> non_neg_integer().
Return the send flow-control window size.
-spec state(stream()) -> stream_state().
Return the current stream state (open, half_closed_local, half_closed_remote, closed).
-spec stop_sending(stream(), non_neg_integer()) -> stream().
Record that we sent STOP_SENDING to the peer, shutting our read side.
-spec stream_type(non_neg_integer()) -> bidi | uni.
Derive the stream type (bidi or uni) from a stream ID.
-spec type(stream()) -> bidi | uni.
Return the stream type: bidi or uni.
-spec update_recv_window(stream(), non_neg_integer()) -> stream().
Set a new receive flow-control window size.
-spec update_send_window(stream(), non_neg_integer()) -> stream().
Set a new send flow-control window size.