tendermint_rpc/endpoint/
header_by_hash.rs1use serde::{Deserialize, Serialize};
4use tendermint::{block::Header, Hash};
5
6use crate::dialect::{v0_37, v0_38, Dialect};
7use crate::request::RequestMessage;
8
9#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
11pub struct Request {
12 #[serde(default)]
20 #[serde(with = "crate::serializers::option_hash")]
21 pub hash: Option<Hash>,
22}
23
24impl Request {
25 pub fn new<H: Into<Hash>>(hash: H) -> Self {
27 Self {
28 hash: Some(hash.into()),
29 }
30 }
31}
32
33impl RequestMessage for Request {
34 fn method(&self) -> crate::Method {
35 crate::Method::HeaderByHash
36 }
37}
38
39impl crate::Request<v0_37::Dialect> for Request {
40 type Response = Response;
41}
42
43impl crate::Request<v0_38::Dialect> for Request {
44 type Response = Response;
45}
46
47impl<S: Dialect> crate::SimpleRequest<S> for Request
48where
49 Self: crate::Request<S>,
50 Response: From<Self::Response>,
51{
52 type Output = Response;
53}
54
55#[derive(Clone, Debug, Deserialize, Serialize)]
57pub struct Response {
58 pub header: Option<Header>,
60}
61
62impl crate::Response for Response {}
63
64impl From<super::block_by_hash::Response> for Response {
65 fn from(block_resp: super::block_by_hash::Response) -> Self {
66 Response {
67 header: block_resp.block.map(|b| b.header),
68 }
69 }
70}