Skip to main content

thruput_node_rpc/
sched_exec.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 6ab835b07c234abb4b0b50b61d687904727a4f32
5
6#![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// clang-format on
29
30// Uniquely describes an executor instance.
31#[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    // A unique 16-bit identifier assigned to the executor by the system.
49    pub exec_id: u64,
50    // The database shards.
51    pub shards: VecM<ShardCard>,
52    // The event server
53    pub event: EventCard,
54}
55
56
57/// Each handler replies with anything that encodes like the reply type.
58/// Implementations can be plain `async fn`s returning a concrete reply type
59/// under `#[allow(refining_impl_trait)]`.
60#[allow(non_camel_case_types)]
61pub trait SchedExec_SchedExec1: Send + Sync {        // [schedexec_intro_exec] is called by an executor to introduce itself to
62    // the system.
63
64    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            // schedexec_intro_exec
87            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         // SAFETY: the call future is awaited right here, so it lives in
125         // this method's future along with `out` and `decode`. Once that
126         // is polled it is pinned, so neither can be freed without the
127         // call future being dropped first. Decoding never blocks.
128         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//
142// XDR internals below this point
143//
144
145