pub struct WebSocketClient { /* private fields */ }Expand description
WebSocket client for the XRP Ledger.
Maintains a persistent WebSocket connection with a background task that
handles message routing. Supports both request-response (via id tracking)
and subscription streams.
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub async fn connect(url: &str) -> Result<Self, ClientError>
pub async fn connect(url: &str) -> Result<Self, ClientError>
Connect to an XRPL WebSocket endpoint.
Spawns a background task that manages the connection and routes messages between the API and the WebSocket.
§Errors
Returns ClientError::WebSocket if the connection fails.
Sourcepub fn subscribe_stream(&self) -> Result<SubscriptionStream, ClientError>
pub fn subscribe_stream(&self) -> Result<SubscriptionStream, ClientError>
Subscribe to receive raw subscription messages.
Returns a SubscriptionStream that yields serde_json::Value
messages pushed by the server (ledger closes, transactions, etc.).
You must also send a SubscribeRequest
via Client::request to tell the server what to subscribe to.
§Errors
Returns ClientError::ConnectionClosed if the WebSocket is disconnected.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if the WebSocket connection is still alive.