avalanche_proto/gen/
io.reader.tonic.rs1pub mod reader_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 ReaderClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl ReaderClient<tonic::transport::Channel> {
12 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14 where
15 D: std::convert::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> ReaderClient<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 ) -> ReaderClient<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 ReaderClient::new(InterceptedService::new(inner, interceptor))
55 }
56 #[must_use]
61 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
62 self.inner = self.inner.send_compressed(encoding);
63 self
64 }
65 #[must_use]
67 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
68 self.inner = self.inner.accept_compressed(encoding);
69 self
70 }
71 pub async fn read(
72 &mut self,
73 request: impl tonic::IntoRequest<super::ReadRequest>,
74 ) -> Result<tonic::Response<super::ReadResponse>, tonic::Status> {
75 self.inner
76 .ready()
77 .await
78 .map_err(|e| {
79 tonic::Status::new(
80 tonic::Code::Unknown,
81 format!("Service was not ready: {}", e.into()),
82 )
83 })?;
84 let codec = tonic::codec::ProstCodec::default();
85 let path = http::uri::PathAndQuery::from_static("/io.reader.Reader/Read");
86 self.inner.unary(request.into_request(), path, codec).await
87 }
88 }
89}
90pub mod reader_server {
92 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
93 use tonic::codegen::*;
94 #[async_trait]
96 pub trait Reader: Send + Sync + 'static {
97 async fn read(
98 &self,
99 request: tonic::Request<super::ReadRequest>,
100 ) -> Result<tonic::Response<super::ReadResponse>, tonic::Status>;
101 }
102 #[derive(Debug)]
103 pub struct ReaderServer<T: Reader> {
104 inner: _Inner<T>,
105 accept_compression_encodings: EnabledCompressionEncodings,
106 send_compression_encodings: EnabledCompressionEncodings,
107 }
108 struct _Inner<T>(Arc<T>);
109 impl<T: Reader> ReaderServer<T> {
110 pub fn new(inner: T) -> Self {
111 Self::from_arc(Arc::new(inner))
112 }
113 pub fn from_arc(inner: Arc<T>) -> Self {
114 let inner = _Inner(inner);
115 Self {
116 inner,
117 accept_compression_encodings: Default::default(),
118 send_compression_encodings: Default::default(),
119 }
120 }
121 pub fn with_interceptor<F>(
122 inner: T,
123 interceptor: F,
124 ) -> InterceptedService<Self, F>
125 where
126 F: tonic::service::Interceptor,
127 {
128 InterceptedService::new(Self::new(inner), interceptor)
129 }
130 #[must_use]
132 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
133 self.accept_compression_encodings.enable(encoding);
134 self
135 }
136 #[must_use]
138 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
139 self.send_compression_encodings.enable(encoding);
140 self
141 }
142 }
143 impl<T, B> tonic::codegen::Service<http::Request<B>> for ReaderServer<T>
144 where
145 T: Reader,
146 B: Body + Send + 'static,
147 B::Error: Into<StdError> + Send + 'static,
148 {
149 type Response = http::Response<tonic::body::BoxBody>;
150 type Error = std::convert::Infallible;
151 type Future = BoxFuture<Self::Response, Self::Error>;
152 fn poll_ready(
153 &mut self,
154 _cx: &mut Context<'_>,
155 ) -> Poll<Result<(), Self::Error>> {
156 Poll::Ready(Ok(()))
157 }
158 fn call(&mut self, req: http::Request<B>) -> Self::Future {
159 let inner = self.inner.clone();
160 match req.uri().path() {
161 "/io.reader.Reader/Read" => {
162 #[allow(non_camel_case_types)]
163 struct ReadSvc<T: Reader>(pub Arc<T>);
164 impl<T: Reader> tonic::server::UnaryService<super::ReadRequest>
165 for ReadSvc<T> {
166 type Response = super::ReadResponse;
167 type Future = BoxFuture<
168 tonic::Response<Self::Response>,
169 tonic::Status,
170 >;
171 fn call(
172 &mut self,
173 request: tonic::Request<super::ReadRequest>,
174 ) -> Self::Future {
175 let inner = self.0.clone();
176 let fut = async move { (*inner).read(request).await };
177 Box::pin(fut)
178 }
179 }
180 let accept_compression_encodings = self.accept_compression_encodings;
181 let send_compression_encodings = self.send_compression_encodings;
182 let inner = self.inner.clone();
183 let fut = async move {
184 let inner = inner.0;
185 let method = ReadSvc(inner);
186 let codec = tonic::codec::ProstCodec::default();
187 let mut grpc = tonic::server::Grpc::new(codec)
188 .apply_compression_config(
189 accept_compression_encodings,
190 send_compression_encodings,
191 );
192 let res = grpc.unary(method, req).await;
193 Ok(res)
194 };
195 Box::pin(fut)
196 }
197 _ => {
198 Box::pin(async move {
199 Ok(
200 http::Response::builder()
201 .status(200)
202 .header("grpc-status", "12")
203 .header("content-type", "application/grpc")
204 .body(empty_body())
205 .unwrap(),
206 )
207 })
208 }
209 }
210 }
211 }
212 impl<T: Reader> Clone for ReaderServer<T> {
213 fn clone(&self) -> Self {
214 let inner = self.inner.clone();
215 Self {
216 inner,
217 accept_compression_encodings: self.accept_compression_encodings,
218 send_compression_encodings: self.send_compression_encodings,
219 }
220 }
221 }
222 impl<T: Reader> Clone for _Inner<T> {
223 fn clone(&self) -> Self {
224 Self(self.0.clone())
225 }
226 }
227 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
228 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
229 write!(f, "{:?}", self.0)
230 }
231 }
232 impl<T: Reader> tonic::server::NamedService for ReaderServer<T> {
233 const NAME: &'static str = "io.reader.Reader";
234 }
235}