Skip to main content

thruput_node_rpc/
coord_sched.rs

1// -*-Rust-*-
2// Generated Code: DO NOT CHECK IN
3
4// Generated from xdrc commit: 0b59180aed1fefa0f2629444e1673213e6738189
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
29/// Each handler replies with anything that encodes like the reply type.
30/// Implementations can be plain `async fn`s returning a concrete reply type
31/// under `#[allow(refining_impl_trait)]`.
32#[allow(non_camel_case_types)]
33pub trait CoordScheduler_CoordScheduler1: Send + Sync {    
34    fn coordscheduler_null(&self) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
35        // The scheduler calls coordscheduler_notify_vetted to indicate that the
36    // given transactions are vetted, meaning the coordinator can broadcast
37    // them to the network.
38
39    fn coordscheduler_notify_vetted(&self, arg0 : ParallelSignedTransactionBatch) -> impl ::core::future::Future<Output = Result<impl xdrs::EncodesAs<()>, ::thruput_rpc_api::ProgramError>> + Send;
40}
41
42
43#[allow(non_camel_case_types)]
44pub struct CoordScheduler_CoordScheduler1_Dispatcher<__Handler> {
45  inner: Box<__Handler>,
46}
47
48impl<__Handler: CoordScheduler_CoordScheduler1> CoordScheduler_CoordScheduler1_Dispatcher<__Handler> {
49  pub fn new(inner: Box<__Handler>) -> Self {
50    Self { inner }
51  }
52}
53
54#[async_trait::async_trait]
55impl<__Handler: CoordScheduler_CoordScheduler1> ::thruput_rpc_api::RpcHandler for CoordScheduler_CoordScheduler1_Dispatcher<__Handler> {
56    fn prog_vers(&self) -> ::thruput_rpc_api::ProgVers {
57        ::thruput_rpc_api::ProgVers::new(0x11117667, 1)
58    }
59    async fn dispatch(&self, proc: u32, data: &[u8]) -> Result<Vec<u8>, ::thruput_rpc_api::RpcError> {
60        match proc {
61            // coordscheduler_null
62            0 => {
63                let args: () =
64                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
65                let res = self.inner.coordscheduler_null().await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
66                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
67            }
68            // coordscheduler_notify_vetted
69            1 => {
70                let args: (ParallelSignedTransactionBatch, ) =
71                    xdrs::txs::decode(data).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
72                let res = self.inner.coordscheduler_notify_vetted(args.0).await.map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?;
73                xdrs::txs::encode(&res).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)
74            }
75            _ => Err(::thruput_rpc_api::RpcError::InvalidProcedure),
76        }
77    }
78}
79
80#[derive(Clone)]
81pub struct CoordScheduler_CoordScheduler1_Client {
82    handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>,
83}
84
85impl CoordScheduler_CoordScheduler1_Client {
86    pub fn new(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
87        Self { handle }
88    }
89
90    fn prog_vers() -> ::thruput_rpc_api::ProgVers {
91        ::thruput_rpc_api::ProgVers::new(0x11117667, 1)
92    }
93    pub async fn coordscheduler_null(&self) -> Result<(), ::thruput_rpc_api::RpcError> {
94         let mut call = self.handle.call_buf();
95         call.append_with(|buf| {
96             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
97             let r = xdrs::write_xdr(&(), &mut w);
98             *buf = w.into();
99             r
100         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
101         let mut out = ::core::option::Option::None;
102         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
103             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
104             Ok(())
105         };
106         // SAFETY: the call future is awaited right here, so it lives in
107         // this method's future along with `out` and `decode`. Once that
108         // is polled it is pinned, so neither can be freed without the
109         // call future being dropped first. Decoding never blocks.
110         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 0, call, &mut decode) }.await?;
111         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
112    }
113    pub async fn coordscheduler_notify_vetted(&self, arg0 : &(impl xdrs::EncodesAs<ParallelSignedTransactionBatch> + ?Sized)) -> Result<(), ::thruput_rpc_api::RpcError> {
114         let mut call = self.handle.call_buf();
115         call.append_with(|buf| {
116             let mut w = xdrs::txs::buf_writer::BufWriter::from(::core::mem::take(buf));
117             let r = xdrs::write_xdr(&(arg0), &mut w);
118             *buf = w.into();
119             r
120         }).map_err(|_| ::thruput_rpc_api::RpcError::GarbageArguments)?;
121         let mut out = ::core::option::Option::None;
122         let mut decode = |reply: &[u8]| -> ::core::result::Result<(), ::thruput_rpc_api::RpcError> {
123             out = ::core::option::Option::Some(xdrs::txs::decode(reply).map_err(|_| ::thruput_rpc_api::RpcError::SystemError)?);
124             Ok(())
125         };
126         // SAFETY: the call future is awaited right here, so it lives in
127         // this method's future along with `out` and `decode`. Once that
128         // is polled it is pinned, so neither can be freed without the
129         // call future being dropped first. Decoding never blocks.
130         unsafe { self.handle.send_call_decoded(Self::prog_vers(), 1, call, &mut decode) }.await?;
131         out.ok_or(::thruput_rpc_api::RpcError::SystemError)
132    }
133}
134
135impl From<::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>> for CoordScheduler_CoordScheduler1_Client {
136    fn from(handle: ::std::sync::Arc<dyn ::thruput_rpc_api::RpcSender>) -> Self {
137        Self::new(handle)
138    }
139}
140
141
142
143//
144// XDR internals below this point
145//
146
147