pub struct RpcCall<Conn, Params, Resp, Output = Resp, Map = fn(_: Resp) -> Output>{ /* private fields */ }
Expand description
A prepared, but unsent, RPC call.
This is a future that will send the request when polled. It contains a
Request
, a Transport
, and knowledge of its expected response
type. Upon awaiting, it will send the request and wait for the response. It
will then deserialize the response into the expected type.
Errors are captured in the RpcResult
type. Rpc Calls will result in
either a successful response of the Resp
type, an error response, or a
transport error.
§Note
Serializing the request is done lazily. The request is not serialized until
the future is polled. This differs from the behavior of
crate::BatchRequest
, which serializes greedily. This is because the
batch request must immediately erase the Param
type to allow batching of
requests with different Param
types, while the RpcCall
may do so lazily.
Implementations§
source§impl<Conn, Params, Resp, Output, Map> RpcCall<Conn, Params, Resp, Output, Map>
impl<Conn, Params, Resp, Output, Map> RpcCall<Conn, Params, Resp, Output, Map>
sourcepub fn map_resp<NewOutput, NewMap>(
self,
map: NewMap,
) -> RpcCall<Conn, Params, Resp, NewOutput, NewMap> ⓘwhere
NewMap: FnOnce(Resp) -> NewOutput,
pub fn map_resp<NewOutput, NewMap>(
self,
map: NewMap,
) -> RpcCall<Conn, Params, Resp, NewOutput, NewMap> ⓘwhere
NewMap: FnOnce(Resp) -> NewOutput,
Map the response to a different type. This is usable for converting
the response to a more usable type, e.g. changing U64
to u64
.
§Note
Carefully review the rust documentation on fn pointers before passing
them to this function. Unless the pointer is specifically coerced to a
fn(_) -> _
, the NewMap
will be inferred as that function’s unique
type. This can lead to confusing error messages.
sourcepub fn is_subscription(&self) -> bool
pub fn is_subscription(&self) -> bool
Returns true
if the request is a subscription.
§Panics
Panics if called after the request has been sent.
sourcepub fn set_is_subscription(&mut self)
pub fn set_is_subscription(&mut self)
Set the request to be a non-standard subscription (i.e. not “eth_subscribe”).
§Panics
Panics if called after the request has been sent.
sourcepub fn set_subscription_status(&mut self, status: bool)
pub fn set_subscription_status(&mut self, status: bool)
Set the subscription status of the request.
sourcepub fn params(&mut self) -> &mut Params
pub fn params(&mut self) -> &mut Params
Get a mutable reference to the params of the request.
This is useful for modifying the params after the request has been prepared.
§Panics
Panics if called after the request has been sent.
sourcepub fn request_mut(&mut self) -> &mut Request<Params>
pub fn request_mut(&mut self) -> &mut Request<Params>
Returns a mutable reference to the request.
§Panics
Panics if called after the request has been sent.
Trait Implementations§
source§impl<Conn, Params, Resp: Clone, Output: Clone, Map> Clone for RpcCall<Conn, Params, Resp, Output, Map>
impl<Conn, Params, Resp: Clone, Output: Clone, Map> Clone for RpcCall<Conn, Params, Resp, Output, Map>
source§impl<Conn, Params, Resp, Output, Map> Future for RpcCall<Conn, Params, Resp, Output, Map>
impl<Conn, Params, Resp, Output, Map> Future for RpcCall<Conn, Params, Resp, Output, Map>
impl<'pin, Conn, Params, Resp, Output, Map> Unpin for RpcCall<Conn, Params, Resp, Output, Map>
Auto Trait Implementations§
impl<Conn, Params, Resp, Output, Map> Freeze for RpcCall<Conn, Params, Resp, Output, Map>
impl<Conn, Params, Resp, Output = Resp, Map = fn(_: Resp) -> Output> !RefUnwindSafe for RpcCall<Conn, Params, Resp, Output, Map>
impl<Conn, Params, Resp, Output, Map> Send for RpcCall<Conn, Params, Resp, Output, Map>where
Map: Send,
impl<Conn, Params, Resp, Output = Resp, Map = fn(_: Resp) -> Output> !Sync for RpcCall<Conn, Params, Resp, Output, Map>
impl<Conn, Params, Resp, Output = Resp, Map = fn(_: Resp) -> Output> !UnwindSafe for RpcCall<Conn, Params, Resp, Output, Map>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moresource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read moresource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
std
only.std
only.source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
channel
and std
only.()
on completion and sends
its output to another future on a separate task. Read moresource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
alloc
only.source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
alloc
only.source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
source§type IntoFuture = F
type IntoFuture = F
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
source§impl<Fut> TryFutureExt for Fut
impl<Fut> TryFutureExt for Fut
source§fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>
fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>
sink
only.