avalanche_types/proto/pb/
vm.runtime.tonic.rs

1// @generated
2/// Generated client implementations.
3pub mod runtime_client {
4    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
5    use tonic::codegen::*;
6    use tonic::codegen::http::Uri;
7    #[derive(Debug, Clone)]
8    pub struct RuntimeClient<T> {
9        inner: tonic::client::Grpc<T>,
10    }
11    impl RuntimeClient<tonic::transport::Channel> {
12        /// Attempt to create a new client by connecting to a given endpoint.
13        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14        where
15            D: TryInto<tonic::transport::Endpoint>,
16            D::Error: Into<StdError>,
17        {
18            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
19            Ok(Self::new(conn))
20        }
21    }
22    impl<T> RuntimeClient<T>
23    where
24        T: tonic::client::GrpcService<tonic::body::BoxBody>,
25        T::Error: Into<StdError>,
26        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
27        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
28    {
29        pub fn new(inner: T) -> Self {
30            let inner = tonic::client::Grpc::new(inner);
31            Self { inner }
32        }
33        pub fn with_origin(inner: T, origin: Uri) -> Self {
34            let inner = tonic::client::Grpc::with_origin(inner, origin);
35            Self { inner }
36        }
37        pub fn with_interceptor<F>(
38            inner: T,
39            interceptor: F,
40        ) -> RuntimeClient<InterceptedService<T, F>>
41        where
42            F: tonic::service::Interceptor,
43            T::ResponseBody: Default,
44            T: tonic::codegen::Service<
45                http::Request<tonic::body::BoxBody>,
46                Response = http::Response<
47                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
48                >,
49            >,
50            <T as tonic::codegen::Service<
51                http::Request<tonic::body::BoxBody>,
52            >>::Error: Into<StdError> + Send + Sync,
53        {
54            RuntimeClient::new(InterceptedService::new(inner, interceptor))
55        }
56        /// Compress requests with the given encoding.
57        ///
58        /// This requires the server to support it otherwise it might respond with an
59        /// error.
60        #[must_use]
61        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
62            self.inner = self.inner.send_compressed(encoding);
63            self
64        }
65        /// Enable decompressing responses.
66        #[must_use]
67        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
68            self.inner = self.inner.accept_compressed(encoding);
69            self
70        }
71        /// Limits the maximum size of a decoded message.
72        ///
73        /// Default: `4MB`
74        #[must_use]
75        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
76            self.inner = self.inner.max_decoding_message_size(limit);
77            self
78        }
79        /// Limits the maximum size of an encoded message.
80        ///
81        /// Default: `usize::MAX`
82        #[must_use]
83        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
84            self.inner = self.inner.max_encoding_message_size(limit);
85            self
86        }
87        pub async fn initialize(
88            &mut self,
89            request: impl tonic::IntoRequest<super::InitializeRequest>,
90        ) -> std::result::Result<
91            tonic::Response<super::super::super::google::protobuf::Empty>,
92            tonic::Status,
93        > {
94            self.inner
95                .ready()
96                .await
97                .map_err(|e| {
98                    tonic::Status::new(
99                        tonic::Code::Unknown,
100                        format!("Service was not ready: {}", e.into()),
101                    )
102                })?;
103            let codec = tonic::codec::ProstCodec::default();
104            let path = http::uri::PathAndQuery::from_static(
105                "/vm.runtime.Runtime/Initialize",
106            );
107            let mut req = request.into_request();
108            req.extensions_mut()
109                .insert(GrpcMethod::new("vm.runtime.Runtime", "Initialize"));
110            self.inner.unary(req, path, codec).await
111        }
112    }
113}
114/// Generated server implementations.
115pub mod runtime_server {
116    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
117    use tonic::codegen::*;
118    /// Generated trait containing gRPC methods that should be implemented for use with RuntimeServer.
119    #[async_trait]
120    pub trait Runtime: Send + Sync + 'static {
121        async fn initialize(
122            &self,
123            request: tonic::Request<super::InitializeRequest>,
124        ) -> std::result::Result<
125            tonic::Response<super::super::super::google::protobuf::Empty>,
126            tonic::Status,
127        >;
128    }
129    #[derive(Debug)]
130    pub struct RuntimeServer<T: Runtime> {
131        inner: _Inner<T>,
132        accept_compression_encodings: EnabledCompressionEncodings,
133        send_compression_encodings: EnabledCompressionEncodings,
134        max_decoding_message_size: Option<usize>,
135        max_encoding_message_size: Option<usize>,
136    }
137    struct _Inner<T>(Arc<T>);
138    impl<T: Runtime> RuntimeServer<T> {
139        pub fn new(inner: T) -> Self {
140            Self::from_arc(Arc::new(inner))
141        }
142        pub fn from_arc(inner: Arc<T>) -> Self {
143            let inner = _Inner(inner);
144            Self {
145                inner,
146                accept_compression_encodings: Default::default(),
147                send_compression_encodings: Default::default(),
148                max_decoding_message_size: None,
149                max_encoding_message_size: None,
150            }
151        }
152        pub fn with_interceptor<F>(
153            inner: T,
154            interceptor: F,
155        ) -> InterceptedService<Self, F>
156        where
157            F: tonic::service::Interceptor,
158        {
159            InterceptedService::new(Self::new(inner), interceptor)
160        }
161        /// Enable decompressing requests with the given encoding.
162        #[must_use]
163        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
164            self.accept_compression_encodings.enable(encoding);
165            self
166        }
167        /// Compress responses with the given encoding, if the client supports it.
168        #[must_use]
169        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
170            self.send_compression_encodings.enable(encoding);
171            self
172        }
173        /// Limits the maximum size of a decoded message.
174        ///
175        /// Default: `4MB`
176        #[must_use]
177        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
178            self.max_decoding_message_size = Some(limit);
179            self
180        }
181        /// Limits the maximum size of an encoded message.
182        ///
183        /// Default: `usize::MAX`
184        #[must_use]
185        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
186            self.max_encoding_message_size = Some(limit);
187            self
188        }
189    }
190    impl<T, B> tonic::codegen::Service<http::Request<B>> for RuntimeServer<T>
191    where
192        T: Runtime,
193        B: Body + Send + 'static,
194        B::Error: Into<StdError> + Send + 'static,
195    {
196        type Response = http::Response<tonic::body::BoxBody>;
197        type Error = std::convert::Infallible;
198        type Future = BoxFuture<Self::Response, Self::Error>;
199        fn poll_ready(
200            &mut self,
201            _cx: &mut Context<'_>,
202        ) -> Poll<std::result::Result<(), Self::Error>> {
203            Poll::Ready(Ok(()))
204        }
205        fn call(&mut self, req: http::Request<B>) -> Self::Future {
206            let inner = self.inner.clone();
207            match req.uri().path() {
208                "/vm.runtime.Runtime/Initialize" => {
209                    #[allow(non_camel_case_types)]
210                    struct InitializeSvc<T: Runtime>(pub Arc<T>);
211                    impl<
212                        T: Runtime,
213                    > tonic::server::UnaryService<super::InitializeRequest>
214                    for InitializeSvc<T> {
215                        type Response = super::super::super::google::protobuf::Empty;
216                        type Future = BoxFuture<
217                            tonic::Response<Self::Response>,
218                            tonic::Status,
219                        >;
220                        fn call(
221                            &mut self,
222                            request: tonic::Request<super::InitializeRequest>,
223                        ) -> Self::Future {
224                            let inner = Arc::clone(&self.0);
225                            let fut = async move { (*inner).initialize(request).await };
226                            Box::pin(fut)
227                        }
228                    }
229                    let accept_compression_encodings = self.accept_compression_encodings;
230                    let send_compression_encodings = self.send_compression_encodings;
231                    let max_decoding_message_size = self.max_decoding_message_size;
232                    let max_encoding_message_size = self.max_encoding_message_size;
233                    let inner = self.inner.clone();
234                    let fut = async move {
235                        let inner = inner.0;
236                        let method = InitializeSvc(inner);
237                        let codec = tonic::codec::ProstCodec::default();
238                        let mut grpc = tonic::server::Grpc::new(codec)
239                            .apply_compression_config(
240                                accept_compression_encodings,
241                                send_compression_encodings,
242                            )
243                            .apply_max_message_size_config(
244                                max_decoding_message_size,
245                                max_encoding_message_size,
246                            );
247                        let res = grpc.unary(method, req).await;
248                        Ok(res)
249                    };
250                    Box::pin(fut)
251                }
252                _ => {
253                    Box::pin(async move {
254                        Ok(
255                            http::Response::builder()
256                                .status(200)
257                                .header("grpc-status", "12")
258                                .header("content-type", "application/grpc")
259                                .body(empty_body())
260                                .unwrap(),
261                        )
262                    })
263                }
264            }
265        }
266    }
267    impl<T: Runtime> Clone for RuntimeServer<T> {
268        fn clone(&self) -> Self {
269            let inner = self.inner.clone();
270            Self {
271                inner,
272                accept_compression_encodings: self.accept_compression_encodings,
273                send_compression_encodings: self.send_compression_encodings,
274                max_decoding_message_size: self.max_decoding_message_size,
275                max_encoding_message_size: self.max_encoding_message_size,
276            }
277        }
278    }
279    impl<T: Runtime> Clone for _Inner<T> {
280        fn clone(&self) -> Self {
281            Self(Arc::clone(&self.0))
282        }
283    }
284    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
285        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
286            write!(f, "{:?}", self.0)
287        }
288    }
289    impl<T: Runtime> tonic::server::NamedService for RuntimeServer<T> {
290        const NAME: &'static str = "vm.runtime.Runtime";
291    }
292}