1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! # Cap'n Web Server Library
//!
//! Server implementation for the Cap'n Web RPC protocol.
//!
//! This crate provides a production-ready server with:
//! - Capability registration and lifecycle management
//! - Automatic batching and pipelining support
//! - Multiple transport protocols (HTTP, WebSocket, WebTransport)
//! - Rate limiting and connection management
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use capnweb_server::{Server, ServerConfig};
//! use capnweb_core::{CapId, RpcError, Value};
//! use capnweb_core::RpcTarget; // Use RpcTarget from core, not server
//! use async_trait::async_trait;
//! use std::sync::Arc;
//! use serde_json::json;
//!
//! #[derive(Debug)]
//! struct HelloService;
//!
//! #[async_trait]
//! impl RpcTarget for HelloService {
//! async fn call(&self, method: &str, args: Vec<Value>) -> Result<Value, RpcError> {
//! match method {
//! "greet" => {
//! // Note: Value is from capnweb_core, not serde_json
//! Ok(Value::String(format!("Hello, World!")))
//! }
//! _ => Err(RpcError::not_found("method not found"))
//! }
//! }
//!
//! async fn get_property(&self, _property: &str) -> Result<Value, RpcError> {
//! Err(RpcError::not_found("property access not implemented"))
//! }
//! }
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Create server configuration
//! let config = ServerConfig {
//! port: 8080,
//! host: "127.0.0.1".to_string(),
//! max_batch_size: 100,
//! };
//!
//! // Create and configure server
//! let server = Server::new(config);
//! server.register_capability(
//! CapId::new(1),
//! Arc::new(HelloService)
//! );
//!
//! // Run the server
//! server.run().await;
//! # Ok(())
//! # }
//! ```
//!
//! ## Capability Registration
//!
//! Register multiple capabilities with different IDs:
//!
//! ```rust,ignore
//! # use capnweb_server::Server;
//! # use capnweb_core::CapId;
//! # use std::sync::Arc;
//! # struct AuthService;
//! # struct DataService;
//! # struct AdminService;
//! # let server = Server::new(Default::default()).unwrap();
//! server.register_capability(CapId::new(1), Arc::new(AuthService));
//! server.register_capability(CapId::new(2), Arc::new(DataService));
//! server.register_capability(CapId::new(3), Arc::new(AdminService));
//! ```
//!
//! ## Transport Configuration
//!
//! The server supports multiple transport protocols:
//!
//! - **HTTP Batch**: Default transport at `/rpc/batch`
//! - **WebSocket**: Real-time bidirectional communication (with feature flag)
//! - **WebTransport**: HTTP/3-based transport (with feature flag)
// Official Cap'n Web wire protocol server
// Legacy servers (TO BE REMOVED - only wire protocol should be used)
// Primary exports: Official Cap'n Web wire protocol
pub use ;
// Legacy exports
pub use ;
pub use CapTable;
pub use ;
pub use ;
pub use RateLimits;
pub use ;
pub use ;
pub use PlanRunner;
pub use ;