celestia_core/abci/response/
begin_block.rs

1use super::super::Event;
2use crate::prelude::*;
3
4#[doc = include_str!("../doc/response-beginblock.md")]
5#[derive(Clone, PartialEq, Eq, Debug, Default)]
6pub struct BeginBlock {
7    /// Events that occurred while beginning the block.
8    pub events: Vec<Event>,
9}
10
11// =============================================================================
12// Protobuf conversions
13// =============================================================================
14
15tendermint_pb_modules! {
16    use super::BeginBlock;
17
18    impl From<BeginBlock> for pb::abci::ResponseBeginBlock {
19        fn from(begin_block: BeginBlock) -> Self {
20            Self {
21                events: begin_block.events.into_iter().map(Into::into).collect(),
22            }
23        }
24    }
25
26    impl TryFrom<pb::abci::ResponseBeginBlock> for BeginBlock {
27        type Error = crate::Error;
28
29        fn try_from(begin_block: pb::abci::ResponseBeginBlock) -> Result<Self, Self::Error> {
30            Ok(Self {
31                events: begin_block
32                    .events
33                    .into_iter()
34                    .map(TryInto::try_into)
35                    .collect::<Result<_, _>>()?,
36            })
37        }
38    }
39
40    impl Protobuf<pb::abci::ResponseBeginBlock> for BeginBlock {}
41}