1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use bytes::Bytes;
use crate::{block, prelude::*, Error};
#[doc = include_str!("../doc/response-info.md")]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Info {
pub data: String,
pub version: String,
pub app_version: u64,
pub last_block_height: block::Height,
pub last_block_app_hash: Bytes,
}
use core::convert::TryFrom;
use tendermint_proto::{abci as pb, Protobuf};
impl From<Info> for pb::ResponseInfo {
fn from(info: Info) -> Self {
Self {
data: info.data,
version: info.version,
app_version: info.app_version,
last_block_height: info.last_block_height.into(),
last_block_app_hash: info.last_block_app_hash,
}
}
}
impl TryFrom<pb::ResponseInfo> for Info {
type Error = Error;
fn try_from(info: pb::ResponseInfo) -> Result<Self, Self::Error> {
Ok(Self {
data: info.data,
version: info.version,
app_version: info.app_version,
last_block_height: info.last_block_height.try_into()?,
last_block_app_hash: info.last_block_app_hash,
})
}
}
impl Protobuf<pb::ResponseInfo> for Info {}