thruput-xdr 0.66.0

Bindings for Thruput protocol structures
Documentation
// Generated by xdrc 0.18.0 (xdrs d7777c37264da66eb41f8139bd539c4aa049fcc5). Do not edit.

// clang-format off

#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(clippy::unnecessary_cast)]
use crate::*;
use core::ops::{Deref, DerefMut};
use core::option::Option;
#[cfg(feature = "std")]
use std::io::{Read, Write};
#[cfg(feature = "xdrs")]
use xdrs::*;
#[cfg(feature = "serde")]
use ::serde::{Deserialize, Serialize};

// clang-format on
// triple slash comments are added to the generated rust docs
/// Error codes returned by system calls.
/// Each syscall can return a specific subset of these error codes.
/// Check the syscalls.yaml documentation for which errors each syscall can return.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
pub struct SyscallErrorCode(pub i32);

impl SyscallErrorCode {
    /// No error
    pub const kSyscallErrorCodeNone: Self = Self(0);
    /// Out of bounds pointer to contract memory passed to syscall
    pub const kSyscallErrorCodeFault: Self = Self(1);
    /// System call for supplied number is not supported
    pub const kSyscallErrorCodeNoSyscall: Self = Self(2);
    /// Cannot call get_msg_sender on root invocation
    pub const kSyscallErrorCodeIsRootTransaction: Self = Self(3);
    /// Reentrance guard violation
    pub const kSyscallErrorCodeReentrance: Self = Self(4);
    /// Attempt made to deploy a contract twice (same nonce and contract hash, from
    /// same address)
    pub const kSyscallErrorCodeContractAlreadyDeployed: Self = Self(5);
    /// No return buffer is available.  Either the most recent subcall faulted, or
    /// there have been no subcalls within this call frame.
    pub const kSyscallErrorCodeNoReturnBufferAvailable: Self = Self(6);
    /// Invalid input to a syscall, such as subtracting below 0 on an nnint
    /// or a bytestring that is too long
    pub const kSyscallErrorCodeInvalidSyscallInput: Self = Self(7);
    /// Accessing a storage key that does not exist in the current view
    pub const kSyscallErrorCodeStorageKeyNotExist: Self = Self(8);
    /// No entry in the retrocausal queue to consume
    pub const kSyscallErrorCodeNoRetrocausalQueueEntry: Self = Self(9);
    /// The transaction has reached its per-transaction limit on concurrent
    /// retrocausal-queue reads (kMaxConcurrentRcqReadsPerTx). This is a resource
    /// limit, not a malformed call, and does not by itself fail the transaction;
    /// a contract may use it as a stop condition (e.g. drain a queue until it
    /// returns this).
    pub const kSyscallErrorCodeRetrocausalQueueReadLimitReached: Self = Self(10);
    /// The invocation would exceed the network's cross-invoke depth bound
    /// (kConfigParamMaxCrossInvokeDepth), which limits how many invocation
    /// frames one transaction may hold open at once. Like the retrocausal-queue
    /// read limit this is a resource limit, not a malformed call: the same
    /// invocation succeeds from a shallower frame. It is reported before any
    /// child frame runs, so the syscall is a complete no-op and the caller's
    /// invoke outputs are left untouched.
    pub const kSyscallErrorCodeInvokeDepthExceeded: Self = Self(11);
}

impl From<i32> for SyscallErrorCode {
    fn from(v: i32) -> Self {
        Self(v)
    }
}

#[cfg(feature = "xdrs")]
impl xdrs::XDRDiscriminant for SyscallErrorCode {
    const ENCODING: xdrs::DiscriminantEncoding = xdrs::DiscriminantEncoding::Signed;
    fn discriminant(&self) -> i32 {
        self.0
    }
    fn from_discriminant(d: i32) -> Self {
        Self(d)
    }
}

#[cfg(feature = "std")]
impl core::fmt::Display for SyscallErrorCode {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self.0 {
            x if x == Self::kSyscallErrorCodeNone.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeNone")
            }
            x if x == Self::kSyscallErrorCodeFault.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeFault")
            }
            x if x == Self::kSyscallErrorCodeNoSyscall.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeNoSyscall")
            }
            x if x == Self::kSyscallErrorCodeIsRootTransaction.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeIsRootTransaction")
            }
            x if x == Self::kSyscallErrorCodeReentrance.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeReentrance")
            }
            x if x == Self::kSyscallErrorCodeContractAlreadyDeployed.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeContractAlreadyDeployed")
            }
            x if x == Self::kSyscallErrorCodeNoReturnBufferAvailable.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeNoReturnBufferAvailable")
            }
            x if x == Self::kSyscallErrorCodeInvalidSyscallInput.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeInvalidSyscallInput")
            }
            x if x == Self::kSyscallErrorCodeStorageKeyNotExist.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeStorageKeyNotExist")
            }
            x if x == Self::kSyscallErrorCodeNoRetrocausalQueueEntry.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeNoRetrocausalQueueEntry")
            }
            x if x == Self::kSyscallErrorCodeRetrocausalQueueReadLimitReached.0 => {
                f.write_str(
                    "SyscallErrorCode::kSyscallErrorCodeRetrocausalQueueReadLimitReached",
                )
            }
            x if x == Self::kSyscallErrorCodeInvokeDepthExceeded.0 => {
                f.write_str("SyscallErrorCode::kSyscallErrorCodeInvokeDepthExceeded")
            }
            _ => write!(f, "SyscallErrorCode({})", self.0),
        }
    }
}