Skip to main content

turul_rpc/
lib.rs

1//! # turul-rpc
2//!
3//! Typed JSON-RPC 2.0 framework. Facade crate re-exporting the
4//! [`turul-rpc-core`], [`turul-rpc-jsonrpc`], and [`turul-rpc-server`]
5//! crates under stable paths that mirror the original
6//! `turul-mcp-json-rpc-server 0.3.x` layout.
7//!
8//! Most consumers should depend on this crate. Use the split crates
9//! directly only when you need to avoid pulling in the async runtime
10//! (depend on `turul-rpc-core` only) or want to write a transport on top
11//! of the codec without the dispatcher (depend on `turul-rpc-jsonrpc`).
12//!
13//! [`turul-rpc-core`]: https://crates.io/crates/turul-rpc-core
14//! [`turul-rpc-jsonrpc`]: https://crates.io/crates/turul-rpc-jsonrpc
15//! [`turul-rpc-server`]: https://crates.io/crates/turul-rpc-server
16
17// Module re-exports — preserve the original `turul_mcp_json_rpc_server::<module>`
18// paths so the compatibility shim can re-export this crate without API drift.
19pub use turul_rpc_core::{error, error_codes, notification, request, response, types};
20pub use turul_rpc_jsonrpc::dispatch;
21
22/// Async dispatcher and handler trait. Mirrors the original `r#async`
23/// module from `turul-mcp-json-rpc-server`.
24#[cfg(feature = "async")]
25pub mod r#async {
26    pub use turul_rpc_server::{
27        FunctionHandler, JsonRpcDispatcher, JsonRpcHandler, SessionContext, ToJsonRpcError,
28    };
29
30    #[cfg(feature = "streams")]
31    pub use turul_rpc_server::streaming;
32}
33
34pub mod prelude;
35
36// Root re-exports — match the original crate's `pub use` lines.
37
38/// JSON-RPC 2.0 error types and standard error codes.
39pub use error::{JsonRpcError, JsonRpcErrorCode};
40/// JSON-RPC notification message structure for fire-and-forget communications.
41pub use notification::JsonRpcNotification;
42/// JSON-RPC request structure with method and parameters.
43pub use request::{JsonRpcRequest, RequestParams};
44/// JSON-RPC response types: the §5 Response object union (`JsonRpcResponse`)
45/// and the success-only struct (`JsonRpcSuccessResponse`).
46pub use response::{JsonRpcResponse, JsonRpcSuccessResponse, ResponseResult};
47/// Core JSON-RPC types for version and request identification.
48pub use types::{JsonRpcVersion, RequestId};
49
50/// Incoming message union (request | notification) produced by the parser.
51pub use turul_rpc_jsonrpc::JsonRpcMessage;
52
53/// Bidirectional wire-message union (request | notification | response) — the
54/// schema's `JSONRPCMessage`. Superset of [`JsonRpcMessage`]; for clients and
55/// peers that read responses. Parse with [`parse_json_rpc_wire_message`].
56pub use turul_rpc_jsonrpc::frame::{JsonRpcWireMessage, parse_json_rpc_wire_message};
57
58#[cfg(feature = "async")]
59pub use turul_rpc_server::{JsonRpcDispatcher, JsonRpcHandler, SessionContext};
60
61#[cfg(feature = "streams")]
62pub use turul_rpc_server::streaming::{
63    JsonRpcFrame, StreamingJsonRpcDispatcher, StreamingJsonRpcHandler,
64};
65
66/// JSON-RPC 2.0 version constant.
67pub const JSONRPC_VERSION: &str = "2.0";