tendermint/abci/response/
list_snapshots.rs

1use super::super::types::Snapshot;
2use crate::prelude::*;
3
4#[doc = include_str!("../doc/response-listsnapshots.md")]
5#[derive(Clone, PartialEq, Eq, Debug, Default)]
6pub struct ListSnapshots {
7    /// A list of local state snapshots.
8    pub snapshots: Vec<Snapshot>,
9}
10
11// =============================================================================
12// Protobuf conversions
13// =============================================================================
14
15tendermint_pb_modules! {
16    use super::ListSnapshots;
17
18    impl From<ListSnapshots> for pb::abci::ResponseListSnapshots {
19        fn from(list_snapshots: ListSnapshots) -> Self {
20            Self {
21                snapshots: list_snapshots
22                    .snapshots
23                    .into_iter()
24                    .map(Into::into)
25                    .collect(),
26            }
27        }
28    }
29
30    impl TryFrom<pb::abci::ResponseListSnapshots> for ListSnapshots {
31        type Error = crate::Error;
32
33        fn try_from(list_snapshots: pb::abci::ResponseListSnapshots) -> Result<Self, Self::Error> {
34            Ok(Self {
35                snapshots: list_snapshots
36                    .snapshots
37                    .into_iter()
38                    .map(TryInto::try_into)
39                    .collect::<Result<_, _>>()?,
40            })
41        }
42    }
43
44    impl Protobuf<pb::abci::ResponseListSnapshots> for ListSnapshots {}
45}