cometbft_rpc/endpoint/
header.rs1use cometbft::block::{self, Header};
4use serde::{Deserialize, Serialize};
5
6use crate::dialect::v1;
7use crate::request::RequestMessage;
8
9#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
11pub struct Request {
12 pub height: Option<block::Height>,
16}
17
18impl Request {
19 pub fn new(height: block::Height) -> Self {
21 Self {
22 height: Some(height),
23 }
24 }
25}
26
27impl RequestMessage for Request {
28 fn method(&self) -> crate::Method {
29 crate::Method::Header
30 }
31}
32
33impl crate::Request<v1::Dialect> for Request {
34 type Response = Response;
35}
36
37impl crate::SimpleRequest<v1::Dialect> for Request {
38 type Output = Response;
39}
40
41#[derive(Clone, Debug, Deserialize, Serialize)]
43pub struct Response {
44 pub header: Header,
46}
47
48impl crate::Response for Response {}
49
50impl From<super::block::Response> for Response {
51 fn from(block_resp: super::block::Response) -> Self {
52 Response {
53 header: block_resp.block.header,
54 }
55 }
56}