ws
33 items · generated by scribe fromstdlib/ws.fd· synced 2026-11-15
Contents
- ws_sha1 (function)
- WsConn (struct)
- WsFrame (struct)
- ws_ok (function)
- ws_failed (function)
- ws_accept_key (function)
- ws_set_tls (function)
- ws_connect (function)
- ws_handshake (function)
- ws_accept (function)
- ws_read_request (function)
- ws_accept_on (function)
- ws_frame_encode (function)
- ws_recv (function)
- ws_send_text (function)
- ws_send_binary (function)
- ws_send_ping (function)
- ws_send_pong (function)
- ws_close (function)
ws_sha1
SHA-1 of a byte Vec → 20-byte Vec.
pub fn ws_sha1(bytes: Vec) -> Vec {Parameters:
bytes:Vec
Returns: Vec
Defined at line 33
WsConn
A WebSocket connection. fd < 0 means handshake/connect failed.
pub struct WsConn {Fields:
| Name | Type |
|---|---|
fd | i64 |
is_client | bool |
open | bool |
tls | i64 |
Defined at line 137
WsFrame
A received frame/message.
pub struct WsFrame {Fields:
| Name | Type |
|---|---|
opcode | i64 |
text | str |
bytes | Vec |
fin | bool |
Defined at line 145
ws_ok
pub fn ws_ok(c: WsConn) -> bool {Parameters:
c:WsConn
Returns: bool
Defined at line 155
ws_failed
A connection that failed (fd -1), for modules that open their own (module wss).
pub fn ws_failed(is_client: bool) -> WsConn {Parameters:
is_client:bool
Returns: WsConn
Defined at line 161
ws_accept_key
The RFC 6455 accept key for a given Sec-WebSocket-Key.
pub fn ws_accept_key(key: str) -> str {Parameters:
key:str
Returns: str
Defined at line 170
ws_set_tls
For module wss: how to read, write and close a TLS session.
pub fn ws_set_tls(recv: fn(i64, i64, i64, i64) -> i64, send: fn(i64, i64, i64) -> i64, close: fn(i64) -> i64) {Parameters:
recv:fn(i64send:fn(i64close:fn(i64) -> i64
Defined at line 208
ws_connect
Client-side connect: TCP + Upgrade handshake. host may be a hostname or IP. Returns WsConn with fd<0 on failure.
pub fn ws_connect(host: str, port: i64, path: str) -> WsConn {Parameters:
host:strport:i64path:str
Returns: WsConn
Defined at line 260
ws_handshake
The client’s Upgrade handshake on a connected socket, or over the TLS session tls on it (module wss). Returns WsConn with fd<0 on failure, the socket then closed.
pub fn ws_handshake(fd: i64, tls: i64, host: str, path: str) -> WsConn {Parameters:
fd:i64tls:i64host:strpath:str
Returns: WsConn
Defined at line 275
ws_accept
Server-side accept: given an accepted socket fd and the client’s HTTP request text (read by the caller), validate the Upgrade and send the 101 response. Returns WsConn with fd<0 on failure.
pub fn ws_accept(fd: i64, request: str) -> WsConn {Parameters:
fd:i64request:str
Returns: WsConn
Defined at line 299
ws_read_request
The request of a client that wants to upgrade: its headers, read from the socket or the TLS session.
pub fn ws_read_request(fd: i64, tls: i64) -> str {Parameters:
fd:i64tls:i64
Returns: str
Defined at line 305
ws_accept_on
ws_accept over the TLS session tls on fd (0: none).
pub fn ws_accept_on(fd: i64, tls: i64, request: str) -> WsConn {Parameters:
fd:i64tls:i64request:str
Returns: WsConn
Defined at line 310
ws_frame_encode
Encode a frame. Clients must mask (RFC 6455 §5.3); servers must not.
pub fn ws_frame_encode(opcode: i64, payload: Vec, mask: bool) -> Vec {Parameters:
opcode:i64payload:Vecmask:bool
Returns: Vec
Defined at line 355
ws_recv
Receive one message; opcode -1 on connection failure/close. Continuation frames are accumulated so a fragmented message arrives as one WsFrame. A ping in the middle of one is answered and a pong skipped; a close there ends it (opcode 8). A control frame before any data frame is returned as it is.
pub fn ws_recv(c: WsConn) -> WsFrame {Parameters:
c:WsConn
Returns: WsFrame
Defined at line 438
ws_send_text
Send a text message.
pub fn ws_send_text(c: WsConn, text: str) -> i64 {Parameters:
c:WsConntext:str
Returns: i64
Defined at line 546
ws_send_binary
Send a binary message.
pub fn ws_send_binary(c: WsConn, data: Vec) -> i64 {Parameters:
c:WsConndata:Vec
Returns: i64
Defined at line 551
ws_send_ping
Send a ping.
pub fn ws_send_ping(c: WsConn, text: str) -> i64 {Parameters:
c:WsConntext:str
Returns: i64
Defined at line 556
ws_send_pong
Reply to a ping (callers handle it automatically in ws_recv_loop).
pub fn ws_send_pong(c: WsConn, payload: Vec) -> i64 {Parameters:
c:WsConnpayload:Vec
Returns: i64
Defined at line 561
ws_close
Close handshake + socket close.
pub fn ws_close(c: WsConn) -> void {Parameters:
c:WsConn
Returns: void
Defined at line 566
Generated by scribe, the Fides documentation generator