Skip to main content

Crate nexus_async_net

Crate nexus_async_net 

Source
Expand description

nexus-async-net — async adapters for nexus-net.

Thin async wrappers over nexus-net’s synchronous protocol primitives. Same zero-copy parsing, same performance — just .await on I/O.

§Runtime Features

Exactly one async runtime must be enabled (mutually exclusive):

  • tokio-rt (default) — tokio-based adapters for WebSocket and REST.
  • nexus — nexus-async-rt-based adapters (single-threaded, pre-allocated). (Renamed from nexus-rt in v0.4.2.)

§Modules

  • ws — Async WebSocket (wraps FrameReader/FrameWriter). Both backends provide recv()/send_*(). The tokio backend also implements Stream/Sink for ecosystem integration.
  • rest — Async HTTP REST client (wraps RequestWriter/ResponseReader)

§Custom transports

WsReader/WsWriter and HttpConnection<S> accept any WireStream — the canonical MaybeTls transport implements it directly. To plug a custom AsyncRead+AsyncWrite transport into the same API, wrap it at the call site:

  • tokio (feature = "tokio-rt"): AsyncReadAdapter
  • nexus-async-rt (feature = "nexus"): [NexusAsyncReadAdapter]
let tcp = tokio::net::TcpStream::connect(addr).await?;
let (mut reader, mut writer, mut conn) = WsStreamBuilder::new()
    .connect_with(AsyncReadAdapter::new(tcp), url)
    .await?;

Modules§

rest
Async HTTP REST client — adapts nexus-net for async runtimes.
rest_types
REST types used in rest::HttpConnection and rest::ClientSlot.
ws
Async WebSocket — adapts nexus-net for async runtimes.

Structs§

AsyncReadAdapter
Wraps a tokio::io::AsyncRead + AsyncWrite source as a WireStream.
CloseFrame
Parsed close frame: status code + UTF-8 reason.
FrameReader
WebSocket frame reader — parses wire bytes into Messages.
FrameReaderBuilder
Builder for FrameReader.
FrameWriter
WebSocket frame encoder.
OwnedCloseFrame
Owned close frame.
TlsConfig
Shared TLS configuration. Create once at startup, pass to each connection.
WriteBuf
Flat byte slab for outbound protocol frames.

Enums§

CloseCode
WebSocket close status codes (RFC 6455 §7.4.1).
HandshakeError
Handshake error.
Message
A complete WebSocket message.
OwnedMessage
An owned WebSocket message, detached from reader buffers.
Role
Determines masking behavior per RFC 6455.
TlsError
TLS operation error.
WsError
Unified error type for WebSocket stream operations.

Traits§

WireStream
A bidirectional byte-level stream that fills a parser’s buffer.