Show HN: Cap'n-rs โ€“ Rust implementation of Cloudflare's Cap'n Web protocol

https://news.ycombinator.com/rss Hits: 5
Summary

Cap'n Web Rust Implementation A complete, production-ready implementation of the Cap'n Web protocol in Rust, providing capability-based RPC with promise pipelining and multi-transport support. Features โœ… Full Protocol Compliance - Implements the complete Cap'n Web wire protocol ๐Ÿ”’ Capability-Based Security - Unforgeable capability references with automatic lifecycle management ๐Ÿš€ Promise Pipelining - Reduced round-trips through dependency resolution ๐ŸŒ Multi-Transport - HTTP batch, WebSocket, and WebTransport support ๐Ÿ›ก๏ธ Production-Ready - Zero-panic code, comprehensive error handling with context โœ… IL Expression Evaluation - Complete intermediate language support with array notation ๐ŸŒ JavaScript Interop - Validated against official TypeScript implementation Quick Start Add to Cargo.toml [ dependencies ] capnweb-server = " 0.1.0 " capnweb-client = " 0.1.0 " Server Example use capnweb_server :: { Server , ServerConfig , RpcTarget } ; use capnweb_core :: { CapId , RpcError } ; use serde_json :: { json , Value } ; use std :: sync :: Arc ; # [ derive ( Debug ) ] struct Calculator ; impl RpcTarget for Calculator { async fn call ( & self , member : & str , args : Vec < Value > ) -> Result < Value , RpcError > { match member { "add" => { let a = args [ 0 ] . as_f64 ( ) . unwrap ( ) ; let b = args [ 1 ] . as_f64 ( ) . unwrap ( ) ; Ok ( json ! ( a + b ) ) } _ => Err ( RpcError :: not_found ( "method not found" ) ) , } } } # [ tokio :: main ] async fn main ( ) -> Result < ( ) , Box < dyn std :: error :: Error > > { let config = ServerConfig :: default ( ) ; let server = Server :: new ( config ) ; // Register capabilities server . register_capability ( CapId :: new ( 1 ) , Arc :: new ( Calculator ) ) ; // Run server with HTTP batch endpoint server . run ( ) . await ? ; Ok ( ( ) ) } Client Example use capnweb_client :: { Client , ClientConfig } ; use capnweb_core :: CapId ; use serde_json :: json ; # [ tokio :: main ] async fn main ( ) -> Result < ( ) , Box < dyn std :: error :: Er...

First seen: 2025-09-30 06:36

Last seen: 2025-09-30 10:36