#![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::option::Option;
use core::ops::{Deref, DerefMut};
#[cfg(feature = "std")]
use std::io::{Read, Write};
use xdrs::*;
#[cfg(feature = "serde")]
use ::serde::{{Serialize, Deserialize}};
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
pub struct SchedGatewayIntroOutcome(pub i32);
impl SchedGatewayIntroOutcome {
pub const SchedGatewayIntroSuccess: Self = Self(0);
pub const SchedGatewayIntroMismatchedProtocol: Self = Self(1);
}
impl From<i32> for SchedGatewayIntroOutcome {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for SchedGatewayIntroOutcome {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::SchedGatewayIntroSuccess.0 => {
write!(f, "SchedGatewayIntroOutcome::SchedGatewayIntroSuccess")
},
x if x == Self::SchedGatewayIntroMismatchedProtocol.0 => {
write!(f, "SchedGatewayIntroOutcome::SchedGatewayIntroMismatchedProtocol")
},
_ => {
write!(f, "SchedGatewayIntroOutcome({})", self.0)
}
}
}
}
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Copy)]
#[repr(transparent)]
pub struct SchedGatewaySubmitOutcome(pub i32);
impl SchedGatewaySubmitOutcome {
pub const SchedGatewaySubmitAdmitted: Self = Self(0);
pub const SchedGatewaySubmitAuthenticationRejected: Self = Self(1);
pub const SchedGatewaySubmitRetryable: Self = Self(2);
pub const SchedGatewaySubmitInternalError: Self = Self(3);
}
impl From<i32> for SchedGatewaySubmitOutcome {
fn from(v: i32) -> Self {
Self(v)
}
}
#[cfg(feature = "std")]
impl core::fmt::Display for SchedGatewaySubmitOutcome {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self.0 {
x if x == Self::SchedGatewaySubmitAdmitted.0 => {
write!(f, "SchedGatewaySubmitOutcome::SchedGatewaySubmitAdmitted")
},
x if x == Self::SchedGatewaySubmitAuthenticationRejected.0 => {
write!(f, "SchedGatewaySubmitOutcome::SchedGatewaySubmitAuthenticationRejected")
},
x if x == Self::SchedGatewaySubmitRetryable.0 => {
write!(f, "SchedGatewaySubmitOutcome::SchedGatewaySubmitRetryable")
},
x if x == Self::SchedGatewaySubmitInternalError.0 => {
write!(f, "SchedGatewaySubmitOutcome::SchedGatewaySubmitInternalError")
},
_ => {
write!(f, "SchedGatewaySubmitOutcome({})", self.0)
}
}
}
}
pub type SchedGatewaySubmitOutcomeBatch = VecM::<SchedGatewaySubmitOutcome>;
pub type PendingTxCount = i64;
#[allow(non_camel_case_types)]
pub trait SchedGateway_SchedGateway1: Send + Sync {
fn schedgateway_intro(&self, arg0 : ProtocolCommit) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<SchedGatewayIntroOutcome>, ::thruput_rpc_api::ProgramError>> + Send;
fn schedgateway_submit_tx_batch(&self, arg0 : ParallelSignedTransactionBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<SchedGatewaySubmitOutcomeBatch>, ::thruput_rpc_api::ProgramError>> + Send;
fn schedgateway_get_tip(&self) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<ExpectedDBTip>, ::thruput_rpc_api::ProgramError>> + Send;
fn schedgateway_lookup_tx(&self, arg0 : TransactionHashBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<OptSignedTransactionBatch>, ::thruput_rpc_api::ProgramError>> + Send;
fn schedgateway_pending_tx_count(&self) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<PendingTxCount>, ::thruput_rpc_api::ProgramError>> + Send;
fn schedgateway_lookup_transaction_outcomes(&self, arg0 : TransactionHashBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<SchedulerTransactionOutcomeBatch>, ::thruput_rpc_api::ProgramError>> + Send;
}
#[allow(non_camel_case_types)]
pub struct SchedGateway_SchedGateway1_Dispatcher<__Handler> {
inner: Box<__Handler>,
}
impl<__Handler: SchedGateway_SchedGateway1> SchedGateway_SchedGateway1_Dispatcher<__Handler> {
pub fn new(inner: Box<__Handler>) -> Self {
Self { inner }
}
}
#[async_trait::async_trait]
impl<__Handler: SchedGateway_SchedGateway1> ::thruput_rpc_api::RpcHandler for SchedGateway_SchedGateway1_Dispatcher<__Handler> {
fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
::thruput_rpc_api::ProgVers::new(0x7ee7aaaa, 1)
}
async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
match proc {
0 => {
let args: (ProtocolCommit, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.schedgateway_intro(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
1 => {
let args: (ParallelSignedTransactionBatch, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.schedgateway_submit_tx_batch(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
2 => {
let args: () =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.schedgateway_get_tip().await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
3 => {
let args: (TransactionHashBatch, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.schedgateway_lookup_tx(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
4 => {
let args: () =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.schedgateway_pending_tx_count().await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
5 => {
let args: (TransactionHashBatch, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.schedgateway_lookup_transaction_outcomes(args.0).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 SchedGateway_SchedGateway1_Client {
handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
}
impl SchedGateway_SchedGateway1_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(0x7ee7aaaa, 1)
}
pub async fn schedgateway_intro(&self, arg0 : &(impl xdrs::EncodesAs<ProtocolCommit> + ?Sized)) -> Result<SchedGatewayIntroOutcome, ::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(&(arg0), &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 schedgateway_submit_tx_batch(&self, arg0 : &(impl xdrs::EncodesAs<ParallelSignedTransactionBatch> + ?Sized)) -> Result<SchedGatewaySubmitOutcomeBatch, ::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(&(arg0), &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)
}
pub async fn schedgateway_get_tip(&self) -> Result<ExpectedDBTip, ::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(), 2, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
pub async fn schedgateway_lookup_tx(&self, arg0 : &(impl xdrs::EncodesAs<TransactionHashBatch> + ?Sized)) -> Result<OptSignedTransactionBatch, ::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(&(arg0), &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(), 3, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
pub async fn schedgateway_pending_tx_count(&self) -> Result<PendingTxCount, ::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(), 4, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
pub async fn schedgateway_lookup_transaction_outcomes(&self, arg0 : &(impl xdrs::EncodesAs<TransactionHashBatch> + ?Sized)) -> Result<SchedulerTransactionOutcomeBatch, ::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(&(arg0), &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(), 5, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
}
impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for SchedGateway_SchedGateway1_Client {
fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
Self::new(handle)
}
}