Skip to main content

agp_config/testutils/
helloworld.rs

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