#![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};
use xdrs::*;
#[cfg(feature = "serde")]
use ::serde::{Deserialize, Serialize};
pub type OperatorHash = [u8; 32];
pub type OperatorShortText = StringM<32>;
pub type OperatorText = StringM<64>;
pub type OperatorDetail = StringM<256>;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
pub struct OperatorReadiness(pub i32);
impl OperatorReadiness {
pub const OPERATOR_STARTING: Self = Self(0);
pub const OPERATOR_READY: Self = Self(1);
pub const OPERATOR_NOT_READY: Self = Self(2);
}
impl From<i32> for OperatorReadiness {
fn from(v: i32) -> Self {
Self(v)
}
}
impl xdrs::XDRDiscriminant for OperatorReadiness {
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 OperatorReadiness {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::OPERATOR_STARTING.0 => {
f.write_str("OperatorReadiness::OPERATOR_STARTING")
}
x if x == Self::OPERATOR_READY.0 => {
f.write_str("OperatorReadiness::OPERATOR_READY")
}
x if x == Self::OPERATOR_NOT_READY.0 => {
f.write_str("OperatorReadiness::OPERATOR_NOT_READY")
}
_ => write!(f, "OperatorReadiness({})", self.0),
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct OperatorPosition {
pub name: OperatorText,
pub height: i64,
pub block_hash: Option<OperatorHash>,
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct OperatorStatus {
pub role: OperatorShortText,
pub process_name: OperatorText,
pub build_version: OperatorText,
pub build_commit: OperatorText,
pub protocol_token: OperatorShortText,
pub network_hash: Option<OperatorHash>,
pub readiness: OperatorReadiness,
pub readiness_detail: OperatorDetail,
pub positions: VecM<OperatorPosition, 64>,
}
#[allow(non_camel_case_types)]
pub trait Operator_Operator1: Send + Sync {
fn operator_null(
&self,
) -> impl ::core::future::Future<
Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>,
> + Send;
fn operator_status(
&self,
) -> impl ::core::future::Future<
Output = Result<
impl xdrs::EncodesAs<OperatorStatus>,
::thruput_rpc_api::ProgramError,
>,
> + Send;
}
#[allow(non_camel_case_types)]
pub struct Operator_Operator1_Dispatcher<__Handler> {
inner: Box<__Handler>,
}
impl<__Handler: Operator_Operator1> Operator_Operator1_Dispatcher<__Handler> {
pub fn new(inner: Box<__Handler>) -> Self {
Self { inner }
}
}
#[async_trait::async_trait]
impl<__Handler: Operator_Operator1> ::thruput_rpc_api::RpcHandler
for Operator_Operator1_Dispatcher<__Handler> {
fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
::thruput_rpc_api::ProgVers::new(0x20000000, 1)
}
async fn dispatch(
&self,
proc: u32,
data: &[u8],
) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
match proc {
0 => {
let args: () = xdrs::txs::decode(data)
.map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self
.inner
.operator_null()
.await
.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res)
.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
1 => {
let args: () = xdrs::txs::decode(data)
.map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self
.inner
.operator_status()
.await
.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res)
.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
_ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
}
}
}
#[derive(Clone)]
pub struct Operator_Operator1_Client {
handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
}
impl Operator_Operator1_Client {
pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
Self { handle }
}
fn prog_vers() -> ::thruput_rpc_api::ProgVers {
::thruput_rpc_api::ProgVers::new(0x20000000, 1)
}
pub async fn operator_null(&self) -> Result<(), ::thruput_rpc_api::RpcError> {
let mut call = self.handle.call_buf();
call.append_with(|buf| {
let mut w = xdrs::txs::buf_writer::BufWriter::from(
::core::mem::take(buf),
);
let r = xdrs::write_xdr(&(), &mut w);
*buf = w.into();
r
})
.map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let mut out = ::core::option::Option::None;
let mut decode = |
reply: &[u8],
| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
out = ::core::option::Option::Some(
xdrs::txs::decode(reply)
.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?,
);
Ok(())
};
unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }
.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
pub async fn operator_status(
&self,
) -> Result<OperatorStatus, ::thruput_rpc_api::RpcError> {
let mut call = self.handle.call_buf();
call.append_with(|buf| {
let mut w = xdrs::txs::buf_writer::BufWriter::from(
::core::mem::take(buf),
);
let r = xdrs::write_xdr(&(), &mut w);
*buf = w.into();
r
})
.map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let mut out = ::core::option::Option::None;
let mut decode = |
reply: &[u8],
| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
out = ::core::option::Option::Some(
xdrs::txs::decode(reply)
.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?,
);
Ok(())
};
unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }
.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
}
impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>>
for Operator_Operator1_Client {
fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
Self::new(handle)
}
}