Skip to main content

hyperlane_plugin_rpc/
type.rs

1use super::*;
2
3/// Boxed `Send` future returned by an async JSON-RPC 2.0 method handler.
4pub type RpcFuture = Pin<Box<dyn Future<Output = Result<Value, RpcError>> + Send>>;
5
6/// Thread-safe async JSON-RPC 2.0 method handler callback.
7pub type RpcHandler = Arc<dyn Fn(Option<Value>) -> RpcFuture + Send + Sync>;
8
9/// Zero-allocation hash map storing registered JSON-RPC method handlers.
10pub(crate) type RpcMethodMap = HashMap<String, RpcHandler, BuildHasherDefault<FxHasher>>;
11
12/// Pre-validated JSON-RPC call ready for async execution or immediate short-circuit reply.
13pub(crate) type PreparedRpcCall =
14    Result<(RpcHandler, Option<Value>, Option<RpcId>), Option<Box<RpcResponse>>>;
15
16/// Pre-validated borrowed JSON-RPC call borrowing the registered handler without cloning `Arc`.
17pub(crate) type PreparedBorrowedCall<'a> =
18    Result<(&'a RpcHandler, Option<Value>, Option<RpcId>), Option<CompactRpcResponse>>;