Crate jsonrpsee_server
source ·Expand description
jsonrpsee-server
jsonrpsee-server is a JSON RPC server that supports both HTTP and WebSocket transport.
Re-exports
pub use jsonrpsee_types as types;pub use tracing;
Modules
- Helpers.
- Logger for
jsonrpseeservers. - Various middleware implementations for RPC specific purposes.
Structs
- Builder to build a
BatchResponse. - This wraps
tokio::sync::Semaphoreand is used to limit the number of subscriptions per connection. - Bounded writer that allows writing at most
max_lenbytes. - Error that may occur during
crate::server::MethodSink::sendorcrate::server::SubscriptionSink::send. - Represents a subscription until it is unsubscribed.
- Represent the response to method call.
- Sink that is used to send back the result to the server for a specific method.
- A method sink with reserved spot in the bounded queue.
- Reference-counted, clone-on-write collection of synchronous and asynchronous methods.
- No-op implementation to be used for servers that don’t support subscriptions.
- The error returned while accepting a subscription.
- Represents a single subscription that is waiting to be accepted or rejected.
- Generates random integers as subscription ID.
- Generates random strings of length
lenas subscription ID. - 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. - JSON RPC server.
- Builder to configure and create a JSON-RPC server
- Server handle.
- Wrapper struct that maintains a subscription “mainly” for testing.
- Represent a unique subscription entry based on
SubscriptionIdandConnectionId. - Subscription message.
- Represents a single subscription that hasn’t been processed yet.
- Helper struct to manage subscriptions.
Enums
- Policy for validating the
HTTP host header. - 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. - Callback wrapper that can be either sync or async.
- Result of a method, either direct value or a future of one.
- Error that may occur during
crate::server::MethodSink::send_timeoutorcrate::server::SubscriptionSink::send_timeout. - Represents what action that will sent when a subscription callback returns.
- A complete subscription message or partial subscription message.
- Error that may occur during
crate::server::MethodSink::try_sendorcrate::server::SubscriptionSink::try_send.
Traits
- Trait to generate subscription IDs.
- 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 Definitions
- Similar to
SyncMethod, but represents an asynchronous handler. - 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.
- Max response size.
- Raw response from an RPC A tuple containing:
- Type-alias for subscribers.
- Method callback for subscriptions.
- Subscription permit.
- 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).