25 releases (6 breaking)

new 0.6.2 Nov 7, 2024
0.5.4 Oct 23, 2024
0.2.0 Jul 16, 2024
0.0.0-reserved Nov 15, 2023

#274 in Magic Beans

Download history 12174/week @ 2024-07-18 12992/week @ 2024-07-25 15649/week @ 2024-08-01 18568/week @ 2024-08-08 16875/week @ 2024-08-15 17598/week @ 2024-08-22 20349/week @ 2024-08-29 23620/week @ 2024-09-05 25371/week @ 2024-09-12 25541/week @ 2024-09-19 26590/week @ 2024-09-26 35859/week @ 2024-10-03 39127/week @ 2024-10-10 41115/week @ 2024-10-17 41032/week @ 2024-10-24 36991/week @ 2024-10-31

165,927 downloads per month
Used in 109 crates (12 directly)

MIT/Apache

91KB
1.5K SLoC

alloy-json-rpc

Core types for JSON-RPC 2.0 clients.

This crate includes data types and traits for JSON-RPC 2.0 requests and responses, targeted at RPC client usage.

Core Model

A JSON-RPC 2.0 request is a JSON object containing an ID, a method name, and an arbitrary parameters object. The parameters object may be omitted if empty.

Any object that may be Serialized and Cloned may be used as RPC Parameters.

Requests are sent via transports (see alloy-transports). This results in 1 of 3 outcomes, captured in the RpcResult<E> enum:

  • Ok(Response) - The request was successful, and the server returned a response.
  • ErrResp(ErrorPayload) - The request was received by the server. Server-side handling was unsuccessful, and the server returned an error response. This indicates a server-side error.
  • Err(E) - Some client-side error prevented the request from being received by the server, or prevented the response from being processed. This indicates a client-side or transport-related error.

Limitations

  • This library does not support borrowing response data from the deserializer. This is intended to simplify client implementations, but makes the library poorly suited for use in a high-performance server.

Dependencies

~18MB
~387K SLoC