Skip to main content

xmtp_proto/gen/
xmtp.migration.api.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct FetchD14nCutoverResponse {
4    /// the unix timestamp at which point d14n becomes the canonical backend
5    #[prost(uint64, tag = "1")]
6    pub timestamp_ns: u64,
7}
8impl ::prost::Name for FetchD14nCutoverResponse {
9    const NAME: &'static str = "FetchD14nCutoverResponse";
10    const PACKAGE: &'static str = "xmtp.migration.api.v1";
11    fn full_name() -> ::prost::alloc::string::String {
12        "xmtp.migration.api.v1.FetchD14nCutoverResponse".into()
13    }
14    fn type_url() -> ::prost::alloc::string::String {
15        "/xmtp.migration.api.v1.FetchD14nCutoverResponse".into()
16    }
17}
18/// Generated server implementations.
19#[cfg(any(not(target_arch = "wasm32"), feature = "grpc_server_impls"))]
20pub mod d14n_migration_api_server {
21    #![allow(
22        unused_variables,
23        dead_code,
24        missing_docs,
25        clippy::wildcard_imports,
26        clippy::let_unit_value,
27    )]
28    use tonic::codegen::*;
29    /// Generated trait containing gRPC methods that should be implemented for use with D14nMigrationApiServer.
30    #[async_trait]
31    pub trait D14nMigrationApi: std::marker::Send + std::marker::Sync + 'static {
32        async fn fetch_d14n_cutover(
33            &self,
34            request: tonic::Request<::pbjson_types::Empty>,
35        ) -> std::result::Result<
36            tonic::Response<super::FetchD14nCutoverResponse>,
37            tonic::Status,
38        >;
39    }
40    #[derive(Debug)]
41    pub struct D14nMigrationApiServer<T> {
42        inner: Arc<T>,
43        accept_compression_encodings: EnabledCompressionEncodings,
44        send_compression_encodings: EnabledCompressionEncodings,
45        max_decoding_message_size: Option<usize>,
46        max_encoding_message_size: Option<usize>,
47    }
48    impl<T> D14nMigrationApiServer<T> {
49        pub fn new(inner: T) -> Self {
50            Self::from_arc(Arc::new(inner))
51        }
52        pub fn from_arc(inner: Arc<T>) -> Self {
53            Self {
54                inner,
55                accept_compression_encodings: Default::default(),
56                send_compression_encodings: Default::default(),
57                max_decoding_message_size: None,
58                max_encoding_message_size: None,
59            }
60        }
61        pub fn with_interceptor<F>(
62            inner: T,
63            interceptor: F,
64        ) -> InterceptedService<Self, F>
65        where
66            F: tonic::service::Interceptor,
67        {
68            InterceptedService::new(Self::new(inner), interceptor)
69        }
70        /// Enable decompressing requests with the given encoding.
71        #[must_use]
72        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
73            self.accept_compression_encodings.enable(encoding);
74            self
75        }
76        /// Compress responses with the given encoding, if the client supports it.
77        #[must_use]
78        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
79            self.send_compression_encodings.enable(encoding);
80            self
81        }
82        /// Limits the maximum size of a decoded message.
83        ///
84        /// Default: `4MB`
85        #[must_use]
86        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
87            self.max_decoding_message_size = Some(limit);
88            self
89        }
90        /// Limits the maximum size of an encoded message.
91        ///
92        /// Default: `usize::MAX`
93        #[must_use]
94        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
95            self.max_encoding_message_size = Some(limit);
96            self
97        }
98    }
99    impl<T, B> tonic::codegen::Service<http::Request<B>> for D14nMigrationApiServer<T>
100    where
101        T: D14nMigrationApi,
102        B: Body + std::marker::Send + 'static,
103        B::Error: Into<StdError> + std::marker::Send + 'static,
104    {
105        type Response = http::Response<tonic::body::Body>;
106        type Error = std::convert::Infallible;
107        type Future = BoxFuture<Self::Response, Self::Error>;
108        fn poll_ready(
109            &mut self,
110            _cx: &mut Context<'_>,
111        ) -> Poll<std::result::Result<(), Self::Error>> {
112            Poll::Ready(Ok(()))
113        }
114        fn call(&mut self, req: http::Request<B>) -> Self::Future {
115            match req.uri().path() {
116                "/xmtp.migration.api.v1.D14nMigrationApi/FetchD14nCutover" => {
117                    #[allow(non_camel_case_types)]
118                    struct FetchD14nCutoverSvc<T: D14nMigrationApi>(pub Arc<T>);
119                    impl<
120                        T: D14nMigrationApi,
121                    > tonic::server::UnaryService<::pbjson_types::Empty>
122                    for FetchD14nCutoverSvc<T> {
123                        type Response = super::FetchD14nCutoverResponse;
124                        type Future = BoxFuture<
125                            tonic::Response<Self::Response>,
126                            tonic::Status,
127                        >;
128                        fn call(
129                            &mut self,
130                            request: tonic::Request<::pbjson_types::Empty>,
131                        ) -> Self::Future {
132                            let inner = Arc::clone(&self.0);
133                            let fut = async move {
134                                <T as D14nMigrationApi>::fetch_d14n_cutover(&inner, request)
135                                    .await
136                            };
137                            Box::pin(fut)
138                        }
139                    }
140                    let accept_compression_encodings = self.accept_compression_encodings;
141                    let send_compression_encodings = self.send_compression_encodings;
142                    let max_decoding_message_size = self.max_decoding_message_size;
143                    let max_encoding_message_size = self.max_encoding_message_size;
144                    let inner = self.inner.clone();
145                    let fut = async move {
146                        let method = FetchD14nCutoverSvc(inner);
147                        let codec = tonic_prost::ProstCodec::default();
148                        let mut grpc = tonic::server::Grpc::new(codec)
149                            .apply_compression_config(
150                                accept_compression_encodings,
151                                send_compression_encodings,
152                            )
153                            .apply_max_message_size_config(
154                                max_decoding_message_size,
155                                max_encoding_message_size,
156                            );
157                        let res = grpc.unary(method, req).await;
158                        Ok(res)
159                    };
160                    Box::pin(fut)
161                }
162                _ => {
163                    Box::pin(async move {
164                        let mut response = http::Response::new(
165                            tonic::body::Body::default(),
166                        );
167                        let headers = response.headers_mut();
168                        headers
169                            .insert(
170                                tonic::Status::GRPC_STATUS,
171                                (tonic::Code::Unimplemented as i32).into(),
172                            );
173                        headers
174                            .insert(
175                                http::header::CONTENT_TYPE,
176                                tonic::metadata::GRPC_CONTENT_TYPE,
177                            );
178                        Ok(response)
179                    })
180                }
181            }
182        }
183    }
184    impl<T> Clone for D14nMigrationApiServer<T> {
185        fn clone(&self) -> Self {
186            let inner = self.inner.clone();
187            Self {
188                inner,
189                accept_compression_encodings: self.accept_compression_encodings,
190                send_compression_encodings: self.send_compression_encodings,
191                max_decoding_message_size: self.max_decoding_message_size,
192                max_encoding_message_size: self.max_encoding_message_size,
193            }
194        }
195    }
196    /// Generated gRPC service name
197    pub const SERVICE_NAME: &str = "xmtp.migration.api.v1.D14nMigrationApi";
198    impl<T> tonic::server::NamedService for D14nMigrationApiServer<T> {
199        const NAME: &'static str = SERVICE_NAME;
200    }
201}