celestia_core/block/
data.rs1use celestia_core_proto::v0_34::types::Data as RawData;
2use serde::{Deserialize, Serialize};
3
4use crate::prelude::*;
5
6#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
7#[non_exhaustive]
8#[serde(try_from = "RawData", into = "RawData")]
9pub struct Data {
10 pub txs: Vec<Vec<u8>>,
11 pub square_size: u64,
12 pub hash: Vec<u8>,
13}
14
15mod v0_34 {
16 use super::Data;
17 use crate::{prelude::*, Error};
18 use celestia_core_proto::v0_34::types::Data as RawData;
19 use celestia_core_proto::Protobuf;
20
21 impl Protobuf<RawData> for Data {}
22
23 impl TryFrom<RawData> for Data {
24 type Error = Error;
25
26 fn try_from(value: RawData) -> Result<Self, Self::Error> {
27 Ok(Data {
28 txs: value.txs,
29 square_size: value.square_size,
30 hash: value.hash,
31 })
32 }
33 }
34
35 impl From<Data> for RawData {
36 fn from(value: Data) -> RawData {
37 RawData {
38 txs: value.txs,
39 square_size: value.square_size,
40 hash: value.hash,
41 }
42 }
43 }
44}