client
ModuleA WebSocket client: connect, send, receive or listen, with event hooks.
Contents
use utopia_websocket::Client;Rust
pub struct ClientA WebSocket client.
Rust
use utopia_websocket::client::{Client, Options};
let client = Client::new("wss://realtime.example.com/v1/realtime?project=main", Options::default())?;
assert_eq!(client.host(), "realtime.example.com");
assert_eq!(client.port(), 443);
assert_eq!(client.path(), "/v1/realtime?project=main");
assert!(!client.is_connected());
let err = Client::new("not a url", Options::default()).unwrap_err();
assert_eq!(err.to_string(), "WebSocket URL must contain a host");Also implements
Debug.use utopia_websocket::client::Frame;Rust
pub struct FrameA frame received from the server.
use utopia_websocket::client::Options;Rust
pub struct OptionsClient options.
Also implements
Default.use utopia_websocket::client::TransportError;Rust
pub struct TransportErrorA transport failure: an error code and its message.
use utopia_websocket::client::Opcode;Rust
pub enum OpcodeThe opcode of a WebSocket frame.
use utopia_websocket::client::Received;Rust
pub enum ReceivedWhat one receive returned.
use utopia_websocket::client::Transport;Rust
pub trait Transport: SendAn established WebSocket connection the client reads and writes:
tokio-tungstenite on the network (the client's own, made by
Client::connect), or one given to Client::attach, such as a
scripted connection in tests.
Implemented byNetwork
Rust
pub const NO_CONNECTION: i64 = 5001The error code of a transport whose connection is gone: Client::listen
and Client::receive treat it as the server closing the connection.
Rust
pub const TIMED_OUT: i64 = 110The error code of a receive that timed out: Client::listen keeps
waiting.