tendermint/abci/request/
load_snapshot_chunk.rs

1use crate::{block, prelude::*};
2
3#[doc = include_str!("../doc/request-loadsnapshotchunk.md")]
4#[derive(Clone, PartialEq, Eq, Debug)]
5pub struct LoadSnapshotChunk {
6    /// The height of the snapshot the chunks belong to.
7    pub height: block::Height,
8    /// An application-specific identifier of the format of the snapshot chunk.
9    pub format: u32,
10    /// The chunk index, starting from `0` for the initial chunk.
11    pub chunk: u32,
12}
13
14// =============================================================================
15// Protobuf conversions
16// =============================================================================
17
18tendermint_pb_modules! {
19    use super::LoadSnapshotChunk;
20
21    impl From<LoadSnapshotChunk> for pb::abci::RequestLoadSnapshotChunk {
22        fn from(load_snapshot_chunk: LoadSnapshotChunk) -> Self {
23            Self {
24                height: load_snapshot_chunk.height.into(),
25                format: load_snapshot_chunk.format,
26                chunk: load_snapshot_chunk.chunk,
27            }
28        }
29    }
30
31    impl TryFrom<pb::abci::RequestLoadSnapshotChunk> for LoadSnapshotChunk {
32        type Error = crate::Error;
33
34        fn try_from(load_snapshot_chunk: pb::abci::RequestLoadSnapshotChunk) -> Result<Self, Self::Error> {
35            Ok(Self {
36                height: load_snapshot_chunk.height.try_into()?,
37                format: load_snapshot_chunk.format,
38                chunk: load_snapshot_chunk.chunk,
39            })
40        }
41    }
42
43    impl Protobuf<pb::abci::RequestLoadSnapshotChunk> for LoadSnapshotChunk {}
44}