Skip to main content

thruput_xdr/
syscall_error.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 6ab835b07c234abb4b0b50b61d687904727a4f32
5
6// clang-format off
7
8#![allow(non_camel_case_types)]
9#![allow(non_snake_case)]
10#![allow(non_upper_case_globals)]
11#![allow(unused_imports)]
12#![allow(dead_code)]
13#![allow(unused_variables)]
14#![allow(clippy::unnecessary_cast)]
15
16use crate::*;
17use core::option::Option;
18use core::ops::{Deref, DerefMut};
19
20#[cfg(feature = "std")]
21use std::io::{Read, Write};
22#[cfg(feature = "xdrs")]
23use xdrs::*;
24
25
26#[cfg(feature = "serde")]
27use ::serde::{{Serialize, Deserialize}};
28
29
30// clang-format on
31
32// triple slash comments are added to the generated rust docs
33
34/// Error codes returned by system calls.
35/// Each syscall can return a specific subset of these error codes.
36/// Check the syscalls.yaml documentation for which errors each syscall can return.
37#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
38#[cfg_attr(feature = "serde", serde(transparent))]
39#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
40#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
41#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42#[derive(Copy)]
43#[repr(transparent)]
44pub struct SyscallErrorCode(pub i32);
45
46impl SyscallErrorCode {
47    /// No error
48    pub const kSyscallErrorCodeNone: Self = Self(0);
49
50    /// Out of bounds pointer to contract memory passed to syscall
51    pub const kSyscallErrorCodeFault: Self = Self(1);
52
53    /// System call for supplied number is not supported
54    pub const kSyscallErrorCodeNoSyscall: Self = Self(2);
55
56    /// Cannot call get_msg_sender on root invocation
57    pub const kSyscallErrorCodeIsRootTransaction: Self = Self(3);
58
59    /// Reentrance guard violation
60    pub const kSyscallErrorCodeReentrance: Self = Self(4);
61
62    /// Attempt made to deploy a contract twice (same nonce and contract hash, from
63    /// same address)
64    pub const kSyscallErrorCodeContractAlreadyDeployed: Self = Self(5);
65
66    /// No return buffer is available.  Either the most recent subcall faulted, or
67    /// there have been no subcalls within this call frame.
68    pub const kSyscallErrorCodeNoReturnBufferAvailable: Self = Self(6);
69
70    /// Invalid input to a syscall, such as subtracting below 0 on an nnint
71    /// or a bytestring that is too long
72    pub const kSyscallErrorCodeInvalidSyscallInput: Self = Self(7);
73
74    /// Accessing a storage key that does not exist in the current view
75    pub const kSyscallErrorCodeStorageKeyNotExist: Self = Self(8);
76
77    /// No entry in the retrocausal queue to consume
78    pub const kSyscallErrorCodeNoRetrocausalQueueEntry: Self = Self(9);
79
80    /// The transaction has reached its per-transaction limit on concurrent
81    /// retrocausal-queue reads (kMaxConcurrentRcqReadsPerTx). This is a resource
82    /// limit, not a malformed call, and does not by itself fail the transaction;
83    /// a contract may use it as a stop condition (e.g. drain a queue until it
84    /// returns this).
85    pub const kSyscallErrorCodeRetrocausalQueueReadLimitReached: Self = Self(10);
86
87    /// The invocation would exceed the network's cross-invoke depth bound
88    /// (kConfigParamMaxCrossInvokeDepth), which limits how many invocation
89    /// frames one transaction may hold open at once. Like the retrocausal-queue
90    /// read limit this is a resource limit, not a malformed call: the same
91    /// invocation succeeds from a shallower frame. It is reported before any
92    /// child frame runs, so the syscall is a complete no-op and the caller's
93    /// invoke outputs are left untouched.
94    pub const kSyscallErrorCodeInvokeDepthExceeded: Self = Self(11);
95}
96impl From<i32> for SyscallErrorCode {
97    fn from(v: i32) -> Self {
98        Self(v)
99    }
100}
101#[cfg(feature = "std")]
102impl core::fmt::Display for SyscallErrorCode {
103    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
104        match self.0 {
105            x if x == Self::kSyscallErrorCodeNone.0 => {
106                write!(f, "SyscallErrorCode::kSyscallErrorCodeNone")
107            },
108            x if x == Self::kSyscallErrorCodeFault.0 => {
109                write!(f, "SyscallErrorCode::kSyscallErrorCodeFault")
110            },
111            x if x == Self::kSyscallErrorCodeNoSyscall.0 => {
112                write!(f, "SyscallErrorCode::kSyscallErrorCodeNoSyscall")
113            },
114            x if x == Self::kSyscallErrorCodeIsRootTransaction.0 => {
115                write!(f, "SyscallErrorCode::kSyscallErrorCodeIsRootTransaction")
116            },
117            x if x == Self::kSyscallErrorCodeReentrance.0 => {
118                write!(f, "SyscallErrorCode::kSyscallErrorCodeReentrance")
119            },
120            x if x == Self::kSyscallErrorCodeContractAlreadyDeployed.0 => {
121                write!(f, "SyscallErrorCode::kSyscallErrorCodeContractAlreadyDeployed")
122            },
123            x if x == Self::kSyscallErrorCodeNoReturnBufferAvailable.0 => {
124                write!(f, "SyscallErrorCode::kSyscallErrorCodeNoReturnBufferAvailable")
125            },
126            x if x == Self::kSyscallErrorCodeInvalidSyscallInput.0 => {
127                write!(f, "SyscallErrorCode::kSyscallErrorCodeInvalidSyscallInput")
128            },
129            x if x == Self::kSyscallErrorCodeStorageKeyNotExist.0 => {
130                write!(f, "SyscallErrorCode::kSyscallErrorCodeStorageKeyNotExist")
131            },
132            x if x == Self::kSyscallErrorCodeNoRetrocausalQueueEntry.0 => {
133                write!(f, "SyscallErrorCode::kSyscallErrorCodeNoRetrocausalQueueEntry")
134            },
135            x if x == Self::kSyscallErrorCodeRetrocausalQueueReadLimitReached.0 => {
136                write!(f, "SyscallErrorCode::kSyscallErrorCodeRetrocausalQueueReadLimitReached")
137            },
138            x if x == Self::kSyscallErrorCodeInvokeDepthExceeded.0 => {
139                write!(f, "SyscallErrorCode::kSyscallErrorCodeInvokeDepthExceeded")
140            },
141            _ => {
142                write!(f, "SyscallErrorCode({})", self.0)
143            }
144        }
145    }
146}
147
148
149
150//
151// XDR internals below this point
152//
153
154