Skip to main content

thruput_xdr/
exec_result.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 6ab835b07c234abb4b0b50b61d687904727a4f32
5
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(non_upper_case_globals)]
9#![allow(unused_imports)]
10#![allow(dead_code)]
11#![allow(unused_variables)]
12#![allow(clippy::unnecessary_cast)]
13
14use crate::*;
15use core::option::Option;
16use core::ops::{Deref, DerefMut};
17
18#[cfg(feature = "std")]
19use std::io::{Read, Write};
20#[cfg(feature = "xdrs")]
21use xdrs::*;
22
23
24#[cfg(feature = "serde")]
25use ::serde::{{Serialize, Deserialize}};
26
27
28#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
29#[cfg_attr(feature = "serde", serde(transparent))]
30#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
31#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
32#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
33#[derive(Copy)]
34#[repr(transparent)]
35pub struct ExecResult(pub i32);
36
37impl ExecResult {
38    pub const ExecResultOK: Self = Self(0);
39
40    // Transaction execution (during proposal or validation) failed.
41    // Specifically, the root frame failed with Deterministic or OutOfGas.
42    // the error is deterministic and can be replayed in validation.
43    // Transactions with this error code can be included in the block.
44    pub const ExecResultTxDeterministicError: Self = Self(1);
45
46    // The root frame of the transaction chose to revert.
47    // This error is deterministic and can be included in a block.
48    // However, any changes within contract state are reverted.
49    pub const ExecResultTxRootFrameReverted: Self = Self(2);
50
51    // Transaction execution (during proposal or validation) failed,
52    // due to nondeterminism during the post-execution 2-phase commit.
53    // Transactions with this error code should not be included in a proposal,
54    // and indicate a block validation failure.
55    pub const ExecResultTxNonDeterministicError: Self = Self(3);
56
57    // No longer used. Previously indicated that gas sponsorship claims were
58    // not validated. Retained to avoid renumbering enum values.
59    pub const ExecResultFailedGasSponsorship: Self = Self(100);
60
61    // Validation on the transaction has failed because the attached validation
62    // data is bad. E.g. missing data or unused data. This error code is only
63    // returned during validation. This is determininistic, but signals a bad
64    // block from a malicious proposer.
65    pub const ExecResultTxValidationFailure: Self = Self(200);
66
67    // The transaction is malformed: a structural check rejected it before
68    // execution, on its contents alone and independent of ledger state.
69    // This error code is only returned during proposal, where the scheduler
70    // drops the transaction instead of including it in the block. The same
71    // defect during validation is ExecResultTxValidationFailure, since a
72    // malformed transaction inside a proposed block is the proposer's fault.
73    pub const ExecResultMalformedTransaction: Self = Self(201);
74
75    // System error; network connection broke, etc.
76    // Executor can recover from this error to continue execution of other
77    // transactions.
78    pub const ExecResultSystemError: Self = Self(300);
79
80    // Critical failure in the executor, which cannot be recovered from.
81    // E.g. OOM or critical logic error.
82    pub const ExecResultUnrecoverable: Self = Self(400);
83}
84impl From<i32> for ExecResult {
85    fn from(v: i32) -> Self {
86        Self(v)
87    }
88}
89#[cfg(feature = "std")]
90impl core::fmt::Display for ExecResult {
91    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
92        match self.0 {
93            x if x == Self::ExecResultOK.0 => {
94                write!(f, "ExecResult::ExecResultOK")
95            },
96            x if x == Self::ExecResultTxDeterministicError.0 => {
97                write!(f, "ExecResult::ExecResultTxDeterministicError")
98            },
99            x if x == Self::ExecResultTxRootFrameReverted.0 => {
100                write!(f, "ExecResult::ExecResultTxRootFrameReverted")
101            },
102            x if x == Self::ExecResultTxNonDeterministicError.0 => {
103                write!(f, "ExecResult::ExecResultTxNonDeterministicError")
104            },
105            x if x == Self::ExecResultFailedGasSponsorship.0 => {
106                write!(f, "ExecResult::ExecResultFailedGasSponsorship")
107            },
108            x if x == Self::ExecResultTxValidationFailure.0 => {
109                write!(f, "ExecResult::ExecResultTxValidationFailure")
110            },
111            x if x == Self::ExecResultMalformedTransaction.0 => {
112                write!(f, "ExecResult::ExecResultMalformedTransaction")
113            },
114            x if x == Self::ExecResultSystemError.0 => {
115                write!(f, "ExecResult::ExecResultSystemError")
116            },
117            x if x == Self::ExecResultUnrecoverable.0 => {
118                write!(f, "ExecResult::ExecResultUnrecoverable")
119            },
120            _ => {
121                write!(f, "ExecResult({})", self.0)
122            }
123        }
124    }
125}
126
127
128
129//
130// XDR internals below this point
131//
132
133