Trait subxt::rpc::RpcClientT
source · pub trait RpcClientT: Send + Sync + 'static {
// Required methods
fn request_raw<'a>(
&'a self,
method: &'a str,
params: Option<Box<RawValue>>
) -> RpcFuture<'a, Box<RawValue>>;
fn subscribe_raw<'a>(
&'a self,
sub: &'a str,
params: Option<Box<RawValue>>,
unsub: &'a str
) -> RpcFuture<'a, RpcSubscription>;
}
Expand description
Any RPC client which implements this can be used in our super::Rpc
type
to talk to a node.
This is a low level interface whose methods expect an already-serialized set of params,
and return an owned but still-serialized RawValue
, deferring deserialization to
the caller. This is the case because we want the methods to be object-safe (which prohibits
generics), and want to avoid any unnecessary allocations in serializing/deserializing
parameters.
Panics
Implementations are free to panic if the RawValue
’s passed to request_raw
or
subscribe_raw
are not JSON arrays. Internally, we ensure that this is always the case.
Required Methods§
sourcefn request_raw<'a>(
&'a self,
method: &'a str,
params: Option<Box<RawValue>>
) -> RpcFuture<'a, Box<RawValue>>
fn request_raw<'a>( &'a self, method: &'a str, params: Option<Box<RawValue>> ) -> RpcFuture<'a, Box<RawValue>>
Make a raw request for which we expect a single response back from. Implementations
should expect that the params will either be None
, or be an already-serialized
JSON array of parameters.
See super::RpcParams
and the super::rpc_params!
macro for an example of how to
construct the parameters.
Prefer to use the interface provided on super::RpcClient
where possible.
sourcefn subscribe_raw<'a>(
&'a self,
sub: &'a str,
params: Option<Box<RawValue>>,
unsub: &'a str
) -> RpcFuture<'a, RpcSubscription>
fn subscribe_raw<'a>( &'a self, sub: &'a str, params: Option<Box<RawValue>>, unsub: &'a str ) -> RpcFuture<'a, RpcSubscription>
Subscribe to some method. Implementations should expect that the params will
either be None
, or be an already-serialized JSON array of parameters.
See super::RpcParams
and the super::rpc_params!
macro for an example of how to
construct the parameters.
Prefer to use the interface provided on super::RpcClient
where possible.