Skip to main content

thruput_xdr/
validator.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 6ab835b07c234abb4b0b50b61d687904727a4f32
5
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#![allow(non_upper_case_globals)]
9#![allow(unused_imports)]
10#![allow(dead_code)]
11#![allow(unused_variables)]
12#![allow(clippy::unnecessary_cast)]
13
14use crate::*;
15use core::option::Option;
16use core::ops::{Deref, DerefMut};
17
18#[cfg(feature = "std")]
19use std::io::{Read, Write};
20#[cfg(feature = "xdrs")]
21use xdrs::*;
22
23
24#[cfg(feature = "serde")]
25use ::serde::{{Serialize, Deserialize}};
26
27
28
29// 
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
32#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
33#[derive(Default, Copy)]
34#[repr(transparent)]
35#[cfg_attr(feature = "serde", serde(transparent))]
36pub struct ValidatorID {
37    #[cfg_attr(feature = "serde", serde(with = "xdr_common::serde_hex"))]
38    inner: [u8; 32 as usize],
39}
40impl From<[u8; 32 as usize]> for ValidatorID {
41    fn from(_inner: [u8; 32 as usize]) -> Self {
42        Self { inner: _inner }
43    }
44}
45impl ValidatorID {
46    pub fn into_inner(self) -> [u8; 32 as usize] {
47        self.inner
48    }
49    pub const fn new(_inner: [u8; 32 as usize]) -> Self {
50        Self { inner: _inner }
51    }
52}
53
54impl Deref for ValidatorID {
55    type Target = [u8; 32 as usize];
56
57    fn deref(&self) -> &Self::Target {
58        &self.inner
59    }
60}
61impl DerefMut for ValidatorID {
62    fn deref_mut(&mut self) -> &mut Self::Target {
63        &mut self.inner
64    }
65}
66impl AsRef<[u8]> for ValidatorID {
67    fn as_ref(&self) -> &[u8] {
68        self.deref().as_slice()
69    }
70}
71impl<'a> From<&'a [u8; 32]> for &'a ValidatorID {
72    fn from(arr: &[u8; 32]) -> Self {
73        let ptr = arr as *const [u8; 32] as *const ValidatorID;
74        unsafe { &*ptr }
75    }
76}
77#[cfg(feature = "xdrs")]
78impl<'r: 'a, 'a> ReadXDR<'r> for &'a ValidatorID {
79  fn read_xdr<R: xdrs::Reader<'r>>(r: &mut R) -> xdrs::ReadResult<Self> {
80      let arr: &[u8; 32] = xdrs::read_xdr(r)?;
81      let val = Self::from(arr);
82      Ok(val)
83  }
84}
85
86#[cfg(feature = "schema")]
87impl schemars::JsonSchema for ValidatorID {
88    fn schema_name() -> ::std::borrow::Cow<'static, str> {
89        "ValidatorID".into()
90    }
91    fn json_schema(_gen: &mut schemars::SchemaGenerator) -> schemars::Schema {
92        schemars::json_schema!({
93            "type": "string",
94            "contentEncoding": "hex",
95            "contentMediaType": "application/binary",
96            "minLength": 64,
97            "maxLength": 64
98        })
99    }
100}
101
102
103
104pub type ValidatorPublicKey = PublicKey;
105
106pub type ValidatorSecretKey = SecretKey;
107
108#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
109#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
110#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
111#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
112#[repr(C)]
113pub struct ValidatorPublicInfo {
114    pub public_key: ValidatorPublicKey,
115    pub address: ServerAddress,
116}
117
118#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
119#[cfg_attr(feature = "xdrs", derive(ReadXDR, WriteXDR, ConstXDRSize))]
120#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
121#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
122#[repr(C)]
123pub struct ValidatorPrivateInfo {
124    pub public_info: ValidatorPublicInfo,
125    pub secret_key: ValidatorSecretKey,
126}
127
128
129//
130// XDR internals below this point
131//
132
133