loro-websocket-client

Crates.ioloro-websocket-client
lib.rsloro-websocket-client
version0.1.0
created_at2025-11-30 15:26:42.741893+00
updated_at2025-11-30 15:26:42.741893+00
descriptionAsync WebSocket client for the Loro protocol
homepage
repositoryhttps://github.com/loro-dev/protocol
max_upload_size
id1958367
size108,412
Zixuan Chen (zxch3n)

documentation

README

loro-websocket-client (Rust)

Async WebSocket client for the Loro protocol. Exposes:

  • Low-level Client to send/receive raw loro_protocol::ProtocolMessage.
  • High-level LoroWebsocketClient that joins rooms and mirrors updates into a loro::LoroDoc, matching the TypeScript client behavior.

%ELO support is WIP: the Rust adaptor currently ships snapshot-only packaging for encrypted docs and APIs may change.

Quick start

use std::sync::Arc;
use loro::{LoroDoc};
use loro_websocket_client::LoroWebsocketClient;

# #[tokio::main(flavor = "current_thread")]
# async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = LoroWebsocketClient::connect("ws://127.0.0.1:9000/ws1?token=secret").await?;
let doc = Arc::new(tokio::sync::Mutex::new(LoroDoc::new()));
let _room = client.join_loro("room1", doc.clone()).await?;
// mutate doc then commit; the client auto-sends updates
{ let mut d = doc.lock().await; d.get_text("text").insert(0, "hello")?; d.commit(); }
# Ok(()) }

Features

  • Handles protocol keepalive ("ping"/"pong") and filters control frames.
  • Automatic fragmentation/reassembly thresholds aligned with the server.
  • %ELO adaptor helpers to encrypt/decrypt containers alongside Loro (experimental snapshot-only flow).

Tests

cargo test -p loro-websocket-client
Commit count: 0

cargo fmt