1#![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)]
13use crate::*;
14use core::ops::{Deref, DerefMut};
15use core::option::Option;
16#[cfg(feature = "std")]
17use std::io::{Read, Write};
18use xdrs::*;
19#[cfg(feature = "serde")]
20use ::serde::{Deserialize, Serialize};
21
22pub type OperatorHash = [u8; 32];
24
25pub type OperatorShortText = StringM<32>;
26
27pub type OperatorText = StringM<64>;
28
29pub type OperatorDetail = StringM<256>;
30
31#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
34#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
35#[cfg_attr(feature = "serde", serde(transparent))]
36#[derive(schemars::JsonSchema)]
37#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38#[derive(Copy)]
39#[repr(transparent)]
40pub struct OperatorReadiness(pub i32);
41
42impl OperatorReadiness {
43 pub const OPERATOR_STARTING: Self = Self(0);
45 pub const OPERATOR_READY: Self = Self(1);
46 pub const OPERATOR_NOT_READY: Self = Self(2);
48}
49
50impl From<i32> for OperatorReadiness {
51 fn from(v: i32) -> Self {
52 Self(v)
53 }
54}
55
56impl xdrs::XDRDiscriminant for OperatorReadiness {
57 const ENCODING: xdrs::DiscriminantEncoding = xdrs::DiscriminantEncoding::Signed;
58 fn discriminant(&self) -> i32 {
59 self.0
60 }
61 fn from_discriminant(d: i32) -> Self {
62 Self(d)
63 }
64}
65
66#[cfg(feature = "std")]
67impl core::fmt::Display for OperatorReadiness {
68 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69 match self.0 {
70 x if x == Self::OPERATOR_STARTING.0 => {
71 f.write_str("OperatorReadiness::OPERATOR_STARTING")
72 }
73 x if x == Self::OPERATOR_READY.0 => {
74 f.write_str("OperatorReadiness::OPERATOR_READY")
75 }
76 x if x == Self::OPERATOR_NOT_READY.0 => {
77 f.write_str("OperatorReadiness::OPERATOR_NOT_READY")
78 }
79 _ => write!(f, "OperatorReadiness({})", self.0),
80 }
81 }
82}
83
84#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
93#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
94#[derive(schemars::JsonSchema)]
95#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
96#[repr(C)]
97pub struct OperatorPosition {
98 pub name: OperatorText,
99 pub height: i64,
104 pub block_hash: Option<OperatorHash>,
105}
106
107#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
108#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
109#[derive(schemars::JsonSchema)]
110#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
111#[repr(C)]
112pub struct OperatorStatus {
113 pub role: OperatorShortText,
117 pub process_name: OperatorText,
119 pub build_version: OperatorText,
121 pub build_commit: OperatorText,
123 pub protocol_token: OperatorShortText,
125 pub network_hash: Option<OperatorHash>,
127 pub readiness: OperatorReadiness,
128 pub readiness_detail: OperatorDetail,
129 pub positions: VecM<OperatorPosition, 64>,
130}
131
132#[allow(non_camel_case_types)]
136pub trait Operator_Operator1: Send + Sync {
137 fn operator_null(
138 &self,
139 ) -> impl ::core::future::Future<
140 Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>,
141 > + Send;
142 fn operator_status(
143 &self,
144 ) -> impl ::core::future::Future<
145 Output = Result<
146 impl xdrs::EncodesAs<OperatorStatus>,
147 ::thruput_rpc_api::ProgramError,
148 >,
149 > + Send;
150}
151
152#[allow(non_camel_case_types)]
153pub struct Operator_Operator1_Dispatcher<__Handler> {
154 inner: Box<__Handler>,
155}
156
157impl<__Handler: Operator_Operator1> Operator_Operator1_Dispatcher<__Handler> {
158 pub fn new(inner: Box<__Handler>) -> Self {
159 Self { inner }
160 }
161}
162
163#[async_trait::async_trait]
164impl<__Handler: Operator_Operator1> ::thruput_rpc_api::RpcHandler
165for Operator_Operator1_Dispatcher<__Handler> {
166 fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
167 ::thruput_rpc_api::ProgVers::new(0x20000000, 1)
168 }
169 async fn dispatch(
170 &self,
171 proc: u32,
172 data: &[u8],
173 ) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
174 match proc {
175 0 => {
177 let args: () = xdrs::txs::decode(data)
178 .map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
179 let res = self
180 .inner
181 .operator_null()
182 .await
183 .map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
184 xdrs::txs::encode(&res)
185 .map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
186 }
187 1 => {
189 let args: () = xdrs::txs::decode(data)
190 .map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
191 let res = self
192 .inner
193 .operator_status()
194 .await
195 .map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
196 xdrs::txs::encode(&res)
197 .map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
198 }
199 _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
200 }
201 }
202}
203
204#[derive(Clone)]
205pub struct Operator_Operator1_Client {
206 handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
207}
208
209impl Operator_Operator1_Client {
210 pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
211 Self { handle }
212 }
213 fn prog_vers() -> ::thruput_rpc_api::ProgVers {
214 ::thruput_rpc_api::ProgVers::new(0x20000000, 1)
215 }
216 pub async fn operator_null(&self) -> Result<(), ::thruput_rpc_api::RpcError> {
221 let mut call = self.handle.call_buf();
222 call.append_with(|buf| {
223 let mut w = xdrs::txs::buf_writer::BufWriter::from(
224 ::core::mem::take(buf),
225 );
226 let r = xdrs::write_xdr(&(), &mut w);
227 *buf = w.into();
228 r
229 })
230 .map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
231 let mut out = ::core::option::Option::None;
232 let mut decode = |
233 reply: &[u8],
234 | -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
235 out = ::core::option::Option::Some(
236 xdrs::txs::decode(reply)
237 .map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?,
238 );
239 Ok(())
240 };
241 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }
242 .await?;
243 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
244 }
245 pub async fn operator_status(
250 &self,
251 ) -> Result<OperatorStatus, ::thruput_rpc_api::RpcError> {
252 let mut call = self.handle.call_buf();
253 call.append_with(|buf| {
254 let mut w = xdrs::txs::buf_writer::BufWriter::from(
255 ::core::mem::take(buf),
256 );
257 let r = xdrs::write_xdr(&(), &mut w);
258 *buf = w.into();
259 r
260 })
261 .map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
262 let mut out = ::core::option::Option::None;
263 let mut decode = |
264 reply: &[u8],
265 | -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
266 out = ::core::option::Option::Some(
267 xdrs::txs::decode(reply)
268 .map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?,
269 );
270 Ok(())
271 };
272 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }
273 .await?;
274 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
275 }
276}
277
278impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>>
279for Operator_Operator1_Client {
280 fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
281 Self::new(handle)
282 }
283}