1pub mod watch_service_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)]
10 pub struct WatchServiceClient<T> {
11 inner: tonic::client::Grpc<T>,
12 }
13 impl<T> WatchServiceClient<T>
14 where
15 T: tonic::client::GrpcService<tonic::body::BoxBody>,
16 T::Error: Into<StdError>,
17 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
18 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
19 {
20 pub fn new(inner: T) -> Self {
21 let inner = tonic::client::Grpc::new(inner);
22 Self { inner }
23 }
24 pub fn with_origin(inner: T, origin: Uri) -> Self {
25 let inner = tonic::client::Grpc::with_origin(inner, origin);
26 Self { inner }
27 }
28 pub fn with_interceptor<F>(
29 inner: T,
30 interceptor: F,
31 ) -> WatchServiceClient<InterceptedService<T, F>>
32 where
33 F: tonic::service::Interceptor,
34 T::ResponseBody: Default,
35 T: tonic::codegen::Service<
36 http::Request<tonic::body::BoxBody>,
37 Response = http::Response<
38 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
39 >,
40 >,
41 <T as tonic::codegen::Service<
42 http::Request<tonic::body::BoxBody>,
43 >>::Error: Into<StdError> + Send + Sync,
44 {
45 WatchServiceClient::new(InterceptedService::new(inner, interceptor))
46 }
47 #[must_use]
52 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
53 self.inner = self.inner.send_compressed(encoding);
54 self
55 }
56 #[must_use]
58 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
59 self.inner = self.inner.accept_compressed(encoding);
60 self
61 }
62 #[must_use]
66 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
67 self.inner = self.inner.max_decoding_message_size(limit);
68 self
69 }
70 #[must_use]
74 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
75 self.inner = self.inner.max_encoding_message_size(limit);
76 self
77 }
78 pub async fn watch_tx(
80 &mut self,
81 request: impl tonic::IntoRequest<super::WatchTxRequest>,
82 ) -> std::result::Result<
83 tonic::Response<tonic::codec::Streaming<super::WatchTxResponse>>,
84 tonic::Status,
85 > {
86 self.inner
87 .ready()
88 .await
89 .map_err(|e| {
90 tonic::Status::new(
91 tonic::Code::Unknown,
92 format!("Service was not ready: {}", e.into()),
93 )
94 })?;
95 let codec = tonic::codec::ProstCodec::default();
96 let path = http::uri::PathAndQuery::from_static(
97 "/utxorpc.v1alpha.watch.WatchService/WatchTx",
98 );
99 let mut req = request.into_request();
100 req.extensions_mut()
101 .insert(
102 GrpcMethod::new("utxorpc.v1alpha.watch.WatchService", "WatchTx"),
103 );
104 self.inner.server_streaming(req, path, codec).await
105 }
106 }
107}
108pub mod watch_service_server {
110 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
111 use tonic::codegen::*;
112 #[async_trait]
114 pub trait WatchService: Send + Sync + 'static {
115 type WatchTxStream: tonic::codegen::tokio_stream::Stream<
117 Item = std::result::Result<super::WatchTxResponse, tonic::Status>,
118 >
119 + Send
120 + 'static;
121 async fn watch_tx(
123 &self,
124 request: tonic::Request<super::WatchTxRequest>,
125 ) -> std::result::Result<tonic::Response<Self::WatchTxStream>, tonic::Status>;
126 }
127 #[derive(Debug)]
130 pub struct WatchServiceServer<T: WatchService> {
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: WatchService> WatchServiceServer<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 #[must_use]
163 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
164 self.accept_compression_encodings.enable(encoding);
165 self
166 }
167 #[must_use]
169 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
170 self.send_compression_encodings.enable(encoding);
171 self
172 }
173 #[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 #[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 WatchServiceServer<T>
191 where
192 T: WatchService,
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 "/utxorpc.v1alpha.watch.WatchService/WatchTx" => {
209 #[allow(non_camel_case_types)]
210 struct WatchTxSvc<T: WatchService>(pub Arc<T>);
211 impl<
212 T: WatchService,
213 > tonic::server::ServerStreamingService<super::WatchTxRequest>
214 for WatchTxSvc<T> {
215 type Response = super::WatchTxResponse;
216 type ResponseStream = T::WatchTxStream;
217 type Future = BoxFuture<
218 tonic::Response<Self::ResponseStream>,
219 tonic::Status,
220 >;
221 fn call(
222 &mut self,
223 request: tonic::Request<super::WatchTxRequest>,
224 ) -> Self::Future {
225 let inner = Arc::clone(&self.0);
226 let fut = async move {
227 <T as WatchService>::watch_tx(&inner, request).await
228 };
229 Box::pin(fut)
230 }
231 }
232 let accept_compression_encodings = self.accept_compression_encodings;
233 let send_compression_encodings = self.send_compression_encodings;
234 let max_decoding_message_size = self.max_decoding_message_size;
235 let max_encoding_message_size = self.max_encoding_message_size;
236 let inner = self.inner.clone();
237 let fut = async move {
238 let inner = inner.0;
239 let method = WatchTxSvc(inner);
240 let codec = tonic::codec::ProstCodec::default();
241 let mut grpc = tonic::server::Grpc::new(codec)
242 .apply_compression_config(
243 accept_compression_encodings,
244 send_compression_encodings,
245 )
246 .apply_max_message_size_config(
247 max_decoding_message_size,
248 max_encoding_message_size,
249 );
250 let res = grpc.server_streaming(method, req).await;
251 Ok(res)
252 };
253 Box::pin(fut)
254 }
255 _ => {
256 Box::pin(async move {
257 Ok(
258 http::Response::builder()
259 .status(200)
260 .header("grpc-status", "12")
261 .header("content-type", "application/grpc")
262 .body(empty_body())
263 .unwrap(),
264 )
265 })
266 }
267 }
268 }
269 }
270 impl<T: WatchService> Clone for WatchServiceServer<T> {
271 fn clone(&self) -> Self {
272 let inner = self.inner.clone();
273 Self {
274 inner,
275 accept_compression_encodings: self.accept_compression_encodings,
276 send_compression_encodings: self.send_compression_encodings,
277 max_decoding_message_size: self.max_decoding_message_size,
278 max_encoding_message_size: self.max_encoding_message_size,
279 }
280 }
281 }
282 impl<T: WatchService> Clone for _Inner<T> {
283 fn clone(&self) -> Self {
284 Self(Arc::clone(&self.0))
285 }
286 }
287 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
288 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
289 write!(f, "{:?}", self.0)
290 }
291 }
292 impl<T: WatchService> tonic::server::NamedService for WatchServiceServer<T> {
293 const NAME: &'static str = "utxorpc.v1alpha.watch.WatchService";
294 }
295}