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- Enableswstransport with TLS.client-ws-transport-no-tls- Enableswstransport without TLS.client-web-transport- Enableswebsystransport.
Re-exports§
pub use jsonrpsee_http_client as http_client;pub use jsonrpsee_ws_client as ws_client;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§
- helpers
- Helpers.
Macros§
- rpc_
params - Convert the given values to a
crate::params::ArrayParamsas expected by a jsonrpsee Client (http or websocket).
Structs§
- Batch
Response - Serialized batch response.
- Batch
Response Builder - Builder to build a
BatchResponse. - Bounded
Subscriptions - This wraps
tokio::sync::Semaphoreand is used to limit the number of subscriptions per connection. - Bounded
Writer - Bounded writer that allows writing at most
max_lenbytes. - Connection
Id - Connection ID.
- Disconnect
Error - Error that may occur during
crate::server::MethodSink::sendorcrate::server::SubscriptionSink::send. - Extensions
- A type map of protocol extensions.
- IsUnsubscribed
- Represents a subscription until it is unsubscribed.
- Method
Response - Represents a response to a method call.
- Method
Response Future - Future that resolves when the method response has been processed.
- Method
Response Notify Tx - Sends a message once the method response has been processed.
- Method
Sink - Sink that is used to send back the result to the server for a specific method.
- Methods
- Reference-counted, clone-on-write collection of synchronous and asynchronous methods.
- Pending
Subscription Accept Error - The error returned while accepting a subscription.
- Pending
Subscription Sink - Represents a single subscription that is waiting to be accepted or rejected.
- Response
Payload - Similar to
jsonrpsee_types::ResponsePayloadbut possible to with an async-like API to detect when a method response has been sent. - RpcModule
- 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.
RpcModulewraps an additional context argument that can be used to access data during call execution. - Subscription
- Wrapper struct that maintains a subscription “mainly” for testing.
- Subscription
Key - Represent a unique subscription entry based on
SubscriptionIdandConnectionId. - Subscription
Message - Subscription message.
- Subscription
Sink - Represents a single subscription that hasn’t been processed yet.
- Subscription
State - Helper struct to manage subscriptions.
Enums§
- Call
OrSubscription - This represent a response to a RPC call
and
Subscribecalls are handled differently because we want to prevent subscriptions to start before the actual subscription call has been answered. - Method
Callback - Callback wrapper that can be either sync or async.
- Method
Kind - The kind of the JSON-RPC method call, it can be a subscription, method call or unknown.
- Method
Response Error - Method response error.
- Method
Result - Result of a method, either direct value or a future of one.
- Methods
Error - The error that can occur when
Methods::callorMethods::subscribeis invoked. - Notify
Msg - A message that that tells whether notification was succesful or not.
- Send
Timeout Error - Error that may occur during
crate::server::MethodSink::send_timeoutorcrate::server::SubscriptionSink::send_timeout. - Subscription
Close Response - Represents what action that will sent when a subscription callback returns.
- Subscription
Message Inner - A complete subscription message or partial subscription message.
- TrySend
Error - Error that may occur during
crate::server::MethodSink::try_sendorcrate::server::SubscriptionSink::try_send.
Traits§
- Into
Response - Something that can be converted into a JSON-RPC method call response.
- Into
Subscription Close Response - Convert something into a subscription close notification before a subscription is terminated.
Functions§
- batch_
response_ error - Create a JSON-RPC error response.
- prepare_
error - Figure out if this is a sufficiently complete request that we can extract an
Idout of, or just plain unparseable garbage.
Type Aliases§
- Async
Method - Similar to
SyncMethod, but represents an asynchronous handler. - MaxResponse
Size - Max response size.
- RawRpc
Response - Raw response from an RPC A tuple containing:
- Subscribers
- Type-alias for subscribers.
- Subscription
Method - Method callback for subscriptions.
- Subscription
Permit - Subscription permit.
- Sync
Method - A
MethodCallbackis an RPC endpoint, callable with a standard JSON-RPC request, implemented as a function pointer to aFnfunction 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).