#![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))]
#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
#[derive(schemars::JsonSchema)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct ShardCard {
pub protocol: ProtocolCommit,
pub upid: UPID,
pub block_height: BlockHeight,
pub address_for_exec: ServerAddress,
pub address_for_sched: ServerAddress,
pub address_for_auth: ServerAddress,
}
#[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 Delta {
pub address: ContractAddress,
pub native_token_delta: int128_xdr,
}
#[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 NativeTokensTransferredChunk {
pub block: BlockHeight,
pub chunk_index: u32,
pub chunk_count: u32,
pub deltas: VecM<Delta>,
}
#[allow(non_camel_case_types)]
pub trait SchedDb_SchedDb1: Send + Sync {
fn scheddb_intro_shard(&self, arg0 : ShardCard) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
fn scheddb_native_tokens_transferred_chunk(&self, arg0 : NativeTokensTransferredChunk) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
}
#[allow(non_camel_case_types)]
pub struct SchedDb_SchedDb1_Dispatcher<__Handler> {
inner: Box<__Handler>,
}
impl<__Handler: SchedDb_SchedDb1> SchedDb_SchedDb1_Dispatcher<__Handler> {
pub fn new(inner: Box<__Handler>) -> Self {
Self { inner }
}
}
#[async_trait::async_trait]
impl<__Handler: SchedDb_SchedDb1> ::thruput_rpc_api::RpcHandler for SchedDb_SchedDb1_Dispatcher<__Handler> {
fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
::thruput_rpc_api::ProgVers::new(0x7ee79998, 1)
}
async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
match proc {
1 => {
let args: (ShardCard, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.scheddb_intro_shard(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
}
4 => {
let args: (NativeTokensTransferredChunk, ) =
xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
let res = self.inner.scheddb_native_tokens_transferred_chunk(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 SchedDb_SchedDb1_Client {
handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
}
impl SchedDb_SchedDb1_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(0x7ee79998, 1)
}
pub async fn scheddb_intro_shard(&self, arg0 : &(impl xdrs::EncodesAs<ShardCard> + ?Sized)) -> 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(&(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 scheddb_native_tokens_transferred_chunk(&self, arg0 : &(impl xdrs::EncodesAs<NativeTokensTransferredChunk> + ?Sized)) -> 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(&(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(), 4, call, &mut decode) }.await?;
out.ok_or(::thruput_rpc_api::RpcError::SystemError)
}
}
impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for SchedDb_SchedDb1_Client {
fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
Self::new(handle)
}
}