| Crates.io | capnweb-client |
| lib.rs | capnweb-client |
| version | 0.1.0 |
| created_at | 2025-09-30 00:50:08.169248+00 |
| updated_at | 2025-09-30 00:50:08.169248+00 |
| description | High-performance Rust client for Cap'n Web RPC protocol with batching and pipelining |
| homepage | https://github.com/currentspace/capn-rs |
| repository | https://github.com/currentspace/capn-rs |
| max_upload_size | |
| id | 1860434 |
| size | 139,642 |
High-performance Rust client for Cap'n Web RPC protocol with batching and pipelining.
capnweb-client provides a feature-rich client implementation for the Cap'n Web RPC protocol. It supports automatic batching, promise pipelining, capability management, and multiple transport options.
Add to your Cargo.toml:
[dependencies]
capnweb-client = "0.1.0"
Basic client usage:
use capnweb_client::{Client, ClientConfig};
use serde_json::json;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// Create client with configuration
let config = ClientConfig {
url: "http://localhost:8080/rpc/batch".to_string(),
batch_size: 10,
batch_timeout_ms: 100,
..Default::default()
};
let client = Client::new(config)?;
// Make RPC calls
let result = client
.call("calculator", "add", vec![json!(5), json!(3)])
.await?;
println!("Result: {}", result);
// Batch multiple calls
let batch = client.batch();
let future1 = batch.call("service1", "method1", vec![]);
let future2 = batch.call("service2", "method2", vec![]);
batch.execute().await?;
let result1 = future1.await?;
let result2 = future2.await?;
Ok(())
}
// Chain operations on promises
let promise = client.call("service", "getUser", vec![json!(123)]);
let email_promise = promise.pipeline("getEmail", vec![]);
let email = email_promise.await?;
// Use WebSocket for real-time communication
let ws_client = Client::websocket("ws://localhost:8080/rpc/ws").await?;
// Subscribe to events
ws_client.subscribe("events", |event| {
println!("Received event: {:?}", event);
}).await?;
url: Server endpoint URLbatch_size: Maximum batch sizebatch_timeout_ms: Batch window timeoutconnection_timeout_ms: Connection timeoutretry_count: Number of retries on failureretry_delay_ms: Initial retry delayThis project is licensed under either of
at your option.