#![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};
#[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 uint128_xdr {
pub highbits: u64,
pub lowbits: u64,
}
#[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 int128_xdr {
pub highbits: i64,
pub lowbits: u64,
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct Protocol {
inner: u32,
}
impl From<u32> for Protocol {
fn from(_inner: u32) -> Self {
Self { inner: _inner }
}
}
impl Protocol {
pub fn into_inner(self) -> u32 {
self.inner
}
pub const fn new(_inner: u32) -> Self {
Self { inner: _inner }
}
}
impl Deref for Protocol {
type Target = u32;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for Protocol {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct TimePoint {
inner: u64,
}
impl From<u64> for TimePoint {
fn from(_inner: u64) -> Self {
Self { inner: _inner }
}
}
impl TimePoint {
pub fn into_inner(self) -> u64 {
self.inner
}
pub const fn new(_inner: u64) -> Self {
Self { inner: _inner }
}
}
impl Deref for TimePoint {
type Target = u64;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for TimePoint {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct TimeSpan {
inner: u64,
}
impl From<u64> for TimeSpan {
fn from(_inner: u64) -> Self {
Self { inner: _inner }
}
}
impl TimeSpan {
pub fn into_inner(self) -> u64 {
self.inner
}
pub const fn new(_inner: u64) -> Self {
Self { inner: _inner }
}
}
impl Deref for TimeSpan {
type Target = u64;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for TimeSpan {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
pub type RuntimeMemoryLength = u32;
pub type GasAmount = u64;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct Ed25519Signature {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 64],
}
impl From<[u8; 64]> for Ed25519Signature {
fn from(_inner: [u8; 64]) -> Self {
Self { inner: _inner }
}
}
impl Ed25519Signature {
pub fn into_inner(self) -> [u8; 64] {
self.inner
}
pub const fn new(_inner: [u8; 64]) -> Self {
Self { inner: _inner }
}
}
impl Deref for Ed25519Signature {
type Target = [u8; 64];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for Ed25519Signature {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for Ed25519Signature {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 64]> for &'a Ed25519Signature {
fn from(arr: &[u8; 64]) -> Self {
let ptr = arr as *const [u8; 64] as *const Ed25519Signature;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a Ed25519Signature {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 64] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for Ed25519Signature {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"Ed25519Signature".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 128, "maxLength" : 128 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct Ristretto255Point {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for Ristretto255Point {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Ristretto255Point {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for Ristretto255Point {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for Ristretto255Point {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for Ristretto255Point {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a Ristretto255Point {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const Ristretto255Point;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a Ristretto255Point {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for Ristretto255Point {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"Ristretto255Point".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct U256Le {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for U256Le {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl U256Le {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for U256Le {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for U256Le {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for U256Le {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a U256Le {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const U256Le;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a U256Le {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for U256Le {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"U256Le".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct Ed25519PublicKey {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for Ed25519PublicKey {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Ed25519PublicKey {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for Ed25519PublicKey {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for Ed25519PublicKey {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for Ed25519PublicKey {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a Ed25519PublicKey {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const Ed25519PublicKey;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a Ed25519PublicKey {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for Ed25519PublicKey {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"Ed25519PublicKey".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct Ed25519SecretKey {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 64],
}
impl From<[u8; 64]> for Ed25519SecretKey {
fn from(_inner: [u8; 64]) -> Self {
Self { inner: _inner }
}
}
impl Ed25519SecretKey {
pub fn into_inner(self) -> [u8; 64] {
self.inner
}
pub const fn new(_inner: [u8; 64]) -> Self {
Self { inner: _inner }
}
}
impl Deref for Ed25519SecretKey {
type Target = [u8; 64];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for Ed25519SecretKey {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for Ed25519SecretKey {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 64]> for &'a Ed25519SecretKey {
fn from(arr: &[u8; 64]) -> Self {
let ptr = arr as *const [u8; 64] as *const Ed25519SecretKey;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a Ed25519SecretKey {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 64] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for Ed25519SecretKey {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"Ed25519SecretKey".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 128, "maxLength" : 128 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct MlDsa65Signature {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 3309],
}
impl From<[u8; 3309]> for MlDsa65Signature {
fn from(_inner: [u8; 3309]) -> Self {
Self { inner: _inner }
}
}
impl MlDsa65Signature {
pub fn into_inner(self) -> [u8; 3309] {
self.inner
}
pub const fn new(_inner: [u8; 3309]) -> Self {
Self { inner: _inner }
}
}
impl Deref for MlDsa65Signature {
type Target = [u8; 3309];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for MlDsa65Signature {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for MlDsa65Signature {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 3309]> for &'a MlDsa65Signature {
fn from(arr: &[u8; 3309]) -> Self {
let ptr = arr as *const [u8; 3309] as *const MlDsa65Signature;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a MlDsa65Signature {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 3309] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for MlDsa65Signature {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"MlDsa65Signature".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 6618, "maxLength" : 6618 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct MlDsa65PublicKey {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 1952],
}
impl From<[u8; 1952]> for MlDsa65PublicKey {
fn from(_inner: [u8; 1952]) -> Self {
Self { inner: _inner }
}
}
impl MlDsa65PublicKey {
pub fn into_inner(self) -> [u8; 1952] {
self.inner
}
pub const fn new(_inner: [u8; 1952]) -> Self {
Self { inner: _inner }
}
}
impl Deref for MlDsa65PublicKey {
type Target = [u8; 1952];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for MlDsa65PublicKey {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for MlDsa65PublicKey {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 1952]> for &'a MlDsa65PublicKey {
fn from(arr: &[u8; 1952]) -> Self {
let ptr = arr as *const [u8; 1952] as *const MlDsa65PublicKey;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a MlDsa65PublicKey {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 1952] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for MlDsa65PublicKey {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"MlDsa65PublicKey".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 3904, "maxLength" : 3904 }
)
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct MlDsa65SecretKey {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 4032],
}
impl From<[u8; 4032]> for MlDsa65SecretKey {
fn from(_inner: [u8; 4032]) -> Self {
Self { inner: _inner }
}
}
impl MlDsa65SecretKey {
pub fn into_inner(self) -> [u8; 4032] {
self.inner
}
pub const fn new(_inner: [u8; 4032]) -> Self {
Self { inner: _inner }
}
}
impl Deref for MlDsa65SecretKey {
type Target = [u8; 4032];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for MlDsa65SecretKey {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for MlDsa65SecretKey {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 4032]> for &'a MlDsa65SecretKey {
fn from(arr: &[u8; 4032]) -> Self {
let ptr = arr as *const [u8; 4032] as *const MlDsa65SecretKey;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a MlDsa65SecretKey {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 4032] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for MlDsa65SecretKey {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"MlDsa65SecretKey".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 8064, "maxLength" : 8064 }
)
}
}
#[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 CryptographicScheme(pub i32);
impl CryptographicScheme {
pub const Ed25519: Self = Self(0);
pub const MlDsa65: Self = Self(1);
}
impl From<i32> for CryptographicScheme {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "xdrs")]
impl xdrs::XDRDiscriminant for CryptographicScheme {
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 CryptographicScheme {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::Ed25519.0 => f.write_str("CryptographicScheme::Ed25519"),
x if x == Self::MlDsa65.0 => f.write_str("CryptographicScheme::MlDsa65"),
_ => write!(f, "CryptographicScheme({})", self.0),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "xdrs", xdr(discriminant = "CryptographicScheme"))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[repr(i32)]
#[non_exhaustive]
pub enum Signature {
Ed25519 { ed25519: Ed25519Signature } = CryptographicScheme::Ed25519.0 as i32,
MlDsa65 { mldsa65: Box<MlDsa65Signature> } = CryptographicScheme::MlDsa65.0 as i32,
}
impl Signature {
#[allow(clippy::match_single_binding)]
pub fn scheme(&self) -> CryptographicScheme {
match self {
Signature::Ed25519 { .. } => CryptographicScheme::Ed25519,
Signature::MlDsa65 { .. } => CryptographicScheme::MlDsa65,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "xdrs", xdr(discriminant = "CryptographicScheme"))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[repr(i32)]
#[non_exhaustive]
pub enum PublicKey {
Ed25519 { ed25519: Ed25519PublicKey } = CryptographicScheme::Ed25519.0 as i32,
MlDsa65 { mldsa65: Box<MlDsa65PublicKey> } = CryptographicScheme::MlDsa65.0 as i32,
}
impl PublicKey {
#[allow(clippy::match_single_binding)]
pub fn scheme(&self) -> CryptographicScheme {
match self {
PublicKey::Ed25519 { .. } => CryptographicScheme::Ed25519,
PublicKey::MlDsa65 { .. } => CryptographicScheme::MlDsa65,
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct PublicKeyHash {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for PublicKeyHash {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl PublicKeyHash {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for PublicKeyHash {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for PublicKeyHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for PublicKeyHash {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a PublicKeyHash {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const PublicKeyHash;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a PublicKeyHash {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for PublicKeyHash {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"PublicKeyHash".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "xdrs", xdr(discriminant = "CryptographicScheme"))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[repr(i32)]
#[non_exhaustive]
pub enum SecretKey {
Ed25519 { ed25519: Ed25519SecretKey } = CryptographicScheme::Ed25519.0 as i32,
MlDsa65 { mldsa65: Box<MlDsa65SecretKey> } = CryptographicScheme::MlDsa65.0 as i32,
}
impl SecretKey {
#[allow(clippy::match_single_binding)]
pub fn scheme(&self) -> CryptographicScheme {
match self {
SecretKey::Ed25519 { .. } => CryptographicScheme::Ed25519,
SecretKey::MlDsa65 { .. } => CryptographicScheme::MlDsa65,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstWriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "xdrs", xdr(discriminant = "i32"))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[repr(i32)]
#[non_exhaustive]
pub enum ExtensionPoint {
_0 = 0 as i32,
}
impl ExtensionPoint {
#[allow(clippy::match_single_binding)]
pub fn v(&self) -> i32 {
match self {
ExtensionPoint::_0 => 0 as i32,
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct SHA256Hash {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for SHA256Hash {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl SHA256Hash {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for SHA256Hash {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for SHA256Hash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for SHA256Hash {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a SHA256Hash {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const SHA256Hash;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a SHA256Hash {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for SHA256Hash {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"SHA256Hash".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct ConsensusValueHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for ConsensusValueHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl ConsensusValueHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for ConsensusValueHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for ConsensusValueHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct NetworkHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for NetworkHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl NetworkHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for NetworkHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for NetworkHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct ConfigHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for ConfigHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl ConfigHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for ConfigHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for ConfigHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct StorageLongHash {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 2048],
}
impl From<[u8; 2048]> for StorageLongHash {
fn from(_inner: [u8; 2048]) -> Self {
Self { inner: _inner }
}
}
impl StorageLongHash {
pub fn into_inner(self) -> [u8; 2048] {
self.inner
}
pub const fn new(_inner: [u8; 2048]) -> Self {
Self { inner: _inner }
}
}
impl Deref for StorageLongHash {
type Target = [u8; 2048];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for StorageLongHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for StorageLongHash {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 2048]> for &'a StorageLongHash {
fn from(arr: &[u8; 2048]) -> Self {
let ptr = arr as *const [u8; 2048] as *const StorageLongHash;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a StorageLongHash {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 2048] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for StorageLongHash {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"StorageLongHash".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 4096, "maxLength" : 4096 }
)
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct StorageShortHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for StorageShortHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl StorageShortHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for StorageShortHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for StorageShortHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct TxsHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for TxsHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl TxsHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for TxsHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for TxsHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct EventsHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for EventsHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl EventsHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for EventsHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for EventsHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct ProposalHeaderHash {
inner: SHA256Hash,
}
impl From<SHA256Hash> for ProposalHeaderHash {
fn from(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl ProposalHeaderHash {
pub fn into_inner(self) -> SHA256Hash {
self.inner
}
pub const fn new(_inner: SHA256Hash) -> Self {
Self { inner: _inner }
}
}
impl Deref for ProposalHeaderHash {
type Target = SHA256Hash;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for ProposalHeaderHash {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct ContractAddress {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for ContractAddress {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl ContractAddress {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for ContractAddress {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for ContractAddress {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for ContractAddress {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a ContractAddress {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const ContractAddress;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a ContractAddress {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for ContractAddress {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"ContractAddress".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[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 StorageKeyType(pub i32);
impl StorageKeyType {
pub const ContractData: Self = Self(0);
pub const FreeNativeTokenBalance: Self = Self(1);
pub const AuthData: Self = Self(2);
pub const Metadata: Self = Self(3);
pub const ReplayCache: Self = Self(4);
}
impl From<i32> for StorageKeyType {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "xdrs")]
impl xdrs::XDRDiscriminant for StorageKeyType {
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 StorageKeyType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::ContractData.0 => f.write_str("StorageKeyType::ContractData"),
x if x == Self::FreeNativeTokenBalance.0 => {
f.write_str("StorageKeyType::FreeNativeTokenBalance")
}
x if x == Self::AuthData.0 => f.write_str("StorageKeyType::AuthData"),
x if x == Self::Metadata.0 => f.write_str("StorageKeyType::Metadata"),
x if x == Self::ReplayCache.0 => f.write_str("StorageKeyType::ReplayCache"),
_ => write!(f, "StorageKeyType({})", self.0),
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Copy)]
#[repr(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct StorageKeyContractData {
#[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
inner: [u8; 32],
}
impl From<[u8; 32]> for StorageKeyContractData {
fn from(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl StorageKeyContractData {
pub fn into_inner(self) -> [u8; 32] {
self.inner
}
pub const fn new(_inner: [u8; 32]) -> Self {
Self { inner: _inner }
}
}
impl Deref for StorageKeyContractData {
type Target = [u8; 32];
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for StorageKeyContractData {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<[u8]> for StorageKeyContractData {
fn as_ref(&self) -> &[u8] {
self.deref().as_slice()
}
}
impl<'a> From<&'a [u8; 32]> for &'a StorageKeyContractData {
fn from(arr: &[u8; 32]) -> Self {
let ptr = arr as *const [u8; 32] as *const StorageKeyContractData;
unsafe { &*ptr }
}
}
#[cfg(feature = "xdrs")]
impl<'r: 'a, 'a> ReadXDR<'r> for &'a StorageKeyContractData {
fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
let arr: &[u8; 32] = xdrs::read_xdr(r)?;
Ok(Self::from(arr))
}
}
#[cfg(feature = "schema")]
impl schemars::JsonSchema for StorageKeyContractData {
fn schema_name() -> ::std::borrow::Cow<'static, str> {
"StorageKeyContractData".into()
}
fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
schemars::json_schema!(
{ "type" : "string", "contentEncoding" : "hex", "contentMediaType" :
"application/binary", "minLength" : 64, "maxLength" : 64 }
)
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
#[cfg_attr(feature = "xdrs", xdr(discriminant = "StorageKeyType"))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[repr(i32)]
#[non_exhaustive]
pub enum StorageKey {
ContractData {
contract_data_key: StorageKeyContractData,
} = StorageKeyType::ContractData.0 as i32,
FreeNativeTokenBalance = StorageKeyType::FreeNativeTokenBalance.0 as i32,
AuthData = StorageKeyType::AuthData.0 as i32,
Metadata = StorageKeyType::Metadata.0 as i32,
ReplayCache = StorageKeyType::ReplayCache.0 as i32,
}
impl StorageKey {
#[allow(clippy::match_single_binding)]
pub fn key_type(&self) -> StorageKeyType {
match self {
StorageKey::ContractData { .. } => StorageKeyType::ContractData,
StorageKey::FreeNativeTokenBalance => StorageKeyType::FreeNativeTokenBalance,
StorageKey::AuthData => StorageKeyType::AuthData,
StorageKey::Metadata => StorageKeyType::Metadata,
StorageKey::ReplayCache => StorageKeyType::ReplayCache,
}
}
}
pub const kNativeTokenDivisibility: u32 = 10_000_000;
#[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 AddressAndKey {
pub address: ContractAddress,
pub key: StorageKey,
}
#[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(transparent)]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct BlockHeight {
inner: i64,
}
impl From<i64> for BlockHeight {
fn from(_inner: i64) -> Self {
Self { inner: _inner }
}
}
impl BlockHeight {
pub fn into_inner(self) -> i64 {
self.inner
}
pub const fn new(_inner: i64) -> Self {
Self { inner: _inner }
}
}
impl Deref for BlockHeight {
type Target = i64;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl DerefMut for BlockHeight {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}