| Crates.io | loro-protocol |
| lib.rs | loro-protocol |
| version | 0.1.0 |
| created_at | 2025-11-30 15:25:55.376794+00 |
| updated_at | 2025-11-30 15:25:55.376794+00 |
| description | Rust implementation of the Loro Syncing Protocol encoder/decoder |
| homepage | |
| repository | https://github.com/loro-dev/protocol |
| max_upload_size | |
| id | 1958364 |
| size | 48,917 |
Rust implementation of the Loro syncing protocol encoder/decoder. Mirrors the TypeScript package in packages/loro-protocol and follows the wire format described in protocol.md and the end-to-end encrypted flow in protocol-e2ee.md.
BytesWriter, BytesReader) for varint/varbytes/varstring%ELO container parsing; Rust-side encryption helpers are WIP and may evolveAdd the crate to your workspace (published crate name matches the package):
cargo add loro-protocol
Encode and decode messages:
use loro_protocol::{encode, decode, ProtocolMessage, CrdtType};
let msg = ProtocolMessage::JoinRequest {
crdt: CrdtType::Loro,
room_id: "room-123".to_string(),
auth: vec![],
version: vec![],
};
let bytes = encode(&msg)?;
let roundtrip = decode(&bytes)?;
assert_eq!(roundtrip, msg);
Streaming-friendly decode:
use loro_protocol::try_decode;
let buf = /* bytes from the wire */;
if let Some(msg) = try_decode(&buf) {
// valid message
} else {
// malformed or incomplete buffer
}
cargo test -p loro-protocol
protocol.md for the wire format and message semanticsprotocol-e2ee.md for %ELO encryption details