webtransport_ffi library
Native only entry points.
Import this instead of package:webtransport/webtransport.dart
when you need functionality that a browser cannot provide:
- WebTransportServer — listening for WebTransport sessions (the
wtransportserver side, including self-signed identities and the certificate digest a client should pin); - NativeWebTransport and NativeSession — the in-process backend, which avoids the worker isolate (and therefore the message hop) when the calling isolate is already dedicated;
- WebTransportWorker — the worker isolate itself, for explicit lifecycle control;
- the raw
ffigenbindings (wt_*functions andwt_*_tstructs); - NativeBuffer — native memory Dart can write into and hand over without copying;
- WebTransportRuntime — runtime lifecycle and diagnostics.
This library is not available on the web: it reaches into dart:ffi.
Classes
- NativeBuffer
- Native memory shared with the transport.
- NativeEvent
- A completion reported by the native layer, copied out of its batch.
- NativeReceiveStream
- The reading half of a stream.
- NativeSendStream
- The writing half of a stream.
- NativeSession
-
An established session on top of a
wt_connection_t. - NativeWebTransport
- A WebTransport client session backed by the native code asset.
- WebTransport
-
Mirrors the browser
WebTransportinterface. - WebTransportBidirectionalStream
-
Mirrors
WebTransportBidirectionalStream. - WebTransportCloseInfo
-
Mirrors
WebTransportCloseInfo. - WebTransportDatagramDuplexStream
-
Mirrors
WebTransportDatagramDuplexStream. - WebTransportDerIdentity
- DER encoded material held in memory.
- WebTransportHash
-
Mirrors
WebTransportHash. - WebTransportOptions
-
Mirrors
WebTransportOptions. - WebTransportPemFileIdentity
- PEM encoded files on disk.
- WebTransportPemIdentity
- PEM encoded material held in memory.
- WebTransportReceiveStream
-
The reading half of a stream, in place of the browser
ReadableStream. - WebTransportRuntime
- Owns the native runtime and routes completions to their Dart completers.
- WebTransportSelfSignedIdentity
- A self-signed certificate generated in memory.
- WebTransportSendStream
-
The writing half of a stream, in place of the browser
WritableStream. - WebTransportSendStreamOptions
-
Mirrors
WebTransportSendStreamOptions. - WebTransportServer
- A listening WebTransport server.
- WebTransportServerConfig
- Configuration of a WebTransportServer.
- WebTransportServerIdentity
- How the server obtains its TLS identity.
- WebTransportSessionRequest
- An incoming session request that the application has to accept or reject.
- WebTransportStats
-
A subset of
WebTransportStats. - WebTransportWorker
- Spawns and owns a worker isolate running the native implementation.
- wt_buffer_t
- Opaque handle to a native byte buffer.
- wt_client_config_t
- Opaque handle to a client configuration.
- wt_client_t
- Opaque handle to a client endpoint.
- wt_connection_t
- Opaque handle to a WebTransport session.
- wt_event_batch_t
-
An owned group of one or more
wt_event_t. - wt_event_t
- One completed unit of work.
- wt_header_t
- A name/value pair; both strings are NUL-terminated UTF-8.
- wt_recv_stream_t
- Opaque handle to a receiving half of a stream.
- wt_runtime_config_t
-
Configuration for
wt_runtime_init. - wt_send_stream_t
- Opaque handle to a sending half of a stream.
- wt_server_config_t
- Opaque handle to a server configuration.
- wt_server_t
- Opaque handle to a server endpoint.
- wt_session_request_t
- Opaque handle to an incoming session request.
Enums
- WebTransportCongestionControl
-
Congestion control hint, mirroring
WebTransportCongestionControl. - WebTransportErrorSource
-
Mirrors
WebTransportErrorSource. - WebTransportReliabilityMode
-
Mirrors
WebTransportReliabilityMode. - wt_op_t
- Kind of work an event reports on.
- wt_status_t
- Result of an operation.
Extensions
- WebTransportReceiveStreamX on WebTransportReceiveStream
- Convenience helpers shared by every backend.
Constants
- WT_ABI_VERSION → const int
- WT_ABI_VERSION_MAJOR → const int
- WT_ABI_VERSION_MINOR → const int
Properties
- nativeAbiVersion → int
-
ABI version of the loaded library, packed as
(major << 16) | minor.no setter - nativeRuntime → WebTransportRuntime
-
The runtime backing the in-process native implementation.
no setter
- nativeVersion → String
-
Version string reported by the library that was actually loaded.
no setter
Functions
-
wt_abi_version(
) → int -
Runtime ABI version of the loaded library, packed as
(major << 16) | minor. -
wt_alloc(
int size) → Pointer< Uint8> -
Allocates
sizebytes from the same allocator used bywt_buffer_t. -
wt_batch_count(
Pointer< wt_event_batch_t> batch) → int -
Number of events in
batch. -
wt_batch_events(
Pointer< wt_event_batch_t> batch) → Pointer<wt_event_t> -
Pointer to the first of
wt_batch_count(batch)contiguouswt_event_t. -
wt_batch_free(
Pointer< wt_event_batch_t> batch) → void - Releases a batch and everything it owns. Passing NULL is a no-op.
-
wt_buffer_capacity(
Pointer< wt_buffer_t> buffer) → int - Allocated capacity in bytes.
-
wt_buffer_data(
Pointer< wt_buffer_t> buffer) → Pointer<Uint8> - Writable pointer to the buffer contents.
-
wt_buffer_data_const(
Pointer< wt_buffer_t> buffer) → Pointer<Uint8> - Read-only pointer to the buffer contents.
-
wt_buffer_free(
Pointer< wt_buffer_t> buffer) → void - Releases the buffer handle.
-
wt_buffer_len(
Pointer< wt_buffer_t> buffer) → int - Logical length in bytes.
-
wt_buffer_new(
int capacity) → Pointer< wt_buffer_t> -
Allocates
capacitybytes (uninitialised, logical length starts at 0). -
wt_buffer_reserve(
Pointer< wt_buffer_t> buffer, int capacity) → wt_status_t -
wt_buffer_set_len(
Pointer< wt_buffer_t> buffer, int length) → wt_status_t -
wt_client_close(
Pointer< wt_client_t> client, int error_code, Pointer<Uint8> reason, int reason_len, int op_id) → wt_status_t -
wt_client_config_free(
Pointer< wt_client_config_t> config) → void - Releases a client configuration handle.
-
wt_client_config_new(
) → Pointer< wt_client_config_t> - Creates a client configuration with defaults (dual-stack ephemeral bind, platform root certificates).
-
wt_client_config_set_bind_address(
Pointer< wt_client_config_t> config, Pointer<Char> ip, int port) → wt_status_t -
wt_client_config_set_certificate_hashes(
Pointer< wt_client_config_t> config, Pointer<Uint8> digests, int digest_count) → wt_status_t -
wt_client_config_set_connect_timeout_ms(
Pointer< wt_client_config_t> config, int timeout_ms) → wt_status_t -
wt_client_config_set_idle_timeout_ms(
Pointer< wt_client_config_t> config, int timeout_ms) → wt_status_t -
wt_client_config_set_keep_alive_ms(
Pointer< wt_client_config_t> config, int interval_ms) → wt_status_t -
wt_client_config_set_native_roots(
Pointer< wt_client_config_t> config) → wt_status_t -
wt_client_config_set_no_certificate_validation(
Pointer< wt_client_config_t> config) → wt_status_t -
wt_client_connect(
Pointer< wt_client_t> client, Pointer<Char> url, Pointer<wt_header_t> headers, int count, int op_id) → wt_status_t -
wt_client_free(
Pointer< wt_client_t> client) → void - Releases a client handle (the endpoint is closed once in-flight work ends).
-
wt_client_local_port(
Pointer< wt_client_t> client) → int - Local UDP port the client is bound to, or 0 when unknown.
-
wt_client_new(
Pointer< wt_client_config_t> config, Pointer<Int> out_status) → Pointer<wt_client_t> - Creates a client endpoint (binds a UDP socket).
-
wt_client_open_connections(
Pointer< wt_client_t> client) → int - Number of currently open connections on this endpoint.
-
wt_connection_accept_bi(
Pointer< wt_connection_t> connection, int op_id) → wt_status_t -
wt_connection_accept_uni(
Pointer< wt_connection_t> connection, int op_id) → wt_status_t -
wt_connection_close(
Pointer< wt_connection_t> connection, int error_code, Pointer<Uint8> reason, int reason_len) → wt_status_t -
wt_connection_closed(
Pointer< wt_connection_t> connection, int op_id) → wt_status_t -
wt_connection_export_keying_material(
Pointer< wt_connection_t> connection, Pointer<Uint8> out, int out_len, Pointer<Uint8> label, int label_len, Pointer<Uint8> context, int context_len) → wt_status_t -
wt_connection_free(
Pointer< wt_connection_t> connection) → void - Releases a connection handle (the session itself is not closed).
-
wt_connection_max_datagram_size(
Pointer< wt_connection_t> connection) → int - Maximum datagram payload, or -1 when the peer does not support datagrams.
-
wt_connection_open_bi(
Pointer< wt_connection_t> connection, int op_id) → wt_status_t -
wt_connection_open_uni(
Pointer< wt_connection_t> connection, int op_id) → wt_status_t -
wt_connection_recv_datagram(
Pointer< wt_connection_t> connection, int op_id) → wt_status_t -
wt_connection_remote_ip(
Pointer< wt_connection_t> connection, Pointer<Char> buffer, Pointer<Size> len) → wt_status_t -
wt_connection_remote_port(
Pointer< wt_connection_t> connection) → int - Peer UDP port.
-
wt_connection_rtt_us(
Pointer< wt_connection_t> connection) → int - Smoothed round-trip time estimate, in microseconds.
-
wt_connection_send_datagram(
Pointer< wt_connection_t> connection, Pointer<Uint8> payload, int len) → wt_status_t -
wt_connection_session_id(
Pointer< wt_connection_t> connection) → int - WebTransport session id.
-
wt_connection_stable_id(
Pointer< wt_connection_t> connection) → int - Stable per-endpoint connection identifier.
-
wt_dealloc(
Pointer< Uint8> data, int size) → void -
Frees memory previously returned by
wt_alloc. -
wt_live_buffer_count(
) → int - Current number of live native buffers.
-
wt_recv_stream_free(
Pointer< wt_recv_stream_t> stream) → void - Releases a receive stream handle.
-
wt_recv_stream_id(
Pointer< wt_recv_stream_t> stream) → int - QUIC stream id.
-
wt_recv_stream_is_busy(
Pointer< wt_recv_stream_t> stream) → int - True when an operation is currently in flight on the stream.
-
wt_recv_stream_read(
Pointer< wt_recv_stream_t> stream, Pointer<Uint8> destination, int capacity, int op_id) → wt_status_t -
wt_recv_stream_read_exact(
Pointer< wt_recv_stream_t> stream, Pointer<Uint8> destination, int len, int op_id) → wt_status_t -
wt_recv_stream_stop(
Pointer< wt_recv_stream_t> stream, int error_code) → wt_status_t -
wt_runtime_init(
Pointer< wt_runtime_config_t> config, wt_events_cb_t callback, Pointer<Void> ctx) → wt_status_t -
wt_runtime_is_running(
) → int - Returns 1 while the runtime is running, 0 otherwise.
-
wt_runtime_set_callback(
wt_events_cb_t callback, Pointer< Void> ctx) → wt_status_t -
wt_runtime_shutdown(
) → wt_status_t -
wt_runtime_wait_idle(
int timeout_ms) → wt_status_t -
wt_send_stream_finish(
Pointer< wt_send_stream_t> stream, int op_id) → wt_status_t -
wt_send_stream_free(
Pointer< wt_send_stream_t> stream) → void - Releases a send stream handle.
-
wt_send_stream_id(
Pointer< wt_send_stream_t> stream) → int - QUIC stream id.
-
wt_send_stream_is_busy(
Pointer< wt_send_stream_t> stream) → int - True when an operation is currently in flight on the stream.
-
wt_send_stream_priority(
Pointer< wt_send_stream_t> stream) → int - Stream priority (initial: 0).
-
wt_send_stream_reset(
Pointer< wt_send_stream_t> stream, int error_code) → wt_status_t -
wt_send_stream_set_priority(
Pointer< wt_send_stream_t> stream, int priority) → wt_status_t -
wt_send_stream_stopped(
Pointer< wt_send_stream_t> stream, int op_id) → wt_status_t -
wt_send_stream_write(
Pointer< wt_send_stream_t> stream, Pointer<Uint8> data, int len, int op_id) → wt_status_t -
wt_send_stream_write_all(
Pointer< wt_send_stream_t> stream, Pointer<Uint8> data, int len, int op_id) → wt_status_t -
wt_server_accept(
Pointer< wt_server_t> server, int op_id) → wt_status_t -
wt_server_close(
Pointer< wt_server_t> server, int error_code, Pointer<Uint8> reason, int reason_len, int op_id) → wt_status_t -
wt_server_config_add_certificate_der(
Pointer< wt_server_config_t> config, Pointer<Uint8> der, int len) → wt_status_t -
wt_server_config_add_certificate_pem(
Pointer< wt_server_config_t> config, Pointer<Char> pem, int len) → wt_status_t -
wt_server_config_certificate_hash(
Pointer< wt_server_config_t> config, Pointer<Uint8> out) → wt_status_t -
wt_server_config_free(
Pointer< wt_server_config_t> config) → void - Releases a server configuration handle.
-
wt_server_config_new(
) → Pointer< wt_server_config_t> - Creates a server configuration with defaults (dual-stack bind, no identity).
-
wt_server_config_set_allow_migration(
Pointer< wt_server_config_t> config, int allow) → wt_status_t -
wt_server_config_set_bind_address(
Pointer< wt_server_config_t> config, Pointer<Char> ip, int port) → wt_status_t -
wt_server_config_set_identity_pem_files(
Pointer< wt_server_config_t> config, Pointer<Char> certificate_path, Pointer<Char> private_key_path) → wt_status_t -
wt_server_config_set_idle_timeout_ms(
Pointer< wt_server_config_t> config, int timeout_ms) → wt_status_t -
wt_server_config_set_keep_alive_ms(
Pointer< wt_server_config_t> config, int interval_ms) → wt_status_t -
wt_server_config_set_private_key(
Pointer< wt_server_config_t> config, Pointer<Uint8> key, int len, int pem) → wt_status_t -
wt_server_config_set_self_signed(
Pointer< wt_server_config_t> config, Pointer<Pointer< sans, int san_count) → wt_status_tChar> > -
wt_server_free(
Pointer< wt_server_t> server) → void - Releases a server handle.
-
wt_server_local_port(
Pointer< wt_server_t> server) → int - Local UDP port the server is bound to, or 0 when unknown.
-
wt_server_new(
Pointer< wt_server_config_t> config, Pointer<Int> out_status) → Pointer<wt_server_t> - Creates a server endpoint (binds a UDP socket and configures TLS).
-
wt_server_open_connections(
Pointer< wt_server_t> server) → int - Number of currently open connections on this endpoint.
-
wt_server_reload_config(
Pointer< wt_server_t> server, Pointer<wt_server_config_t> config, int rebind, int op_id) → wt_status_t -
wt_session_request_accept(
Pointer< wt_session_request_t> request, Pointer<wt_header_t> headers, int count, int op_id) → wt_status_t -
:authorityof the request (borrowed). -
wt_session_request_forbidden(
Pointer< wt_session_request_t> request, int op_id) → wt_status_t -
wt_session_request_free(
Pointer< wt_session_request_t> request) → void - Releases a session request handle without answering it.
-
wt_session_request_header(
Pointer< wt_session_request_t> request, Pointer<Char> name) → Pointer<Char> - Looks up a header by (case-insensitive) name; NULL when absent.
-
wt_session_request_header_at(
Pointer< wt_session_request_t> request, int index, Pointer<Pointer< out_name, Pointer<Char> >Pointer< out_value) → wt_status_tChar> > -
wt_session_request_header_count(
Pointer< wt_session_request_t> request) → int - Number of request headers.
-
wt_session_request_not_found(
Pointer< wt_session_request_t> request, int op_id) → wt_status_t -
wt_session_request_origin(
Pointer< wt_session_request_t> request) → Pointer<Char> -
originheader, or NULL when absent (borrowed). -
wt_session_request_path(
Pointer< wt_session_request_t> request) → Pointer<Char> -
:pathof the WebTransport request. -
wt_session_request_remote_ip(
Pointer< wt_session_request_t> request, Pointer<Char> buffer, Pointer<Size> len) → wt_status_t -
wt_session_request_remote_port(
Pointer< wt_session_request_t> request) → int - Peer UDP port.
-
wt_session_request_too_many_requests(
Pointer< wt_session_request_t> request, int op_id) → wt_status_t -
wt_session_request_user_agent(
Pointer< wt_session_request_t> request) → Pointer<Char> -
user-agentheader, or NULL when absent (borrowed). -
wt_status_string(
int status) → Pointer< Char> - NUL-terminated static human readable description of a status code.
-
wt_version_string(
) → Pointer< Char> - NUL-terminated static version string.
Typedefs
-
Dartwt_events_cb_tFunction
= void Function(Pointer<
Void> ctx, Pointer<wt_event_batch_t> batch) -
wt_events_cb_t
= Pointer<
NativeFunction< wt_events_cb_tFunction> > - Event sink.
-
wt_events_cb_tFunction
= Void Function(Pointer<
Void> ctx, Pointer<wt_event_batch_t> batch)
Exceptions / Errors
- WebTransportError
-
Mirrors
WebTransportError. - WebTransportException
- Raised when the native layer reports a non-success status.