rnacos/grpc/
nacos_proto.rs

1#![allow(non_camel_case_types)]
2
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Any {
5    #[prost(string, tag = "1")]
6    pub type_url: ::prost::alloc::string::String,
7    #[prost(bytes = "vec", tag = "2")]
8    pub value: ::prost::alloc::vec::Vec<u8>,
9}
10#[derive(Clone, PartialEq, ::prost::Message)]
11pub struct Metadata {
12    #[prost(string, tag = "3")]
13    pub r#type: ::prost::alloc::string::String,
14    #[prost(string, tag = "8")]
15    pub client_ip: ::prost::alloc::string::String,
16    #[prost(map = "string, string", tag = "7")]
17    pub headers:
18        ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
19}
20#[derive(Clone, PartialEq, ::prost::Message)]
21pub struct Payload {
22    #[prost(message, optional, tag = "2")]
23    pub metadata: ::core::option::Option<Metadata>,
24    #[prost(message, optional, tag = "3")]
25    pub body: ::core::option::Option<Any>,
26}
27#[doc = r" Generated client implementations."]
28pub mod request_client {
29    #![allow(unused_variables, dead_code, missing_docs)]
30    use tonic::codegen::*;
31    pub struct RequestClient<T> {
32        inner: tonic::client::Grpc<T>,
33    }
34    impl RequestClient<tonic::transport::Channel> {
35        #[doc = r" Attempt to create a new client by connecting to a given endpoint."]
36        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
37        where
38            D: std::convert::TryInto<tonic::transport::Endpoint>,
39            D::Error: Into<StdError>,
40        {
41            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
42            Ok(Self::new(conn))
43        }
44    }
45    impl<T> RequestClient<T>
46    where
47        T: tonic::client::GrpcService<tonic::body::BoxBody>,
48        T::ResponseBody: Body + HttpBody + Send + 'static,
49        T::Error: Into<StdError>,
50        <T::ResponseBody as HttpBody>::Error: Into<StdError> + Send,
51    {
52        pub fn new(inner: T) -> Self {
53            let inner = tonic::client::Grpc::new(inner);
54            Self { inner }
55        }
56        pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
57            let inner = tonic::client::Grpc::with_interceptor(inner, interceptor);
58            Self { inner }
59        }
60        #[doc = " Sends a commonRequest"]
61        pub async fn request(
62            &mut self,
63            request: impl tonic::IntoRequest<super::Payload>,
64        ) -> Result<tonic::Response<super::Payload>, tonic::Status> {
65            self.inner.ready().await.map_err(|e| {
66                tonic::Status::new(
67                    tonic::Code::Unknown,
68                    format!("Service was not ready: {}", e.into()),
69                )
70            })?;
71            let codec = tonic::codec::ProstCodec::default();
72            let path = http::uri::PathAndQuery::from_static("/Request/request");
73            self.inner.unary(request.into_request(), path, codec).await
74        }
75    }
76    impl<T: Clone> Clone for RequestClient<T> {
77        fn clone(&self) -> Self {
78            Self {
79                inner: self.inner.clone(),
80            }
81        }
82    }
83    impl<T> std::fmt::Debug for RequestClient<T> {
84        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
85            write!(f, "RequestClient {{ ... }}")
86        }
87    }
88}
89#[doc = r" Generated client implementations."]
90pub mod bi_request_stream_client {
91    #![allow(unused_variables, dead_code, missing_docs)]
92    use tonic::codegen::*;
93    pub struct BiRequestStreamClient<T> {
94        inner: tonic::client::Grpc<T>,
95    }
96    impl BiRequestStreamClient<tonic::transport::Channel> {
97        #[doc = r" Attempt to create a new client by connecting to a given endpoint."]
98        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
99        where
100            D: std::convert::TryInto<tonic::transport::Endpoint>,
101            D::Error: Into<StdError>,
102        {
103            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
104            Ok(Self::new(conn))
105        }
106    }
107    impl<T> BiRequestStreamClient<T>
108    where
109        T: tonic::client::GrpcService<tonic::body::BoxBody>,
110        T::ResponseBody: Body + HttpBody + Send + 'static,
111        T::Error: Into<StdError>,
112        <T::ResponseBody as HttpBody>::Error: Into<StdError> + Send,
113    {
114        pub fn new(inner: T) -> Self {
115            let inner = tonic::client::Grpc::new(inner);
116            Self { inner }
117        }
118        pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
119            let inner = tonic::client::Grpc::with_interceptor(inner, interceptor);
120            Self { inner }
121        }
122        #[doc = " Sends a commonRequest"]
123        pub async fn request_bi_stream(
124            &mut self,
125            request: impl tonic::IntoStreamingRequest<Message = super::Payload>,
126        ) -> Result<tonic::Response<tonic::codec::Streaming<super::Payload>>, tonic::Status>
127        {
128            self.inner.ready().await.map_err(|e| {
129                tonic::Status::new(
130                    tonic::Code::Unknown,
131                    format!("Service was not ready: {}", e.into()),
132                )
133            })?;
134            let codec = tonic::codec::ProstCodec::default();
135            let path = http::uri::PathAndQuery::from_static("/BiRequestStream/requestBiStream");
136            self.inner
137                .streaming(request.into_streaming_request(), path, codec)
138                .await
139        }
140    }
141    impl<T: Clone> Clone for BiRequestStreamClient<T> {
142        fn clone(&self) -> Self {
143            Self {
144                inner: self.inner.clone(),
145            }
146        }
147    }
148    impl<T> std::fmt::Debug for BiRequestStreamClient<T> {
149        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
150            write!(f, "BiRequestStreamClient {{ ... }}")
151        }
152    }
153}
154#[doc = r" Generated server implementations."]
155pub mod request_server {
156    #![allow(unused_variables, dead_code, missing_docs)]
157    use tonic::codegen::*;
158    #[doc = "Generated trait containing gRPC methods that should be implemented for use with RequestServer."]
159    #[async_trait]
160    pub trait Request: Send + Sync + 'static {
161        #[doc = " Sends a commonRequest"]
162        async fn request(
163            &self,
164            request: tonic::Request<super::Payload>,
165        ) -> Result<tonic::Response<super::Payload>, tonic::Status>;
166    }
167    #[derive(Debug)]
168    pub struct RequestServer<T: Request> {
169        inner: _Inner<T>,
170    }
171    struct _Inner<T>(Arc<T>, Option<tonic::Interceptor>);
172    impl<T: Request> RequestServer<T> {
173        pub fn new(inner: T) -> Self {
174            let inner = Arc::new(inner);
175            let inner = _Inner(inner, None);
176            Self { inner }
177        }
178        pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
179            let inner = Arc::new(inner);
180            let inner = _Inner(inner, Some(interceptor.into()));
181            Self { inner }
182        }
183    }
184    impl<T, B> Service<http::Request<B>> for RequestServer<T>
185    where
186        T: Request,
187        B: HttpBody + Send + Sync + 'static,
188        B::Error: Into<StdError> + Send + 'static,
189    {
190        type Response = http::Response<tonic::body::BoxBody>;
191        type Error = Never;
192        type Future = BoxFuture<Self::Response, Self::Error>;
193        fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
194            Poll::Ready(Ok(()))
195        }
196        fn call(&mut self, req: http::Request<B>) -> Self::Future {
197            let inner = self.inner.clone();
198            match req.uri().path() {
199                "/Request/request" => {
200                    #[allow(non_camel_case_types)]
201                    struct requestSvc<T: Request>(pub Arc<T>);
202                    impl<T: Request> tonic::server::UnaryService<super::Payload> for requestSvc<T> {
203                        type Response = super::Payload;
204                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
205                        fn call(
206                            &mut self,
207                            request: tonic::Request<super::Payload>,
208                        ) -> Self::Future {
209                            let inner = self.0.clone();
210                            let fut = async move { (*inner).request(request).await };
211                            Box::pin(fut)
212                        }
213                    }
214                    let inner = self.inner.clone();
215                    let fut = async move {
216                        let interceptor = inner.1.clone();
217                        let inner = inner.0;
218                        let method = requestSvc(inner);
219                        let codec = tonic::codec::ProstCodec::default();
220                        let mut grpc = if let Some(interceptor) = interceptor {
221                            tonic::server::Grpc::with_interceptor(codec, interceptor)
222                        } else {
223                            tonic::server::Grpc::new(codec)
224                        };
225                        let res = grpc.unary(method, req).await;
226                        Ok(res)
227                    };
228                    Box::pin(fut)
229                }
230                _ => Box::pin(async move {
231                    Ok(http::Response::builder()
232                        .status(200)
233                        .header("grpc-status", "12")
234                        .header("content-type", "application/grpc")
235                        .body(tonic::body::BoxBody::empty())
236                        .unwrap())
237                }),
238            }
239        }
240    }
241    impl<T: Request> Clone for RequestServer<T> {
242        fn clone(&self) -> Self {
243            let inner = self.inner.clone();
244            Self { inner }
245        }
246    }
247    impl<T: Request> Clone for _Inner<T> {
248        fn clone(&self) -> Self {
249            Self(self.0.clone(), self.1.clone())
250        }
251    }
252    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
253        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
254            write!(f, "{:?}", self.0)
255        }
256    }
257    impl<T: Request> tonic::transport::NamedService for RequestServer<T> {
258        const NAME: &'static str = "Request";
259    }
260}
261#[doc = r" Generated server implementations."]
262pub mod bi_request_stream_server {
263    #![allow(unused_variables, dead_code, missing_docs)]
264    use tonic::codegen::*;
265    #[doc = "Generated trait containing gRPC methods that should be implemented for use with BiRequestStreamServer."]
266    #[async_trait]
267    pub trait BiRequestStream: Send + Sync + 'static {
268        #[doc = "Server streaming response type for the requestBiStream method."]
269        type requestBiStreamStream: futures_core::Stream<Item = Result<super::Payload, tonic::Status>>
270            + Send
271            + Sync
272            + 'static;
273        #[doc = " Sends a commonRequest"]
274        async fn request_bi_stream(
275            &self,
276            request: tonic::Request<tonic::Streaming<super::Payload>>,
277        ) -> Result<tonic::Response<Self::requestBiStreamStream>, tonic::Status>;
278    }
279    #[derive(Debug)]
280    pub struct BiRequestStreamServer<T: BiRequestStream> {
281        inner: _Inner<T>,
282    }
283    struct _Inner<T>(Arc<T>, Option<tonic::Interceptor>);
284    impl<T: BiRequestStream> BiRequestStreamServer<T> {
285        pub fn new(inner: T) -> Self {
286            let inner = Arc::new(inner);
287            let inner = _Inner(inner, None);
288            Self { inner }
289        }
290        pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
291            let inner = Arc::new(inner);
292            let inner = _Inner(inner, Some(interceptor.into()));
293            Self { inner }
294        }
295    }
296    impl<T, B> Service<http::Request<B>> for BiRequestStreamServer<T>
297    where
298        T: BiRequestStream,
299        B: HttpBody + Send + Sync + 'static,
300        B::Error: Into<StdError> + Send + 'static,
301    {
302        type Response = http::Response<tonic::body::BoxBody>;
303        type Error = Never;
304        type Future = BoxFuture<Self::Response, Self::Error>;
305        fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
306            Poll::Ready(Ok(()))
307        }
308        fn call(&mut self, req: http::Request<B>) -> Self::Future {
309            let inner = self.inner.clone();
310            match req.uri().path() {
311                "/BiRequestStream/requestBiStream" => {
312                    #[allow(non_camel_case_types)]
313                    struct requestBiStreamSvc<T: BiRequestStream>(pub Arc<T>);
314                    impl<T: BiRequestStream> tonic::server::StreamingService<super::Payload> for requestBiStreamSvc<T> {
315                        type Response = super::Payload;
316                        type ResponseStream = T::requestBiStreamStream;
317                        type Future =
318                            BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
319                        fn call(
320                            &mut self,
321                            request: tonic::Request<tonic::Streaming<super::Payload>>,
322                        ) -> Self::Future {
323                            let inner = self.0.clone();
324                            let fut = async move { (*inner).request_bi_stream(request).await };
325                            Box::pin(fut)
326                        }
327                    }
328                    let inner = self.inner.clone();
329                    let fut = async move {
330                        let interceptor = inner.1;
331                        let inner = inner.0;
332                        let method = requestBiStreamSvc(inner);
333                        let codec = tonic::codec::ProstCodec::default();
334                        let mut grpc = if let Some(interceptor) = interceptor {
335                            tonic::server::Grpc::with_interceptor(codec, interceptor)
336                        } else {
337                            tonic::server::Grpc::new(codec)
338                        };
339                        let res = grpc.streaming(method, req).await;
340                        Ok(res)
341                    };
342                    Box::pin(fut)
343                }
344                _ => Box::pin(async move {
345                    Ok(http::Response::builder()
346                        .status(200)
347                        .header("grpc-status", "12")
348                        .header("content-type", "application/grpc")
349                        .body(tonic::body::BoxBody::empty())
350                        .unwrap())
351                }),
352            }
353        }
354    }
355    impl<T: BiRequestStream> Clone for BiRequestStreamServer<T> {
356        fn clone(&self) -> Self {
357            let inner = self.inner.clone();
358            Self { inner }
359        }
360    }
361    impl<T: BiRequestStream> Clone for _Inner<T> {
362        fn clone(&self) -> Self {
363            Self(self.0.clone(), self.1.clone())
364        }
365    }
366    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
367        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
368            write!(f, "{:?}", self.0)
369        }
370    }
371    impl<T: BiRequestStream> tonic::transport::NamedService for BiRequestStreamServer<T> {
372        const NAME: &'static str = "BiRequestStream";
373    }
374}