tendermint/abci/request/
check_tx.rs1use bytes::Bytes;
2
3use crate::prelude::*;
4
5#[doc = include_str!("../doc/request-checktx.md")]
6#[derive(Clone, PartialEq, Eq, Debug)]
7pub struct CheckTx {
8 pub tx: Bytes,
10 pub kind: CheckTxKind,
15}
16
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
24#[repr(i32)]
25#[derive(Default)]
26pub enum CheckTxKind {
27 #[default]
29 New = 0,
30 Recheck = 1,
32}
33
34tendermint_pb_modules! {
39 use super::{CheckTx, CheckTxKind};
40
41 impl From<CheckTx> for pb::abci::RequestCheckTx {
42 fn from(check_tx: CheckTx) -> Self {
43 Self {
44 tx: check_tx.tx,
45 r#type: check_tx.kind as i32,
46 }
47 }
48 }
49
50 impl TryFrom<pb::abci::RequestCheckTx> for CheckTx {
51 type Error = crate::Error;
52
53 fn try_from(check_tx: pb::abci::RequestCheckTx) -> Result<Self, Self::Error> {
54 let kind = match check_tx.r#type {
55 0 => CheckTxKind::New,
56 1 => CheckTxKind::Recheck,
57 _ => return Err(crate::Error::unsupported_check_tx_type()),
58 };
59 Ok(Self {
60 tx: check_tx.tx,
61 kind,
62 })
63 }
64 }
65
66 impl Protobuf<pb::abci::RequestCheckTx> for CheckTx {}
67}