thruput-xdr 0.66.0

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

#![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
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct GenesisConfiguration {
    pub network_hash: NetworkHash,
    pub storage_cost_model: StorageCostModelXdr,
    /// The execution parameters block 0 runs under, in canonical form. Carried
    /// into the DbTip at genesis load and forward by every later commit.
    pub network_config: NetworkConfig,
    pub root_contract: Contract,
    /// The contract resolved for root invocations of undeployed addresses.
    /// Committed to by `ProposalHeader::config_hash` through
    /// `ConfigHashPreimage`, so a node cannot run under a different one than
    /// the chain agreed.
    pub default_wallet: DeployedContractHash,
}

// These translated into the contract addresses that are initialized
// at the start of the chain.
//
// The addresses (32 bytes) are all zeros, with the last 4 bytes equal
// to the enum value.
#[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 GenesisContractAddresses(pub i32);

impl GenesisContractAddresses {
    // Null address (reserved)
    pub const kAddressNull: Self = Self(0);
    // Precompiled native-token contract
    pub const kAddressNativeToken: Self = Self(1);
    // Genesis root contract
    pub const kAddressGenesisRoot: Self = Self(2);
}

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

#[cfg(feature = "xdrs")]
impl xdrs::XDRDiscriminant for GenesisContractAddresses {
    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 GenesisContractAddresses {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self.0 {
            x if x == Self::kAddressNull.0 => {
                f.write_str("GenesisContractAddresses::kAddressNull")
            }
            x if x == Self::kAddressNativeToken.0 => {
                f.write_str("GenesisContractAddresses::kAddressNativeToken")
            }
            x if x == Self::kAddressGenesisRoot.0 => {
                f.write_str("GenesisContractAddresses::kAddressGenesisRoot")
            }
            _ => write!(f, "GenesisContractAddresses({})", self.0),
        }
    }
}