thruput_node_rpc/
sched_exec.rs1#![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};
20use xdrs::*;
21
22
23#[cfg(feature = "serde")]
24use ::serde::{{Serialize, Deserialize}};
25
26
27
28#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
32#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
33#[derive(schemars::JsonSchema)]
34#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35#[repr(C)]
36pub struct ExecCard {
37 pub protocol: ProtocolCommit,
38 pub upid: UPID,
39 pub address: ServerAddress,
40}
41
42#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
43#[derive(ReadXDR, WriteXDR, ConstXDRSize)]
44#[derive(schemars::JsonSchema)]
45#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46#[repr(C)]
47pub struct IntroExecResult {
48 pub exec_id: u64,
50 pub shards: VecM<ShardCard>,
52 pub event: EventCard,
54}
55
56
57#[allow(non_camel_case_types)]
61pub trait SchedExec_SchedExec1: Send + Sync { fn schedexec_intro_exec(&self, arg0 : ExecCard) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<IntroExecResult>, ::thruput_rpc_api::ProgramError>> + Send;
65}
66
67
68#[allow(non_camel_case_types)]
69pub struct SchedExec_SchedExec1_Dispatcher<__Handler> {
70 inner: Box<__Handler>,
71}
72
73impl<__Handler: SchedExec_SchedExec1> SchedExec_SchedExec1_Dispatcher<__Handler> {
74 pub fn new(inner: Box<__Handler>) -> Self {
75 Self { inner }
76 }
77}
78
79#[async_trait::async_trait]
80impl<__Handler: SchedExec_SchedExec1> ::thruput_rpc_api::RpcHandler for SchedExec_SchedExec1_Dispatcher<__Handler> {
81 fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
82 ::thruput_rpc_api::ProgVers::new(0x7ee79997, 1)
83 }
84 async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
85 match proc {
86 1 => {
88 let args: (ExecCard, ) =
89 xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
90 let res = self.inner.schedexec_intro_exec(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
91 xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
92 }
93 _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
94 }
95 }
96}
97
98#[derive(Clone)]
99pub struct SchedExec_SchedExec1_Client {
100 handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
101}
102
103impl SchedExec_SchedExec1_Client {
104 pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
105 Self { handle }
106 }
107
108 fn prog_vers() -> ::thruput_rpc_api::ProgVers {
109 ::thruput_rpc_api::ProgVers::new(0x7ee79997, 1)
110 }
111 pub async fn schedexec_intro_exec(&self, arg0 : &(impl xdrs::EncodesAs<ExecCard> + ?Sized)) -> Result<IntroExecResult, ::thruput_rpc_api::RpcError> {
112 let mut call = self.handle.call_buf();
113 call.append_with(|buf| {
114 let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
115 let r = xdrs::write_xdr(&(arg0), &mut w);
116 *buf = w.into();
117 r
118 }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
119 let mut out = ::core::option::Option::None;
120 let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
121 out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
122 Ok(())
123 };
124 unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }.await?;
129 out.ok_or(::thruput_rpc_api::RpcError::SystemError)
130 }
131}
132
133impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for SchedExec_SchedExec1_Client {
134 fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
135 Self::new(handle)
136 }
137}
138
139
140
141