avalanche_proto/gen/
subnetlookup.tonic.rs1pub mod subnet_lookup_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 SubnetLookupClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl SubnetLookupClient<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> SubnetLookupClient<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 ) -> SubnetLookupClient<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 SubnetLookupClient::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 subnet_id(
72 &mut self,
73 request: impl tonic::IntoRequest<super::SubnetIdRequest>,
74 ) -> Result<tonic::Response<super::SubnetIdResponse>, 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(
86 "/subnetlookup.SubnetLookup/SubnetID",
87 );
88 self.inner.unary(request.into_request(), path, codec).await
89 }
90 }
91}
92pub mod subnet_lookup_server {
94 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
95 use tonic::codegen::*;
96 #[async_trait]
98 pub trait SubnetLookup: Send + Sync + 'static {
99 async fn subnet_id(
100 &self,
101 request: tonic::Request<super::SubnetIdRequest>,
102 ) -> Result<tonic::Response<super::SubnetIdResponse>, tonic::Status>;
103 }
104 #[derive(Debug)]
105 pub struct SubnetLookupServer<T: SubnetLookup> {
106 inner: _Inner<T>,
107 accept_compression_encodings: EnabledCompressionEncodings,
108 send_compression_encodings: EnabledCompressionEncodings,
109 }
110 struct _Inner<T>(Arc<T>);
111 impl<T: SubnetLookup> SubnetLookupServer<T> {
112 pub fn new(inner: T) -> Self {
113 Self::from_arc(Arc::new(inner))
114 }
115 pub fn from_arc(inner: Arc<T>) -> Self {
116 let inner = _Inner(inner);
117 Self {
118 inner,
119 accept_compression_encodings: Default::default(),
120 send_compression_encodings: Default::default(),
121 }
122 }
123 pub fn with_interceptor<F>(
124 inner: T,
125 interceptor: F,
126 ) -> InterceptedService<Self, F>
127 where
128 F: tonic::service::Interceptor,
129 {
130 InterceptedService::new(Self::new(inner), interceptor)
131 }
132 #[must_use]
134 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
135 self.accept_compression_encodings.enable(encoding);
136 self
137 }
138 #[must_use]
140 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
141 self.send_compression_encodings.enable(encoding);
142 self
143 }
144 }
145 impl<T, B> tonic::codegen::Service<http::Request<B>> for SubnetLookupServer<T>
146 where
147 T: SubnetLookup,
148 B: Body + Send + 'static,
149 B::Error: Into<StdError> + Send + 'static,
150 {
151 type Response = http::Response<tonic::body::BoxBody>;
152 type Error = std::convert::Infallible;
153 type Future = BoxFuture<Self::Response, Self::Error>;
154 fn poll_ready(
155 &mut self,
156 _cx: &mut Context<'_>,
157 ) -> Poll<Result<(), Self::Error>> {
158 Poll::Ready(Ok(()))
159 }
160 fn call(&mut self, req: http::Request<B>) -> Self::Future {
161 let inner = self.inner.clone();
162 match req.uri().path() {
163 "/subnetlookup.SubnetLookup/SubnetID" => {
164 #[allow(non_camel_case_types)]
165 struct SubnetIDSvc<T: SubnetLookup>(pub Arc<T>);
166 impl<
167 T: SubnetLookup,
168 > tonic::server::UnaryService<super::SubnetIdRequest>
169 for SubnetIDSvc<T> {
170 type Response = super::SubnetIdResponse;
171 type Future = BoxFuture<
172 tonic::Response<Self::Response>,
173 tonic::Status,
174 >;
175 fn call(
176 &mut self,
177 request: tonic::Request<super::SubnetIdRequest>,
178 ) -> Self::Future {
179 let inner = self.0.clone();
180 let fut = async move { (*inner).subnet_id(request).await };
181 Box::pin(fut)
182 }
183 }
184 let accept_compression_encodings = self.accept_compression_encodings;
185 let send_compression_encodings = self.send_compression_encodings;
186 let inner = self.inner.clone();
187 let fut = async move {
188 let inner = inner.0;
189 let method = SubnetIDSvc(inner);
190 let codec = tonic::codec::ProstCodec::default();
191 let mut grpc = tonic::server::Grpc::new(codec)
192 .apply_compression_config(
193 accept_compression_encodings,
194 send_compression_encodings,
195 );
196 let res = grpc.unary(method, req).await;
197 Ok(res)
198 };
199 Box::pin(fut)
200 }
201 _ => {
202 Box::pin(async move {
203 Ok(
204 http::Response::builder()
205 .status(200)
206 .header("grpc-status", "12")
207 .header("content-type", "application/grpc")
208 .body(empty_body())
209 .unwrap(),
210 )
211 })
212 }
213 }
214 }
215 }
216 impl<T: SubnetLookup> Clone for SubnetLookupServer<T> {
217 fn clone(&self) -> Self {
218 let inner = self.inner.clone();
219 Self {
220 inner,
221 accept_compression_encodings: self.accept_compression_encodings,
222 send_compression_encodings: self.send_compression_encodings,
223 }
224 }
225 }
226 impl<T: SubnetLookup> Clone for _Inner<T> {
227 fn clone(&self) -> Self {
228 Self(self.0.clone())
229 }
230 }
231 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
232 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
233 write!(f, "{:?}", self.0)
234 }
235 }
236 impl<T: SubnetLookup> tonic::server::NamedService for SubnetLookupServer<T> {
237 const NAME: &'static str = "subnetlookup.SubnetLookup";
238 }
239}