Stdlibnet
net::ws
WebSocket, RFC 6455, over any async transport — so the same code handles ws:// over TCP and wss:// over TLS. It is non-blocking throughout, over one buffered connection.
public module net::ws::frame;
public module net::ws::handshake;
public module net::ws::conn;
| File | What it holds | Import |
|---|---|---|
conn | WebSocket<S>, Message, connect, accept | import std::net::ws::conn; |
frame | Frame, OpCode, and the frame reader/writer on BufStream | import std::net::ws::frame; |
handshake | generate_key, compute_accept | import std::net::ws::handshake; |
import std::net::ws;
mut ws: WebSocket<TcpStream> = await ws::connect(conn, host, path)?;
await ws.send_text(Str::new("hello"));
match (await ws.recv()) {
Result::Ok(msg) => { /* Message::Text / Binary / Close */ }
Result::Err(e) => { }
}
SHA-1 and base64 for the accept key are pure Cryo from encoding, so plain ws:// pulls in no crypto dependency at all.