Expand description
jsonrpsee wrapper crate.
Optional features
The jsonrpsee
crate composes JSON-RPC functionality behind optional feature
flags to provide for client and server communication over specific protocols.
There are no default features, all functionality must be opted in to accordingly.
The following features are available.
http-client
- JSON-RPC client functionality over HTTP protocol.wasm-client
- JSON-RPC client functionality over web-sys.ws-client
- JSON-RPC client functionality over WebSocket protocol.macros
- JSON-RPC API generation convenience by derive macros.client-core
- Enables minimal client features to generate the RPC API without transports.client
- Enables all client features including transports.server-core
- Enables minimal server features to generate the RPC API without transports.server
- Enables all server features including transports.full
- Enables all features.async-client
- Enables the async client without any transport.client-ws-transport
- Enablesws
transport with TLS.client-ws-transport-no-tls
- Enablesws
transport without TLS.client-web-transport
- Enableswebsys
transport.
Re-exports
pub use jsonrpsee_http_client as http_client;
pub use jsonrpsee_ws_client as ws_client;
pub use jsonrpsee_wasm_client as wasm_client;
pub use jsonrpsee_client_transport as client_transport;
pub use jsonrpsee_server as server;
pub use tokio;
pub use jsonrpsee_proc_macros as proc_macros;
pub use tracing;
pub use jsonrpsee_types as types;
pub use jsonrpsee_core as core;
Modules
- async_client
async-client
Abstract async client. - helpers
server
Helpers.
Macros
- Convert the given values to a
crate::params::ArrayParams
as expected by a jsonrpsee Client (http or websocket).
Structs
- BatchResponseBuilder
server
Builder to build aBatchResponse
. - BoundedSubscriptions
server
This wrapstokio::sync::Semaphore
and is used to limit the number of subscriptions per connection. - BoundedWriter
server
Bounded writer that allows writing at mostmax_len
bytes. - DisconnectError
server
Error that may occur duringcrate::server::MethodSink::send
orcrate::server::SubscriptionSink::send
. - IsUnsubscribed
server
Represents a subscription until it is unsubscribed. - MethodResponse
server
Represent the response to a method call. - MethodSink
server
Sink that is used to send back the result to the server for a specific method. - Methods
server
Reference-counted, clone-on-write collection of synchronous and asynchronous methods. - The error returned while accepting a subscription.
- PendingSubscriptionSink
server
Represents a single subscription that is waiting to be accepted or rejected. - RpcModule
server
Sets of JSON-RPC methods can be organized into “module“s that are in turn registered on the server or, alternatively, merged with other modules to construct a cohesive API.RpcModule
wraps an additional context argument that can be used to access data during call execution. - Subscription
server
Wrapper struct that maintains a subscription “mainly” for testing. - SubscriptionKey
server
Represent a unique subscription entry based onSubscriptionId
andConnectionId
. - SubscriptionMessage
server
Subscription message. - SubscriptionSink
server
Represents a single subscription that hasn’t been processed yet. - SubscriptionState
server
Helper struct to manage subscriptions.
Enums
- CallOrSubscription
server
This represent a response to a RPC call andSubscribe
calls are handled differently because we want to prevent subscriptions to start before the actual subscription call has been answered. - MethodCallback
server
Callback wrapper that can be either sync or async. - MethodResult
server
Result of a method, either direct value or a future of one. - SendTimeoutError
server
Error that may occur duringcrate::server::MethodSink::send_timeout
orcrate::server::SubscriptionSink::send_timeout
. - Represents what action that will sent when a subscription callback returns.
- SubscriptionMessageInner
server
A complete subscription message or partial subscription message. - TrySendError
server
Error that may occur duringcrate::server::MethodSink::try_send
orcrate::server::SubscriptionSink::try_send
.
Traits
- IntoResponse
server
Something that can be converted into a JSON-RPC method call response. - Convert something into a subscription close notification before a subscription is terminated.
Type Aliases
- AsyncMethod
server
Similar toSyncMethod
, but represents an asynchronous handler. - ConnectionId
server
Connection ID, used for stateful protocol such as WebSockets. For stateless protocols such as http it’s unused, so feel free to set it some hardcoded value. - MaxResponseSize
server
Max response size. - RawRpcResponse
server
Raw response from an RPC A tuple containing: - Subscribers
server
Type-alias for subscribers. - SubscriptionMethod
server
Method callback for subscriptions. - SubscriptionPermit
server
Subscription permit. - SyncMethod
server
AMethodCallback
is an RPC endpoint, callable with a standard JSON-RPC request, implemented as a function pointer to aFn
function taking four arguments: theid
,params
, a channel the function uses to communicate the result (or error) back tojsonrpsee
, and the connection ID (useful for the websocket transport).