hyperlane-plugin-rpc 23.3.1

A JSON-RPC 2.0 server plugin for the Hyperlane framework with async method routing, batch dispatch, notification handling, and configurable payload and batch DoS bounds.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::*;

/// Boxed `Send` future returned by an async JSON-RPC 2.0 method handler.
pub type RpcFuture = Pin<Box<dyn Future<Output = Result<Value, RpcError>> + Send>>;

/// Thread-safe async JSON-RPC 2.0 method handler callback.
pub type RpcHandler = Arc<dyn Fn(Option<Value>) -> RpcFuture + Send + Sync>;

/// Zero-allocation hash map storing registered JSON-RPC method handlers.
pub(crate) type RpcMethodMap = HashMap<String, RpcHandler, BuildHasherDefault<FxHasher>>;

/// Pre-validated JSON-RPC call ready for async execution or immediate short-circuit reply.
pub(crate) type PreparedRpcCall =
    Result<(RpcHandler, Option<Value>, Option<RpcId>), Option<Box<RpcResponse>>>;

/// Pre-validated borrowed JSON-RPC call borrowing the registered handler without cloning `Arc`.
pub(crate) type PreparedBorrowedCall<'a> =
    Result<(&'a RpcHandler, Option<Value>, Option<RpcId>), Option<CompactRpcResponse>>;