tendermint_rpc/dialect/
v0_37.rs

1use tendermint::evidence;
2use tendermint_proto::v0_37 as raw;
3
4use crate::prelude::*;
5use serde::{Deserialize, Serialize};
6
7/// The Event serialization in the latest RPC dialect is the canonical
8/// serialization for the ABCI domain type.
9pub use tendermint::abci::Event;
10
11#[derive(Default, Clone)]
12pub struct Dialect;
13
14impl crate::dialect::Dialect for Dialect {
15    type Event = Event;
16    type Evidence = Evidence;
17}
18
19#[derive(Clone, Debug, Serialize, Deserialize)]
20#[serde(into = "raw::types::Evidence", try_from = "raw::types::Evidence")]
21pub struct Evidence(evidence::Evidence);
22
23impl From<Evidence> for raw::types::Evidence {
24    fn from(evidence: Evidence) -> Self {
25        evidence.0.into()
26    }
27}
28
29impl TryFrom<raw::types::Evidence> for Evidence {
30    type Error = <evidence::Evidence as TryFrom<raw::types::Evidence>>::Error;
31
32    fn try_from(value: raw::types::Evidence) -> Result<Self, Self::Error> {
33        Ok(Self(evidence::Evidence::try_from(value)?))
34    }
35}
36
37impl From<evidence::Evidence> for Evidence {
38    fn from(evidence: evidence::Evidence) -> Self {
39        Self(evidence)
40    }
41}
42
43impl From<Evidence> for evidence::Evidence {
44    fn from(evidence: Evidence) -> Self {
45        evidence.0
46    }
47}