| Crates.io | capnweb-server |
| lib.rs | capnweb-server |
| version | 0.1.0 |
| created_at | 2025-09-30 00:49:52.768967+00 |
| updated_at | 2025-09-30 00:49:52.768967+00 |
| description | Production-ready server for Cap'n Web RPC protocol with capability management |
| homepage | https://github.com/currentspace/capn-rs |
| repository | https://github.com/currentspace/capn-rs |
| max_upload_size | |
| id | 1860433 |
| size | 340,512 |
Production-ready server for Cap'n Web RPC protocol with capability management.
capnweb-server provides a high-performance, production-ready server implementation of the Cap'n Web RPC protocol. It supports multiple transport layers and includes built-in capability management, rate limiting, and observability.
Add to your Cargo.toml:
[dependencies]
capnweb-server = "0.1.0"
Create a simple server:
use capnweb_server::{Server, ServerConfig, RpcTarget};
use capnweb_core::{CapId, RpcError};
use async_trait::async_trait;
use serde_json::{json, Value};
use std::sync::Arc;
use anyhow::Result;
#[derive(Debug)]
struct MyService;
#[async_trait]
impl RpcTarget for MyService {
async fn call(&self, method: &str, args: Vec<Value>) -> Result<Value, RpcError> {
match method {
"echo" => Ok(json!({ "echoed": args })),
_ => Err(RpcError::not_found("Method not found")),
}
}
}
#[tokio::main]
async fn main() -> Result<()> {
let config = ServerConfig {
port: 8080,
host: "127.0.0.1".to_string(),
max_batch_size: 100,
};
let server = Server::new(config);
server.register_capability(CapId::new(0), Arc::new(MyService));
server.run().await?;
Ok(())
}
The crate includes a capnweb-server binary for quick testing:
cargo install capnweb-server
capnweb-server
The server can be configured via ServerConfig:
port: Server port (default: 8080)host: Bind address (default: "127.0.0.1")max_batch_size: Maximum batch request sizerate_limit: Requests per second limitsession_timeout: Session inactivity timeoutThis project is licensed under either of
at your option.