1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use crate::prelude::*;

#[doc = include_str!("../doc/response-processproposal.md")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(i32)]
#[derive(Default)]
pub enum ProcessProposal {
    #[default]
    Unknown = 0,
    Accept = 1,
    Reject = 2,
}

// =============================================================================
// Protobuf conversions
// =============================================================================

mod v0_37 {
    use super::ProcessProposal;
    use crate::Error;
    use tendermint_proto::v0_37::abci as pb;
    use tendermint_proto::Protobuf;

    impl From<ProcessProposal> for pb::ResponseProcessProposal {
        fn from(value: ProcessProposal) -> Self {
            Self {
                status: value as i32,
            }
        }
    }

    impl TryFrom<pb::ResponseProcessProposal> for ProcessProposal {
        type Error = Error;

        fn try_from(message: pb::ResponseProcessProposal) -> Result<Self, Self::Error> {
            use pb::response_process_proposal::ProposalStatus;

            let status = message
                .status
                .try_into()
                .map_err(|_| Error::unsupported_process_proposal_status())?;

            let value = match status {
                ProposalStatus::Unknown => ProcessProposal::Unknown,
                ProposalStatus::Accept => ProcessProposal::Accept,
                ProposalStatus::Reject => ProcessProposal::Reject,
            };
            Ok(value)
        }
    }

    impl Protobuf<pb::ResponseProcessProposal> for ProcessProposal {}
}

mod v0_38 {
    use super::ProcessProposal;
    use crate::Error;
    use tendermint_proto::v0_38::abci as pb;
    use tendermint_proto::Protobuf;

    impl From<ProcessProposal> for pb::ResponseProcessProposal {
        fn from(value: ProcessProposal) -> Self {
            Self {
                status: value as i32,
            }
        }
    }

    impl TryFrom<pb::ResponseProcessProposal> for ProcessProposal {
        type Error = Error;

        fn try_from(message: pb::ResponseProcessProposal) -> Result<Self, Self::Error> {
            use pb::response_process_proposal::ProposalStatus;

            let status = message
                .status
                .try_into()
                .map_err(|_| Error::unsupported_process_proposal_status())?;

            let value = match status {
                ProposalStatus::Unknown => ProcessProposal::Unknown,
                ProposalStatus::Accept => ProcessProposal::Accept,
                ProposalStatus::Reject => ProcessProposal::Reject,
            };
            Ok(value)
        }
    }

    impl Protobuf<pb::ResponseProcessProposal> for ProcessProposal {}
}