ws_native library
Native (Rust) transport for package:ws, with the library bundled by a
build hook (Flutter, dart build cli, dart run, dart test).
void main() {
WsNative.install(); // falls back to pure Dart if the library is missing
runApp(...);
}
Executables built with dart compile exe cannot depend on this package
(it has a build hook); they load the library by path with
package:ws/native.dart instead.
On the web this library is a stub: WsNative.install returns false
and the browser transport is used, so one main.dart serves every
platform. WsNative.library exists only where dart:ffi does.
Classes
- NativeTransport
- The Rust transport: tokio + tungstenite + rustls, JSON parsed into a tape off the Dart thread, messages delivered in batches as external typed data (no copies), receive credits for flow control.
- WsNative
-
Installs the native transport as the default for
WebSocketClient. - WsNativeLibrary
-
The Rust library (
libws_native), loaded and checked.