tendermint/abci/response/
apply_snapshot_chunk.rs1use crate::prelude::*;
2
3#[doc = include_str!("../doc/response-applysnapshotchunk.md")]
4#[derive(Clone, PartialEq, Eq, Debug, Default)]
5pub struct ApplySnapshotChunk {
6 pub result: ApplySnapshotChunkResult,
8 pub refetch_chunks: Vec<u32>,
13 pub reject_senders: Vec<String>,
19}
20
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
23#[repr(i32)]
24pub enum ApplySnapshotChunkResult {
25 Unknown = 0,
27 Accept = 1,
29 Abort = 2,
31 Retry = 3,
35 RetrySnapshot = 4,
39 RejectSnapshot = 5,
41}
42
43impl Default for ApplySnapshotChunkResult {
44 fn default() -> Self {
45 Self::Unknown
46 }
47}
48
49tendermint_pb_modules! {
54 use super::{ApplySnapshotChunk, ApplySnapshotChunkResult};
55
56 impl From<ApplySnapshotChunk> for pb::abci::ResponseApplySnapshotChunk {
57 fn from(apply_snapshot_chunk: ApplySnapshotChunk) -> Self {
58 Self {
59 result: apply_snapshot_chunk.result as i32,
60 refetch_chunks: apply_snapshot_chunk.refetch_chunks,
61 reject_senders: apply_snapshot_chunk.reject_senders,
62 }
63 }
64 }
65
66 impl TryFrom<pb::abci::ResponseApplySnapshotChunk> for ApplySnapshotChunk {
67 type Error = crate::Error;
68
69 fn try_from(apply_snapshot_chunk: pb::abci::ResponseApplySnapshotChunk) -> Result<Self, Self::Error> {
70 let result = match apply_snapshot_chunk.result {
71 0 => ApplySnapshotChunkResult::Unknown,
72 1 => ApplySnapshotChunkResult::Accept,
73 2 => ApplySnapshotChunkResult::Abort,
74 3 => ApplySnapshotChunkResult::Retry,
75 4 => ApplySnapshotChunkResult::RetrySnapshot,
76 5 => ApplySnapshotChunkResult::RejectSnapshot,
77 _ => return Err(crate::Error::unsupported_apply_snapshot_chunk_result()),
78 };
79 Ok(Self {
80 result,
81 refetch_chunks: apply_snapshot_chunk.refetch_chunks,
82 reject_senders: apply_snapshot_chunk.reject_senders,
83 })
84 }
85 }
86
87 impl Protobuf<pb::abci::ResponseApplySnapshotChunk> for ApplySnapshotChunk {}
88}