Skip to main content

turul_rpc_core/
lib.rs

1//! # turul-rpc-core
2//!
3//! Pure JSON-RPC 2.0 wire types. No async, no codec helpers, no parser.
4//! Use [`turul-rpc-jsonrpc`] for parsing/batch and [`turul-rpc-server`] for
5//! the dispatcher and handler trait. Most consumers should depend on the
6//! [`turul-rpc`] facade instead of these crates directly.
7//!
8//! [`turul-rpc-jsonrpc`]: https://crates.io/crates/turul-rpc-jsonrpc
9//! [`turul-rpc-server`]: https://crates.io/crates/turul-rpc-server
10//! [`turul-rpc`]: https://crates.io/crates/turul-rpc
11
12pub mod error;
13pub mod notification;
14pub mod request;
15pub mod response;
16pub mod types;
17
18// Root re-exports matching the original `turul-mcp-json-rpc-server` shape.
19pub use error::{JsonRpcError, JsonRpcErrorCode};
20pub use notification::JsonRpcNotification;
21pub use request::{JsonRpcRequest, RequestParams};
22pub use response::{JsonRpcResponse, JsonRpcSuccessResponse, ResponseResult};
23pub use types::{JsonRpcVersion, RequestId};
24
25/// JSON-RPC 2.0 version constant.
26pub const JSONRPC_VERSION: &str = "2.0";
27
28/// Standard JSON-RPC 2.0 error codes.
29pub mod error_codes {
30    pub const PARSE_ERROR: i64 = -32700;
31    pub const INVALID_REQUEST: i64 = -32600;
32    pub const METHOD_NOT_FOUND: i64 = -32601;
33    pub const INVALID_PARAMS: i64 = -32602;
34    pub const INTERNAL_ERROR: i64 = -32603;
35
36    /// Inclusive lower bound of the JSON-RPC 2.0 server-defined error range.
37    pub const SERVER_ERROR_START: i64 = -32099;
38    /// Inclusive upper bound of the JSON-RPC 2.0 server-defined error range.
39    pub const SERVER_ERROR_END: i64 = -32000;
40}