tendermint/abci/response/
info.rsuse crate::{block, prelude::*, AppHash};
use tendermint_proto::v0_37::abci as pb;
use serde::{Deserialize, Serialize};
#[doc = include_str!("../doc/response-info.md")]
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
#[serde(default, try_from = "pb::ResponseInfo", into = "pb::ResponseInfo")]
pub struct Info {
pub data: String,
pub version: String,
pub app_version: u64,
pub last_block_height: block::Height,
pub last_block_app_hash: AppHash,
}
tendermint_pb_modules! {
use super::Info;
impl From<Info> for pb::abci::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.into(),
}
}
}
impl TryFrom<pb::abci::ResponseInfo> for Info {
type Error = crate::Error;
fn try_from(info: pb::abci::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.try_into()?,
})
}
}
impl Protobuf<pb::abci::ResponseInfo> for Info {}
}