webtransport_h3 (webtransport v0.2.3)

View Source

Minimal runtime wrapper for an HTTP/3 WebTransport session.

The HTTP/3 CONNECT stream is managed through quic_h3. Native WebTransport streams and datagrams use the underlying QUIC connection.

Summary

Functions

Send a CLOSE_WEBTRANSPORT_SESSION capsule and FIN the CONNECT stream.

Decode an incoming QUIC datagram into session ID and payload.

Decode the session ID and stream kind from the start of an incoming stream.

Send a DRAIN_WEBTRANSPORT_SESSION capsule to signal graceful shutdown.

Return the HTTP/3 connection pid.

Create a new H3 transport state with no router.

Create a new H3 transport state, optionally attaching a stream router.

Open a new bidirectional WebTransport stream on the QUIC connection.

Open a new unidirectional WebTransport stream on the QUIC connection.

Return the peer's advertised WebTransport settings.

Return the underlying QUIC connection pid.

Reset a stream with the given application error code mapped to the QUIC error space.

Return the stream router pid, or undefined if none is set.

Send data on a stream. Routes through H3 for the CONNECT stream, QUIC for native streams.

Send an unreliable datagram, prefixed with the quarter stream ID.

Return the WebTransport session ID (the CONNECT stream ID).

Request that the peer stop sending on a stream with the given error code.

Return a new state with updated peer settings.

Return a new state with the given stream router pid.

Types

state/0

-opaque state()

Functions

close_session(State, ErrorCode, Reason)

-spec close_session(state(), non_neg_integer(), binary()) -> ok | {error, term()}.

Send a CLOSE_WEBTRANSPORT_SESSION capsule and FIN the CONNECT stream.

decode_datagram(Bin)

-spec decode_datagram(binary()) ->
                         {ok, non_neg_integer(), binary()} | {more, pos_integer()} | {error, term()}.

Decode an incoming QUIC datagram into session ID and payload.

decode_stream_header(Bin)

-spec decode_stream_header(binary()) ->
                              {ok, non_neg_integer(), wt_h3_capsule:stream_kind(), binary()} |
                              {more, pos_integer()} |
                              {error, term()}.

Decode the session ID and stream kind from the start of an incoming stream.

drain_session(State)

-spec drain_session(state()) -> ok | {error, term()}.

Send a DRAIN_WEBTRANSPORT_SESSION capsule to signal graceful shutdown.

h3_conn(State)

-spec h3_conn(state()) -> pid().

Return the HTTP/3 connection pid.

new(H3Conn, SessionId)

-spec new(pid(), non_neg_integer()) -> state().

Create a new H3 transport state with no router.

new(H3Conn, SessionId, Router)

-spec new(pid(), non_neg_integer(), undefined | pid()) -> state().

Create a new H3 transport state, optionally attaching a stream router.

open_bidi_stream(State)

-spec open_bidi_stream(state()) -> {ok, non_neg_integer(), state()} | {error, term()}.

Open a new bidirectional WebTransport stream on the QUIC connection.

open_uni_stream(State)

-spec open_uni_stream(state()) -> {ok, non_neg_integer(), state()} | {error, term()}.

Open a new unidirectional WebTransport stream on the QUIC connection.

peer_settings(State)

-spec peer_settings(state()) -> map().

Return the peer's advertised WebTransport settings.

quic_conn(State)

-spec quic_conn(state()) -> pid().

Return the underlying QUIC connection pid.

reset_stream(State, StreamId, ErrorCode, ReliableSize)

-spec reset_stream(state(), non_neg_integer(), non_neg_integer(), non_neg_integer()) ->
                      ok | {error, term()}.

Reset a stream with the given application error code mapped to the QUIC error space.

router(State)

-spec router(state()) -> undefined | pid().

Return the stream router pid, or undefined if none is set.

send(State, StreamId, Data, Fin)

-spec send(state(), non_neg_integer(), iodata(), boolean()) -> ok | {error, term()}.

Send data on a stream. Routes through H3 for the CONNECT stream, QUIC for native streams.

send_datagram(State, Data)

-spec send_datagram(state(), binary()) -> ok | {error, term()}.

Send an unreliable datagram, prefixed with the quarter stream ID.

session_id(State)

-spec session_id(state()) -> non_neg_integer().

Return the WebTransport session ID (the CONNECT stream ID).

stop_sending(State, StreamId, ErrorCode)

-spec stop_sending(state(), non_neg_integer(), non_neg_integer()) -> ok | {error, term()}.

Request that the peer stop sending on a stream with the given error code.

with_peer_settings(State, PeerSettings)

-spec with_peer_settings(state(), map()) -> state().

Return a new state with updated peer settings.

with_router(State, Router)

-spec with_router(state(), undefined | pid()) -> state().

Return a new state with the given stream router pid.