use bytes::Bytes;
use crate::{block, prelude::*};
#[doc = include_str!("../doc/request-query.md")]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Query {
pub data: Bytes,
pub path: String,
pub height: block::Height,
pub prove: bool,
}
tendermint_pb_modules! {
use super::Query;
impl From<Query> for pb::abci::RequestQuery {
fn from(query: Query) -> Self {
Self {
data: query.data,
path: query.path,
height: query.height.into(),
prove: query.prove,
}
}
}
impl TryFrom<pb::abci::RequestQuery> for Query {
type Error = crate::Error;
fn try_from(query: pb::abci::RequestQuery) -> Result<Self, Self::Error> {
Ok(Self {
data: query.data,
path: query.path,
height: query.height.try_into()?,
prove: query.prove,
})
}
}
impl Protobuf<pb::abci::RequestQuery> for Query {}
}