cometbft_rpc/dialect/
begin_block.rs1use serde::{Deserialize, Serialize};
2
3use cometbft::abci;
4
5use crate::prelude::*;
6
7#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
8pub struct BeginBlock<Ev> {
9 #[serde(default = "Default::default")]
11 pub events: Vec<Ev>,
12}
13
14impl<Ev> Default for BeginBlock<Ev> {
15 fn default() -> Self {
16 Self {
17 events: Default::default(),
18 }
19 }
20}
21
22impl<Ev> From<BeginBlock<Ev>> for abci::response::BeginBlock
23where
24 Ev: Into<abci::Event>,
25{
26 fn from(msg: BeginBlock<Ev>) -> Self {
27 Self {
28 events: msg.events.into_iter().map(Into::into).collect(),
29 }
30 }
31}
32
33impl<Ev> From<abci::response::BeginBlock> for BeginBlock<Ev>
34where
35 abci::Event: Into<Ev>,
36{
37 fn from(value: abci::response::BeginBlock) -> Self {
38 Self {
39 events: value.events.into_iter().map(Into::into).collect(),
40 }
41 }
42}