thruput_xdr/
syscall_error.rs1#![allow(non_camel_case_types)]
6#![allow(non_snake_case)]
7#![allow(non_upper_case_globals)]
8#![allow(unused_imports)]
9#![allow(dead_code)]
10#![allow(unused_variables)]
11#![allow(clippy::unnecessary_cast)]
12use crate::*;
13use core::ops::{Deref, DerefMut};
14use core::option::Option;
15#[cfg(feature = "std")]
16use std::io::{Read, Write};
17#[cfg(feature = "xdrs")]
18use xdrs::*;
19#[cfg(feature = "serde")]
20use ::serde::{Deserialize, Serialize};
21
22#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
28#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
29#[cfg_attr(feature = "serde", serde(transparent))]
30#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
31#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
32#[derive(Copy)]
33#[repr(transparent)]
34pub struct SyscallErrorCode(pub i32);
35
36impl SyscallErrorCode {
37 pub const kSyscallErrorCodeNone: Self = Self(0);
39 pub const kSyscallErrorCodeFault: Self = Self(1);
41 pub const kSyscallErrorCodeNoSyscall: Self = Self(2);
43 pub const kSyscallErrorCodeIsRootTransaction: Self = Self(3);
45 pub const kSyscallErrorCodeReentrance: Self = Self(4);
47 pub const kSyscallErrorCodeContractAlreadyDeployed: Self = Self(5);
50 pub const kSyscallErrorCodeNoReturnBufferAvailable: Self = Self(6);
53 pub const kSyscallErrorCodeInvalidSyscallInput: Self = Self(7);
56 pub const kSyscallErrorCodeStorageKeyNotExist: Self = Self(8);
58 pub const kSyscallErrorCodeNoRetrocausalQueueEntry: Self = Self(9);
60 pub const kSyscallErrorCodeRetrocausalQueueReadLimitReached: Self = Self(10);
66 pub const kSyscallErrorCodeInvokeDepthExceeded: Self = Self(11);
74}
75
76impl From<i32> for SyscallErrorCode {
77 fn from(v: i32) -> Self {
78 Self(v)
79 }
80}
81
82#[cfg(feature = "xdrs")]
83impl xdrs::XDRDiscriminant for SyscallErrorCode {
84 const ENCODING: xdrs::DiscriminantEncoding = xdrs::DiscriminantEncoding::Signed;
85 fn discriminant(&self) -> i32 {
86 self.0
87 }
88 fn from_discriminant(d: i32) -> Self {
89 Self(d)
90 }
91}
92
93#[cfg(feature = "std")]
94impl core::fmt::Display for SyscallErrorCode {
95 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
96 match self.0 {
97 x if x == Self::kSyscallErrorCodeNone.0 => {
98 f.write_str("SyscallErrorCode::kSyscallErrorCodeNone")
99 }
100 x if x == Self::kSyscallErrorCodeFault.0 => {
101 f.write_str("SyscallErrorCode::kSyscallErrorCodeFault")
102 }
103 x if x == Self::kSyscallErrorCodeNoSyscall.0 => {
104 f.write_str("SyscallErrorCode::kSyscallErrorCodeNoSyscall")
105 }
106 x if x == Self::kSyscallErrorCodeIsRootTransaction.0 => {
107 f.write_str("SyscallErrorCode::kSyscallErrorCodeIsRootTransaction")
108 }
109 x if x == Self::kSyscallErrorCodeReentrance.0 => {
110 f.write_str("SyscallErrorCode::kSyscallErrorCodeReentrance")
111 }
112 x if x == Self::kSyscallErrorCodeContractAlreadyDeployed.0 => {
113 f.write_str("SyscallErrorCode::kSyscallErrorCodeContractAlreadyDeployed")
114 }
115 x if x == Self::kSyscallErrorCodeNoReturnBufferAvailable.0 => {
116 f.write_str("SyscallErrorCode::kSyscallErrorCodeNoReturnBufferAvailable")
117 }
118 x if x == Self::kSyscallErrorCodeInvalidSyscallInput.0 => {
119 f.write_str("SyscallErrorCode::kSyscallErrorCodeInvalidSyscallInput")
120 }
121 x if x == Self::kSyscallErrorCodeStorageKeyNotExist.0 => {
122 f.write_str("SyscallErrorCode::kSyscallErrorCodeStorageKeyNotExist")
123 }
124 x if x == Self::kSyscallErrorCodeNoRetrocausalQueueEntry.0 => {
125 f.write_str("SyscallErrorCode::kSyscallErrorCodeNoRetrocausalQueueEntry")
126 }
127 x if x == Self::kSyscallErrorCodeRetrocausalQueueReadLimitReached.0 => {
128 f.write_str(
129 "SyscallErrorCode::kSyscallErrorCodeRetrocausalQueueReadLimitReached",
130 )
131 }
132 x if x == Self::kSyscallErrorCodeInvokeDepthExceeded.0 => {
133 f.write_str("SyscallErrorCode::kSyscallErrorCodeInvokeDepthExceeded")
134 }
135 _ => write!(f, "SyscallErrorCode({})", self.0),
136 }
137 }
138}