1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
5pub struct Token {
6 #[prost(message, optional, tag = "1")]
8 pub identity_key: ::core::option::Option<super::super::message_contents::PublicKey>,
9 #[prost(bytes = "vec", tag = "2")]
11 pub auth_data_bytes: ::prost::alloc::vec::Vec<u8>,
12 #[prost(message, optional, tag = "3")]
14 pub auth_data_signature: ::core::option::Option<
15 super::super::message_contents::Signature,
16 >,
17}
18impl ::prost::Name for Token {
19 const NAME: &'static str = "Token";
20 const PACKAGE: &'static str = "xmtp.message_api.v1";
21 fn full_name() -> ::prost::alloc::string::String {
22 "xmtp.message_api.v1.Token".into()
23 }
24 fn type_url() -> ::prost::alloc::string::String {
25 "/xmtp.message_api.v1.Token".into()
26 }
27}
28#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
34pub struct AuthData {
35 #[prost(string, tag = "1")]
37 pub wallet_addr: ::prost::alloc::string::String,
38 #[prost(uint64, tag = "2")]
40 pub created_ns: u64,
41}
42impl ::prost::Name for AuthData {
43 const NAME: &'static str = "AuthData";
44 const PACKAGE: &'static str = "xmtp.message_api.v1";
45 fn full_name() -> ::prost::alloc::string::String {
46 "xmtp.message_api.v1.AuthData".into()
47 }
48 fn type_url() -> ::prost::alloc::string::String {
49 "/xmtp.message_api.v1.AuthData".into()
50 }
51}
52#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
56pub struct IndexCursor {
57 #[prost(bytes = "vec", tag = "1")]
58 pub digest: ::prost::alloc::vec::Vec<u8>,
59 #[prost(uint64, tag = "2")]
60 pub sender_time_ns: u64,
61}
62impl ::prost::Name for IndexCursor {
63 const NAME: &'static str = "IndexCursor";
64 const PACKAGE: &'static str = "xmtp.message_api.v1";
65 fn full_name() -> ::prost::alloc::string::String {
66 "xmtp.message_api.v1.IndexCursor".into()
67 }
68 fn type_url() -> ::prost::alloc::string::String {
69 "/xmtp.message_api.v1.IndexCursor".into()
70 }
71}
72#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
74pub struct Cursor {
75 #[prost(oneof = "cursor::Cursor", tags = "1")]
79 pub cursor: ::core::option::Option<cursor::Cursor>,
80}
81pub mod cursor {
83 #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
87 pub enum Cursor {
88 #[prost(message, tag = "1")]
89 Index(super::IndexCursor),
90 }
91}
92impl ::prost::Name for Cursor {
93 const NAME: &'static str = "Cursor";
94 const PACKAGE: &'static str = "xmtp.message_api.v1";
95 fn full_name() -> ::prost::alloc::string::String {
96 "xmtp.message_api.v1.Cursor".into()
97 }
98 fn type_url() -> ::prost::alloc::string::String {
99 "/xmtp.message_api.v1.Cursor".into()
100 }
101}
102#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
105pub struct PagingInfo {
106 #[prost(uint32, tag = "1")]
108 pub limit: u32,
109 #[prost(message, optional, tag = "2")]
110 pub cursor: ::core::option::Option<Cursor>,
111 #[prost(enumeration = "SortDirection", tag = "3")]
112 pub direction: i32,
113}
114impl ::prost::Name for PagingInfo {
115 const NAME: &'static str = "PagingInfo";
116 const PACKAGE: &'static str = "xmtp.message_api.v1";
117 fn full_name() -> ::prost::alloc::string::String {
118 "xmtp.message_api.v1.PagingInfo".into()
119 }
120 fn type_url() -> ::prost::alloc::string::String {
121 "/xmtp.message_api.v1.PagingInfo".into()
122 }
123}
124#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
126pub struct Envelope {
127 #[prost(string, tag = "1")]
131 pub content_topic: ::prost::alloc::string::String,
132 #[prost(uint64, tag = "2")]
136 pub timestamp_ns: u64,
137 #[prost(bytes = "vec", tag = "3")]
138 pub message: ::prost::alloc::vec::Vec<u8>,
139}
140impl ::prost::Name for Envelope {
141 const NAME: &'static str = "Envelope";
142 const PACKAGE: &'static str = "xmtp.message_api.v1";
143 fn full_name() -> ::prost::alloc::string::String {
144 "xmtp.message_api.v1.Envelope".into()
145 }
146 fn type_url() -> ::prost::alloc::string::String {
147 "/xmtp.message_api.v1.Envelope".into()
148 }
149}
150#[derive(Clone, PartialEq, ::prost::Message)]
152pub struct PublishRequest {
153 #[prost(message, repeated, tag = "1")]
154 pub envelopes: ::prost::alloc::vec::Vec<Envelope>,
155}
156impl ::prost::Name for PublishRequest {
157 const NAME: &'static str = "PublishRequest";
158 const PACKAGE: &'static str = "xmtp.message_api.v1";
159 fn full_name() -> ::prost::alloc::string::String {
160 "xmtp.message_api.v1.PublishRequest".into()
161 }
162 fn type_url() -> ::prost::alloc::string::String {
163 "/xmtp.message_api.v1.PublishRequest".into()
164 }
165}
166#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
168pub struct PublishResponse {}
169impl ::prost::Name for PublishResponse {
170 const NAME: &'static str = "PublishResponse";
171 const PACKAGE: &'static str = "xmtp.message_api.v1";
172 fn full_name() -> ::prost::alloc::string::String {
173 "xmtp.message_api.v1.PublishResponse".into()
174 }
175 fn type_url() -> ::prost::alloc::string::String {
176 "/xmtp.message_api.v1.PublishResponse".into()
177 }
178}
179#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
181pub struct SubscribeRequest {
182 #[prost(string, repeated, tag = "1")]
183 pub content_topics: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
184}
185impl ::prost::Name for SubscribeRequest {
186 const NAME: &'static str = "SubscribeRequest";
187 const PACKAGE: &'static str = "xmtp.message_api.v1";
188 fn full_name() -> ::prost::alloc::string::String {
189 "xmtp.message_api.v1.SubscribeRequest".into()
190 }
191 fn type_url() -> ::prost::alloc::string::String {
192 "/xmtp.message_api.v1.SubscribeRequest".into()
193 }
194}
195#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
197pub struct SubscribeAllRequest {}
198impl ::prost::Name for SubscribeAllRequest {
199 const NAME: &'static str = "SubscribeAllRequest";
200 const PACKAGE: &'static str = "xmtp.message_api.v1";
201 fn full_name() -> ::prost::alloc::string::String {
202 "xmtp.message_api.v1.SubscribeAllRequest".into()
203 }
204 fn type_url() -> ::prost::alloc::string::String {
205 "/xmtp.message_api.v1.SubscribeAllRequest".into()
206 }
207}
208#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
210pub struct QueryRequest {
211 #[prost(string, repeated, tag = "1")]
212 pub content_topics: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
213 #[prost(uint64, tag = "2")]
214 pub start_time_ns: u64,
215 #[prost(uint64, tag = "3")]
216 pub end_time_ns: u64,
217 #[prost(message, optional, tag = "4")]
218 pub paging_info: ::core::option::Option<PagingInfo>,
219}
220impl ::prost::Name for QueryRequest {
221 const NAME: &'static str = "QueryRequest";
222 const PACKAGE: &'static str = "xmtp.message_api.v1";
223 fn full_name() -> ::prost::alloc::string::String {
224 "xmtp.message_api.v1.QueryRequest".into()
225 }
226 fn type_url() -> ::prost::alloc::string::String {
227 "/xmtp.message_api.v1.QueryRequest".into()
228 }
229}
230#[derive(Clone, PartialEq, ::prost::Message)]
232pub struct QueryResponse {
233 #[prost(message, repeated, tag = "1")]
234 pub envelopes: ::prost::alloc::vec::Vec<Envelope>,
235 #[prost(message, optional, tag = "2")]
236 pub paging_info: ::core::option::Option<PagingInfo>,
237}
238impl ::prost::Name for QueryResponse {
239 const NAME: &'static str = "QueryResponse";
240 const PACKAGE: &'static str = "xmtp.message_api.v1";
241 fn full_name() -> ::prost::alloc::string::String {
242 "xmtp.message_api.v1.QueryResponse".into()
243 }
244 fn type_url() -> ::prost::alloc::string::String {
245 "/xmtp.message_api.v1.QueryResponse".into()
246 }
247}
248#[derive(Clone, PartialEq, ::prost::Message)]
250pub struct BatchQueryRequest {
251 #[prost(message, repeated, tag = "1")]
252 pub requests: ::prost::alloc::vec::Vec<QueryRequest>,
253}
254impl ::prost::Name for BatchQueryRequest {
255 const NAME: &'static str = "BatchQueryRequest";
256 const PACKAGE: &'static str = "xmtp.message_api.v1";
257 fn full_name() -> ::prost::alloc::string::String {
258 "xmtp.message_api.v1.BatchQueryRequest".into()
259 }
260 fn type_url() -> ::prost::alloc::string::String {
261 "/xmtp.message_api.v1.BatchQueryRequest".into()
262 }
263}
264#[derive(Clone, PartialEq, ::prost::Message)]
266pub struct BatchQueryResponse {
267 #[prost(message, repeated, tag = "1")]
268 pub responses: ::prost::alloc::vec::Vec<QueryResponse>,
269}
270impl ::prost::Name for BatchQueryResponse {
271 const NAME: &'static str = "BatchQueryResponse";
272 const PACKAGE: &'static str = "xmtp.message_api.v1";
273 fn full_name() -> ::prost::alloc::string::String {
274 "xmtp.message_api.v1.BatchQueryResponse".into()
275 }
276 fn type_url() -> ::prost::alloc::string::String {
277 "/xmtp.message_api.v1.BatchQueryResponse".into()
278 }
279}
280#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
282#[repr(i32)]
283pub enum SortDirection {
284 Unspecified = 0,
285 Ascending = 1,
286 Descending = 2,
287}
288impl SortDirection {
289 pub fn as_str_name(&self) -> &'static str {
294 match self {
295 Self::Unspecified => "SORT_DIRECTION_UNSPECIFIED",
296 Self::Ascending => "SORT_DIRECTION_ASCENDING",
297 Self::Descending => "SORT_DIRECTION_DESCENDING",
298 }
299 }
300 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
302 match value {
303 "SORT_DIRECTION_UNSPECIFIED" => Some(Self::Unspecified),
304 "SORT_DIRECTION_ASCENDING" => Some(Self::Ascending),
305 "SORT_DIRECTION_DESCENDING" => Some(Self::Descending),
306 _ => None,
307 }
308 }
309}
310#[cfg(any(not(target_arch = "wasm32"), feature = "grpc_server_impls"))]
312pub mod message_api_server {
313 #![allow(
314 unused_variables,
315 dead_code,
316 missing_docs,
317 clippy::wildcard_imports,
318 clippy::let_unit_value,
319 )]
320 use tonic::codegen::*;
321 #[async_trait]
323 pub trait MessageApi: std::marker::Send + std::marker::Sync + 'static {
324 async fn publish(
326 &self,
327 request: tonic::Request<super::PublishRequest>,
328 ) -> std::result::Result<tonic::Response<super::PublishResponse>, tonic::Status>;
329 type SubscribeStream: tonic::codegen::tokio_stream::Stream<
331 Item = std::result::Result<super::Envelope, tonic::Status>,
332 >
333 + std::marker::Send
334 + 'static;
335 async fn subscribe(
337 &self,
338 request: tonic::Request<super::SubscribeRequest>,
339 ) -> std::result::Result<tonic::Response<Self::SubscribeStream>, tonic::Status>;
340 type Subscribe2Stream: tonic::codegen::tokio_stream::Stream<
342 Item = std::result::Result<super::Envelope, tonic::Status>,
343 >
344 + std::marker::Send
345 + 'static;
346 async fn subscribe2(
350 &self,
351 request: tonic::Request<tonic::Streaming<super::SubscribeRequest>>,
352 ) -> std::result::Result<tonic::Response<Self::Subscribe2Stream>, tonic::Status>;
353 type SubscribeAllStream: tonic::codegen::tokio_stream::Stream<
355 Item = std::result::Result<super::Envelope, tonic::Status>,
356 >
357 + std::marker::Send
358 + 'static;
359 async fn subscribe_all(
361 &self,
362 request: tonic::Request<super::SubscribeAllRequest>,
363 ) -> std::result::Result<
364 tonic::Response<Self::SubscribeAllStream>,
365 tonic::Status,
366 >;
367 async fn query(
369 &self,
370 request: tonic::Request<super::QueryRequest>,
371 ) -> std::result::Result<tonic::Response<super::QueryResponse>, tonic::Status>;
372 async fn batch_query(
374 &self,
375 request: tonic::Request<super::BatchQueryRequest>,
376 ) -> std::result::Result<
377 tonic::Response<super::BatchQueryResponse>,
378 tonic::Status,
379 >;
380 }
381 #[derive(Debug)]
383 pub struct MessageApiServer<T> {
384 inner: Arc<T>,
385 accept_compression_encodings: EnabledCompressionEncodings,
386 send_compression_encodings: EnabledCompressionEncodings,
387 max_decoding_message_size: Option<usize>,
388 max_encoding_message_size: Option<usize>,
389 }
390 impl<T> MessageApiServer<T> {
391 pub fn new(inner: T) -> Self {
392 Self::from_arc(Arc::new(inner))
393 }
394 pub fn from_arc(inner: Arc<T>) -> Self {
395 Self {
396 inner,
397 accept_compression_encodings: Default::default(),
398 send_compression_encodings: Default::default(),
399 max_decoding_message_size: None,
400 max_encoding_message_size: None,
401 }
402 }
403 pub fn with_interceptor<F>(
404 inner: T,
405 interceptor: F,
406 ) -> InterceptedService<Self, F>
407 where
408 F: tonic::service::Interceptor,
409 {
410 InterceptedService::new(Self::new(inner), interceptor)
411 }
412 #[must_use]
414 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
415 self.accept_compression_encodings.enable(encoding);
416 self
417 }
418 #[must_use]
420 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
421 self.send_compression_encodings.enable(encoding);
422 self
423 }
424 #[must_use]
428 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
429 self.max_decoding_message_size = Some(limit);
430 self
431 }
432 #[must_use]
436 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
437 self.max_encoding_message_size = Some(limit);
438 self
439 }
440 }
441 impl<T, B> tonic::codegen::Service<http::Request<B>> for MessageApiServer<T>
442 where
443 T: MessageApi,
444 B: Body + std::marker::Send + 'static,
445 B::Error: Into<StdError> + std::marker::Send + 'static,
446 {
447 type Response = http::Response<tonic::body::Body>;
448 type Error = std::convert::Infallible;
449 type Future = BoxFuture<Self::Response, Self::Error>;
450 fn poll_ready(
451 &mut self,
452 _cx: &mut Context<'_>,
453 ) -> Poll<std::result::Result<(), Self::Error>> {
454 Poll::Ready(Ok(()))
455 }
456 fn call(&mut self, req: http::Request<B>) -> Self::Future {
457 match req.uri().path() {
458 "/xmtp.message_api.v1.MessageApi/Publish" => {
459 #[allow(non_camel_case_types)]
460 struct PublishSvc<T: MessageApi>(pub Arc<T>);
461 impl<
462 T: MessageApi,
463 > tonic::server::UnaryService<super::PublishRequest>
464 for PublishSvc<T> {
465 type Response = super::PublishResponse;
466 type Future = BoxFuture<
467 tonic::Response<Self::Response>,
468 tonic::Status,
469 >;
470 fn call(
471 &mut self,
472 request: tonic::Request<super::PublishRequest>,
473 ) -> Self::Future {
474 let inner = Arc::clone(&self.0);
475 let fut = async move {
476 <T as MessageApi>::publish(&inner, request).await
477 };
478 Box::pin(fut)
479 }
480 }
481 let accept_compression_encodings = self.accept_compression_encodings;
482 let send_compression_encodings = self.send_compression_encodings;
483 let max_decoding_message_size = self.max_decoding_message_size;
484 let max_encoding_message_size = self.max_encoding_message_size;
485 let inner = self.inner.clone();
486 let fut = async move {
487 let method = PublishSvc(inner);
488 let codec = tonic_prost::ProstCodec::default();
489 let mut grpc = tonic::server::Grpc::new(codec)
490 .apply_compression_config(
491 accept_compression_encodings,
492 send_compression_encodings,
493 )
494 .apply_max_message_size_config(
495 max_decoding_message_size,
496 max_encoding_message_size,
497 );
498 let res = grpc.unary(method, req).await;
499 Ok(res)
500 };
501 Box::pin(fut)
502 }
503 "/xmtp.message_api.v1.MessageApi/Subscribe" => {
504 #[allow(non_camel_case_types)]
505 struct SubscribeSvc<T: MessageApi>(pub Arc<T>);
506 impl<
507 T: MessageApi,
508 > tonic::server::ServerStreamingService<super::SubscribeRequest>
509 for SubscribeSvc<T> {
510 type Response = super::Envelope;
511 type ResponseStream = T::SubscribeStream;
512 type Future = BoxFuture<
513 tonic::Response<Self::ResponseStream>,
514 tonic::Status,
515 >;
516 fn call(
517 &mut self,
518 request: tonic::Request<super::SubscribeRequest>,
519 ) -> Self::Future {
520 let inner = Arc::clone(&self.0);
521 let fut = async move {
522 <T as MessageApi>::subscribe(&inner, request).await
523 };
524 Box::pin(fut)
525 }
526 }
527 let accept_compression_encodings = self.accept_compression_encodings;
528 let send_compression_encodings = self.send_compression_encodings;
529 let max_decoding_message_size = self.max_decoding_message_size;
530 let max_encoding_message_size = self.max_encoding_message_size;
531 let inner = self.inner.clone();
532 let fut = async move {
533 let method = SubscribeSvc(inner);
534 let codec = tonic_prost::ProstCodec::default();
535 let mut grpc = tonic::server::Grpc::new(codec)
536 .apply_compression_config(
537 accept_compression_encodings,
538 send_compression_encodings,
539 )
540 .apply_max_message_size_config(
541 max_decoding_message_size,
542 max_encoding_message_size,
543 );
544 let res = grpc.server_streaming(method, req).await;
545 Ok(res)
546 };
547 Box::pin(fut)
548 }
549 "/xmtp.message_api.v1.MessageApi/Subscribe2" => {
550 #[allow(non_camel_case_types)]
551 struct Subscribe2Svc<T: MessageApi>(pub Arc<T>);
552 impl<
553 T: MessageApi,
554 > tonic::server::StreamingService<super::SubscribeRequest>
555 for Subscribe2Svc<T> {
556 type Response = super::Envelope;
557 type ResponseStream = T::Subscribe2Stream;
558 type Future = BoxFuture<
559 tonic::Response<Self::ResponseStream>,
560 tonic::Status,
561 >;
562 fn call(
563 &mut self,
564 request: tonic::Request<
565 tonic::Streaming<super::SubscribeRequest>,
566 >,
567 ) -> Self::Future {
568 let inner = Arc::clone(&self.0);
569 let fut = async move {
570 <T as MessageApi>::subscribe2(&inner, request).await
571 };
572 Box::pin(fut)
573 }
574 }
575 let accept_compression_encodings = self.accept_compression_encodings;
576 let send_compression_encodings = self.send_compression_encodings;
577 let max_decoding_message_size = self.max_decoding_message_size;
578 let max_encoding_message_size = self.max_encoding_message_size;
579 let inner = self.inner.clone();
580 let fut = async move {
581 let method = Subscribe2Svc(inner);
582 let codec = tonic_prost::ProstCodec::default();
583 let mut grpc = tonic::server::Grpc::new(codec)
584 .apply_compression_config(
585 accept_compression_encodings,
586 send_compression_encodings,
587 )
588 .apply_max_message_size_config(
589 max_decoding_message_size,
590 max_encoding_message_size,
591 );
592 let res = grpc.streaming(method, req).await;
593 Ok(res)
594 };
595 Box::pin(fut)
596 }
597 "/xmtp.message_api.v1.MessageApi/SubscribeAll" => {
598 #[allow(non_camel_case_types)]
599 struct SubscribeAllSvc<T: MessageApi>(pub Arc<T>);
600 impl<
601 T: MessageApi,
602 > tonic::server::ServerStreamingService<super::SubscribeAllRequest>
603 for SubscribeAllSvc<T> {
604 type Response = super::Envelope;
605 type ResponseStream = T::SubscribeAllStream;
606 type Future = BoxFuture<
607 tonic::Response<Self::ResponseStream>,
608 tonic::Status,
609 >;
610 fn call(
611 &mut self,
612 request: tonic::Request<super::SubscribeAllRequest>,
613 ) -> Self::Future {
614 let inner = Arc::clone(&self.0);
615 let fut = async move {
616 <T as MessageApi>::subscribe_all(&inner, request).await
617 };
618 Box::pin(fut)
619 }
620 }
621 let accept_compression_encodings = self.accept_compression_encodings;
622 let send_compression_encodings = self.send_compression_encodings;
623 let max_decoding_message_size = self.max_decoding_message_size;
624 let max_encoding_message_size = self.max_encoding_message_size;
625 let inner = self.inner.clone();
626 let fut = async move {
627 let method = SubscribeAllSvc(inner);
628 let codec = tonic_prost::ProstCodec::default();
629 let mut grpc = tonic::server::Grpc::new(codec)
630 .apply_compression_config(
631 accept_compression_encodings,
632 send_compression_encodings,
633 )
634 .apply_max_message_size_config(
635 max_decoding_message_size,
636 max_encoding_message_size,
637 );
638 let res = grpc.server_streaming(method, req).await;
639 Ok(res)
640 };
641 Box::pin(fut)
642 }
643 "/xmtp.message_api.v1.MessageApi/Query" => {
644 #[allow(non_camel_case_types)]
645 struct QuerySvc<T: MessageApi>(pub Arc<T>);
646 impl<T: MessageApi> tonic::server::UnaryService<super::QueryRequest>
647 for QuerySvc<T> {
648 type Response = super::QueryResponse;
649 type Future = BoxFuture<
650 tonic::Response<Self::Response>,
651 tonic::Status,
652 >;
653 fn call(
654 &mut self,
655 request: tonic::Request<super::QueryRequest>,
656 ) -> Self::Future {
657 let inner = Arc::clone(&self.0);
658 let fut = async move {
659 <T as MessageApi>::query(&inner, request).await
660 };
661 Box::pin(fut)
662 }
663 }
664 let accept_compression_encodings = self.accept_compression_encodings;
665 let send_compression_encodings = self.send_compression_encodings;
666 let max_decoding_message_size = self.max_decoding_message_size;
667 let max_encoding_message_size = self.max_encoding_message_size;
668 let inner = self.inner.clone();
669 let fut = async move {
670 let method = QuerySvc(inner);
671 let codec = tonic_prost::ProstCodec::default();
672 let mut grpc = tonic::server::Grpc::new(codec)
673 .apply_compression_config(
674 accept_compression_encodings,
675 send_compression_encodings,
676 )
677 .apply_max_message_size_config(
678 max_decoding_message_size,
679 max_encoding_message_size,
680 );
681 let res = grpc.unary(method, req).await;
682 Ok(res)
683 };
684 Box::pin(fut)
685 }
686 "/xmtp.message_api.v1.MessageApi/BatchQuery" => {
687 #[allow(non_camel_case_types)]
688 struct BatchQuerySvc<T: MessageApi>(pub Arc<T>);
689 impl<
690 T: MessageApi,
691 > tonic::server::UnaryService<super::BatchQueryRequest>
692 for BatchQuerySvc<T> {
693 type Response = super::BatchQueryResponse;
694 type Future = BoxFuture<
695 tonic::Response<Self::Response>,
696 tonic::Status,
697 >;
698 fn call(
699 &mut self,
700 request: tonic::Request<super::BatchQueryRequest>,
701 ) -> Self::Future {
702 let inner = Arc::clone(&self.0);
703 let fut = async move {
704 <T as MessageApi>::batch_query(&inner, request).await
705 };
706 Box::pin(fut)
707 }
708 }
709 let accept_compression_encodings = self.accept_compression_encodings;
710 let send_compression_encodings = self.send_compression_encodings;
711 let max_decoding_message_size = self.max_decoding_message_size;
712 let max_encoding_message_size = self.max_encoding_message_size;
713 let inner = self.inner.clone();
714 let fut = async move {
715 let method = BatchQuerySvc(inner);
716 let codec = tonic_prost::ProstCodec::default();
717 let mut grpc = tonic::server::Grpc::new(codec)
718 .apply_compression_config(
719 accept_compression_encodings,
720 send_compression_encodings,
721 )
722 .apply_max_message_size_config(
723 max_decoding_message_size,
724 max_encoding_message_size,
725 );
726 let res = grpc.unary(method, req).await;
727 Ok(res)
728 };
729 Box::pin(fut)
730 }
731 _ => {
732 Box::pin(async move {
733 let mut response = http::Response::new(
734 tonic::body::Body::default(),
735 );
736 let headers = response.headers_mut();
737 headers
738 .insert(
739 tonic::Status::GRPC_STATUS,
740 (tonic::Code::Unimplemented as i32).into(),
741 );
742 headers
743 .insert(
744 http::header::CONTENT_TYPE,
745 tonic::metadata::GRPC_CONTENT_TYPE,
746 );
747 Ok(response)
748 })
749 }
750 }
751 }
752 }
753 impl<T> Clone for MessageApiServer<T> {
754 fn clone(&self) -> Self {
755 let inner = self.inner.clone();
756 Self {
757 inner,
758 accept_compression_encodings: self.accept_compression_encodings,
759 send_compression_encodings: self.send_compression_encodings,
760 max_decoding_message_size: self.max_decoding_message_size,
761 max_encoding_message_size: self.max_encoding_message_size,
762 }
763 }
764 }
765 pub const SERVICE_NAME: &str = "xmtp.message_api.v1.MessageApi";
767 impl<T> tonic::server::NamedService for MessageApiServer<T> {
768 const NAME: &'static str = SERVICE_NAME;
769 }
770}