[−][src]Trait essrpc::AsyncClientTransport
Trait for RPC transport (client) to be used with asynchronous clients
Associated Types
type TXState
Type of transport-internal state used when bulding a call for transmission on the client. May be unit if the transport does not need to track state or does so through member variables.
type FinalState
Type of state object returned from tx_finalize and consumed by rx_response. May be unit.
Required methods
fn tx_begin_call(&mut self, method: MethodId) -> Result<Self::TXState, RPCError>
Begin calling the given method. The transport may begin transmitting over the wire,
or it may may wait until the call to tx_finalize
.
fn tx_add_param(
&mut self,
name: &'static str,
value: impl Serialize,
state: &mut Self::TXState
) -> Result<(), RPCError>
&mut self,
name: &'static str,
value: impl Serialize,
state: &mut Self::TXState
) -> Result<(), RPCError>
Add a parameter to a method call started with
tx_begin_call
. This method is guaranteed to be called only
after tx_begin_call
and to be called appropriately for each
parameter of the method passed to tx_begin_call
. state
is
the object returned by tx_begin_call
. Parameters are always
added and read in order, so transmitting the name is not a requirement.
fn tx_finalize(
&mut self,
state: Self::TXState
) -> Result<Self::FinalState, RPCError>
&mut self,
state: Self::TXState
) -> Result<Self::FinalState, RPCError>
Finalize transmission of a method call. Called only after
tx_begin_call
and appropriate calls to tx_add_param
. If
the transport has not yet transmitted the method identifier
and parameters over the wire, it should do so at this time.
fn rx_response<T>(
&mut self,
state: Self::FinalState
) -> Box<dyn Future<Item = T, Error = RPCError>> where
T: Deserialize<'de>,
T: 'static,
&mut self,
state: Self::FinalState
) -> Box<dyn Future<Item = T, Error = RPCError>> where
T: Deserialize<'de>,
T: 'static,
Read the return value of a method call. Always called after
tx_finalize
. state
is the object returned by
tx_finalize
.
Implementors
impl<F> AsyncClientTransport for BincodeAsyncClientTransport<F> where
F: Fn(Vec<u8>) -> Box<dyn Future<Item = Vec<u8>, Error = RPCError>>,
[src]
F: Fn(Vec<u8>) -> Box<dyn Future<Item = Vec<u8>, Error = RPCError>>,
type TXState = Vec<u8>
type FinalState = Box<dyn Future<Item = Vec<u8>, Error = RPCError>>
fn tx_begin_call(&mut self, method: MethodId) -> Result<Vec<u8>, RPCError>
[src]
fn tx_add_param(
&mut self,
_name: &'static str,
value: impl Serialize,
state: &mut Vec<u8>
) -> Result<(), RPCError>
[src]
&mut self,
_name: &'static str,
value: impl Serialize,
state: &mut Vec<u8>
) -> Result<(), RPCError>
fn tx_finalize(
&mut self,
state: Vec<u8>
) -> Result<Box<dyn Future<Item = Vec<u8>, Error = RPCError>>, RPCError>
[src]
&mut self,
state: Vec<u8>
) -> Result<Box<dyn Future<Item = Vec<u8>, Error = RPCError>>, RPCError>
fn rx_response<T>(
&mut self,
state: Box<dyn Future<Item = Vec<u8>, Error = RPCError>>
) -> Box<dyn Future<Item = T, Error = RPCError>> where
T: Deserialize<'de>,
T: 'static,
[src]
&mut self,
state: Box<dyn Future<Item = Vec<u8>, Error = RPCError>>
) -> Box<dyn Future<Item = T, Error = RPCError>> where
T: Deserialize<'de>,
T: 'static,
impl<F> AsyncClientTransport for JSONAsyncClientTransport<F> where
F: Fn(Vec<u8>) -> Box<dyn Future<Item = Vec<u8>, Error = RPCError>>,
[src]
F: Fn(Vec<u8>) -> Box<dyn Future<Item = Vec<u8>, Error = RPCError>>,
type TXState = JTXState
type FinalState = Box<dyn Future<Item = Vec<u8>, Error = RPCError>>
fn tx_begin_call(&mut self, method: MethodId) -> Result<JTXState, RPCError>
[src]
fn tx_add_param(
&mut self,
name: &'static str,
value: impl Serialize,
state: &mut JTXState
) -> Result<(), RPCError>
[src]
&mut self,
name: &'static str,
value: impl Serialize,
state: &mut JTXState
) -> Result<(), RPCError>
fn tx_finalize(
&mut self,
state: JTXState
) -> Result<Box<dyn Future<Item = Vec<u8>, Error = RPCError>>, RPCError>
[src]
&mut self,
state: JTXState
) -> Result<Box<dyn Future<Item = Vec<u8>, Error = RPCError>>, RPCError>
fn rx_response<T>(
&mut self,
state: Box<dyn Future<Item = Vec<u8>, Error = RPCError>>
) -> Box<dyn Future<Item = T, Error = RPCError>> where
T: Deserialize<'de>,
T: 'static,
[src]
&mut self,
state: Box<dyn Future<Item = Vec<u8>, Error = RPCError>>
) -> Box<dyn Future<Item = T, Error = RPCError>> where
T: Deserialize<'de>,
T: 'static,