hyperlane-plugin-rpc 22.14.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
use super::*;

/// JSON-RPC 2.0 request/response correlation identifier.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(untagged)]
pub enum RpcId {
    /// Integer identifier.
    Number(i64),
    /// String identifier.
    Text(String),
    /// Explicit null identifier.
    #[default]
    Null,
}

/// Zero-copy deserialized batch array element falling back to ignored invalid items.
#[derive(Deserialize)]
#[serde(untagged)]
pub(crate) enum BorrowedBatchItem<'a> {
    /// Syntactically valid JSON-RPC candidate object.
    #[serde(borrow)]
    Request(BorrowedRpcRequest<'a>),
    /// Non-object or type-mismatched JSON element producing `Invalid Request`.
    Invalid(IgnoredAny),
}

/// Internal per-item batch execution slot avoiding `tokio::spawn` overhead.
pub(crate) enum BatchDispatchSlot {
    /// Immediately resolved static response (for example validation or method-not-found error).
    Ready(CompactRpcResponse),
    /// Async handler future executing concurrently inside `poll_fn`.
    Pending {
        /// Running boxed handler future.
        future: RpcFuture,
        /// Optional correlation id (`None` for notifications).
        id: Option<RpcId>,
    },
}