RpcTxConverter

Trait RpcTxConverter 

pub trait RpcTxConverter<Tx, RpcTx, TxInfo>:
    Clone
    + Debug
    + Unpin
    + Send
    + Sync
    + 'static {
    type Err;

    // Required method
    fn convert_rpc_tx(
        &self,
        tx: Tx,
        signer: Address,
        tx_info: TxInfo,
    ) -> Result<RpcTx, Self::Err>;
}
Expand description

Converts Tx into RpcTx

Where:

  • Tx is a transaction from the consensus layer.
  • RpcTx is a transaction response object of the RPC API

The conversion function is accompanied by signer’s address and tx_info providing extra context about a transaction in a block.

The RpcTxConverter has two blanket implementations:

One should prefer to implement IntoRpcTx for Tx to get the RpcTxConverter implementation for free, thanks to the blanket implementation, unless the conversion requires more context. For example, some configuration parameters or access handles to database, network, etc.

Required Associated Types§

type Err

An associated error that can happen during the conversion.

Required Methods§

fn convert_rpc_tx( &self, tx: Tx, signer: Address, tx_info: TxInfo, ) -> Result<RpcTx, Self::Err>

Performs the conversion of tx from Tx into RpcTx.

See RpcTxConverter for more information.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl<Tx, RpcTx> RpcTxConverter<Tx, RpcTx, <Tx as IntoRpcTx<RpcTx>>::TxInfo> for ()
where Tx: IntoRpcTx<RpcTx>,

§

type Err = Infallible

§

fn convert_rpc_tx( &self, tx: Tx, signer: Address, tx_info: <Tx as IntoRpcTx<RpcTx>>::TxInfo, ) -> Result<RpcTx, <() as RpcTxConverter<Tx, RpcTx, <Tx as IntoRpcTx<RpcTx>>::TxInfo>>::Err>

Implementors§

§

impl<Tx, RpcTx, F, TxInfo, E> RpcTxConverter<Tx, RpcTx, TxInfo> for F
where F: Fn(Tx, Address, TxInfo) -> Result<RpcTx, E> + Clone + Debug + Unpin + Send + Sync + 'static,

§

type Err = E