use crate::prelude::*;
#[doc = include_str!("../doc/response-applysnapshotchunk.md")]
#[derive(Clone, PartialEq, Eq, Debug, Default)]
pub struct ApplySnapshotChunk {
pub result: ApplySnapshotChunkResult,
pub refetch_chunks: Vec<u32>,
pub reject_senders: Vec<String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(i32)]
pub enum ApplySnapshotChunkResult {
Unknown = 0,
Accept = 1,
Abort = 2,
Retry = 3,
RetrySnapshot = 4,
RejectSnapshot = 5,
}
impl Default for ApplySnapshotChunkResult {
fn default() -> Self {
Self::Unknown
}
}
tendermint_pb_modules! {
use super::{ApplySnapshotChunk, ApplySnapshotChunkResult};
impl From<ApplySnapshotChunk> for pb::abci::ResponseApplySnapshotChunk {
fn from(apply_snapshot_chunk: ApplySnapshotChunk) -> Self {
Self {
result: apply_snapshot_chunk.result as i32,
refetch_chunks: apply_snapshot_chunk.refetch_chunks,
reject_senders: apply_snapshot_chunk.reject_senders,
}
}
}
impl TryFrom<pb::abci::ResponseApplySnapshotChunk> for ApplySnapshotChunk {
type Error = crate::Error;
fn try_from(apply_snapshot_chunk: pb::abci::ResponseApplySnapshotChunk) -> Result<Self, Self::Error> {
let result = match apply_snapshot_chunk.result {
0 => ApplySnapshotChunkResult::Unknown,
1 => ApplySnapshotChunkResult::Accept,
2 => ApplySnapshotChunkResult::Abort,
3 => ApplySnapshotChunkResult::Retry,
4 => ApplySnapshotChunkResult::RetrySnapshot,
5 => ApplySnapshotChunkResult::RejectSnapshot,
_ => return Err(crate::Error::unsupported_apply_snapshot_chunk_result()),
};
Ok(Self {
result,
refetch_chunks: apply_snapshot_chunk.refetch_chunks,
reject_senders: apply_snapshot_chunk.reject_senders,
})
}
}
impl Protobuf<pb::abci::ResponseApplySnapshotChunk> for ApplySnapshotChunk {}
}