1pub mod notification_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)]
8 pub struct NotificationServiceClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl NotificationServiceClient<tonic::transport::Channel> {
12 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14 where
15 D: 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> NotificationServiceClient<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 ) -> NotificationServiceClient<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 NotificationServiceClient::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 #[must_use]
75 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
76 self.inner = self.inner.max_decoding_message_size(limit);
77 self
78 }
79 #[must_use]
83 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
84 self.inner = self.inner.max_encoding_message_size(limit);
85 self
86 }
87 pub async fn create_notification(
88 &mut self,
89 request: impl tonic::IntoRequest<super::CreateNotificationRequest>,
90 ) -> std::result::Result<tonic::Response<super::Notification>, tonic::Status> {
91 self.inner
92 .ready()
93 .await
94 .map_err(|e| {
95 tonic::Status::new(
96 tonic::Code::Unknown,
97 format!("Service was not ready: {}", e.into()),
98 )
99 })?;
100 let codec = tonic::codec::ProstCodec::default();
101 let path = http::uri::PathAndQuery::from_static(
102 "/mmm.v1.notification.NotificationService/CreateNotification",
103 );
104 let mut req = request.into_request();
105 req.extensions_mut()
106 .insert(
107 GrpcMethod::new(
108 "mmm.v1.notification.NotificationService",
109 "CreateNotification",
110 ),
111 );
112 self.inner.unary(req, path, codec).await
113 }
114 }
115}
116pub mod notification_service_server {
118 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
119 use tonic::codegen::*;
120 #[async_trait]
122 pub trait NotificationService: Send + Sync + 'static {
123 async fn create_notification(
124 &self,
125 request: tonic::Request<super::CreateNotificationRequest>,
126 ) -> std::result::Result<tonic::Response<super::Notification>, tonic::Status>;
127 }
128 #[derive(Debug)]
129 pub struct NotificationServiceServer<T: NotificationService> {
130 inner: Arc<T>,
131 accept_compression_encodings: EnabledCompressionEncodings,
132 send_compression_encodings: EnabledCompressionEncodings,
133 max_decoding_message_size: Option<usize>,
134 max_encoding_message_size: Option<usize>,
135 }
136 impl<T: NotificationService> NotificationServiceServer<T> {
137 pub fn new(inner: T) -> Self {
138 Self::from_arc(Arc::new(inner))
139 }
140 pub fn from_arc(inner: Arc<T>) -> Self {
141 Self {
142 inner,
143 accept_compression_encodings: Default::default(),
144 send_compression_encodings: Default::default(),
145 max_decoding_message_size: None,
146 max_encoding_message_size: None,
147 }
148 }
149 pub fn with_interceptor<F>(
150 inner: T,
151 interceptor: F,
152 ) -> InterceptedService<Self, F>
153 where
154 F: tonic::service::Interceptor,
155 {
156 InterceptedService::new(Self::new(inner), interceptor)
157 }
158 #[must_use]
160 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
161 self.accept_compression_encodings.enable(encoding);
162 self
163 }
164 #[must_use]
166 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
167 self.send_compression_encodings.enable(encoding);
168 self
169 }
170 #[must_use]
174 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
175 self.max_decoding_message_size = Some(limit);
176 self
177 }
178 #[must_use]
182 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
183 self.max_encoding_message_size = Some(limit);
184 self
185 }
186 }
187 impl<T, B> tonic::codegen::Service<http::Request<B>> for NotificationServiceServer<T>
188 where
189 T: NotificationService,
190 B: Body + Send + 'static,
191 B::Error: Into<StdError> + Send + 'static,
192 {
193 type Response = http::Response<tonic::body::BoxBody>;
194 type Error = std::convert::Infallible;
195 type Future = BoxFuture<Self::Response, Self::Error>;
196 fn poll_ready(
197 &mut self,
198 _cx: &mut Context<'_>,
199 ) -> Poll<std::result::Result<(), Self::Error>> {
200 Poll::Ready(Ok(()))
201 }
202 fn call(&mut self, req: http::Request<B>) -> Self::Future {
203 match req.uri().path() {
204 "/mmm.v1.notification.NotificationService/CreateNotification" => {
205 #[allow(non_camel_case_types)]
206 struct CreateNotificationSvc<T: NotificationService>(pub Arc<T>);
207 impl<
208 T: NotificationService,
209 > tonic::server::UnaryService<super::CreateNotificationRequest>
210 for CreateNotificationSvc<T> {
211 type Response = super::Notification;
212 type Future = BoxFuture<
213 tonic::Response<Self::Response>,
214 tonic::Status,
215 >;
216 fn call(
217 &mut self,
218 request: tonic::Request<super::CreateNotificationRequest>,
219 ) -> Self::Future {
220 let inner = Arc::clone(&self.0);
221 let fut = async move {
222 <T as NotificationService>::create_notification(
223 &inner,
224 request,
225 )
226 .await
227 };
228 Box::pin(fut)
229 }
230 }
231 let accept_compression_encodings = self.accept_compression_encodings;
232 let send_compression_encodings = self.send_compression_encodings;
233 let max_decoding_message_size = self.max_decoding_message_size;
234 let max_encoding_message_size = self.max_encoding_message_size;
235 let inner = self.inner.clone();
236 let fut = async move {
237 let method = CreateNotificationSvc(inner);
238 let codec = tonic::codec::ProstCodec::default();
239 let mut grpc = tonic::server::Grpc::new(codec)
240 .apply_compression_config(
241 accept_compression_encodings,
242 send_compression_encodings,
243 )
244 .apply_max_message_size_config(
245 max_decoding_message_size,
246 max_encoding_message_size,
247 );
248 let res = grpc.unary(method, req).await;
249 Ok(res)
250 };
251 Box::pin(fut)
252 }
253 _ => {
254 Box::pin(async move {
255 Ok(
256 http::Response::builder()
257 .status(200)
258 .header("grpc-status", tonic::Code::Unimplemented as i32)
259 .header(
260 http::header::CONTENT_TYPE,
261 tonic::metadata::GRPC_CONTENT_TYPE,
262 )
263 .body(empty_body())
264 .unwrap(),
265 )
266 })
267 }
268 }
269 }
270 }
271 impl<T: NotificationService> Clone for NotificationServiceServer<T> {
272 fn clone(&self) -> Self {
273 let inner = self.inner.clone();
274 Self {
275 inner,
276 accept_compression_encodings: self.accept_compression_encodings,
277 send_compression_encodings: self.send_compression_encodings,
278 max_decoding_message_size: self.max_decoding_message_size,
279 max_encoding_message_size: self.max_encoding_message_size,
280 }
281 }
282 }
283 impl<T: NotificationService> tonic::server::NamedService
284 for NotificationServiceServer<T> {
285 const NAME: &'static str = "mmm.v1.notification.NotificationService";
286 }
287}