avalanche_proto/gen/
messenger.tonic.rs1pub mod messenger_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 MessengerClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl MessengerClient<tonic::transport::Channel> {
12 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14 where
15 D: std::convert::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> MessengerClient<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 ) -> MessengerClient<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 MessengerClient::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 pub async fn notify(
72 &mut self,
73 request: impl tonic::IntoRequest<super::NotifyRequest>,
74 ) -> Result<tonic::Response<super::NotifyResponse>, tonic::Status> {
75 self.inner
76 .ready()
77 .await
78 .map_err(|e| {
79 tonic::Status::new(
80 tonic::Code::Unknown,
81 format!("Service was not ready: {}", e.into()),
82 )
83 })?;
84 let codec = tonic::codec::ProstCodec::default();
85 let path = http::uri::PathAndQuery::from_static(
86 "/messenger.Messenger/Notify",
87 );
88 self.inner.unary(request.into_request(), path, codec).await
89 }
90 }
91}
92pub mod messenger_server {
94 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
95 use tonic::codegen::*;
96 #[async_trait]
98 pub trait Messenger: Send + Sync + 'static {
99 async fn notify(
100 &self,
101 request: tonic::Request<super::NotifyRequest>,
102 ) -> Result<tonic::Response<super::NotifyResponse>, tonic::Status>;
103 }
104 #[derive(Debug)]
105 pub struct MessengerServer<T: Messenger> {
106 inner: _Inner<T>,
107 accept_compression_encodings: EnabledCompressionEncodings,
108 send_compression_encodings: EnabledCompressionEncodings,
109 }
110 struct _Inner<T>(Arc<T>);
111 impl<T: Messenger> MessengerServer<T> {
112 pub fn new(inner: T) -> Self {
113 Self::from_arc(Arc::new(inner))
114 }
115 pub fn from_arc(inner: Arc<T>) -> Self {
116 let inner = _Inner(inner);
117 Self {
118 inner,
119 accept_compression_encodings: Default::default(),
120 send_compression_encodings: Default::default(),
121 }
122 }
123 pub fn with_interceptor<F>(
124 inner: T,
125 interceptor: F,
126 ) -> InterceptedService<Self, F>
127 where
128 F: tonic::service::Interceptor,
129 {
130 InterceptedService::new(Self::new(inner), interceptor)
131 }
132 #[must_use]
134 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
135 self.accept_compression_encodings.enable(encoding);
136 self
137 }
138 #[must_use]
140 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
141 self.send_compression_encodings.enable(encoding);
142 self
143 }
144 }
145 impl<T, B> tonic::codegen::Service<http::Request<B>> for MessengerServer<T>
146 where
147 T: Messenger,
148 B: Body + Send + 'static,
149 B::Error: Into<StdError> + Send + 'static,
150 {
151 type Response = http::Response<tonic::body::BoxBody>;
152 type Error = std::convert::Infallible;
153 type Future = BoxFuture<Self::Response, Self::Error>;
154 fn poll_ready(
155 &mut self,
156 _cx: &mut Context<'_>,
157 ) -> Poll<Result<(), Self::Error>> {
158 Poll::Ready(Ok(()))
159 }
160 fn call(&mut self, req: http::Request<B>) -> Self::Future {
161 let inner = self.inner.clone();
162 match req.uri().path() {
163 "/messenger.Messenger/Notify" => {
164 #[allow(non_camel_case_types)]
165 struct NotifySvc<T: Messenger>(pub Arc<T>);
166 impl<T: Messenger> tonic::server::UnaryService<super::NotifyRequest>
167 for NotifySvc<T> {
168 type Response = super::NotifyResponse;
169 type Future = BoxFuture<
170 tonic::Response<Self::Response>,
171 tonic::Status,
172 >;
173 fn call(
174 &mut self,
175 request: tonic::Request<super::NotifyRequest>,
176 ) -> Self::Future {
177 let inner = self.0.clone();
178 let fut = async move { (*inner).notify(request).await };
179 Box::pin(fut)
180 }
181 }
182 let accept_compression_encodings = self.accept_compression_encodings;
183 let send_compression_encodings = self.send_compression_encodings;
184 let inner = self.inner.clone();
185 let fut = async move {
186 let inner = inner.0;
187 let method = NotifySvc(inner);
188 let codec = tonic::codec::ProstCodec::default();
189 let mut grpc = tonic::server::Grpc::new(codec)
190 .apply_compression_config(
191 accept_compression_encodings,
192 send_compression_encodings,
193 );
194 let res = grpc.unary(method, req).await;
195 Ok(res)
196 };
197 Box::pin(fut)
198 }
199 _ => {
200 Box::pin(async move {
201 Ok(
202 http::Response::builder()
203 .status(200)
204 .header("grpc-status", "12")
205 .header("content-type", "application/grpc")
206 .body(empty_body())
207 .unwrap(),
208 )
209 })
210 }
211 }
212 }
213 }
214 impl<T: Messenger> Clone for MessengerServer<T> {
215 fn clone(&self) -> Self {
216 let inner = self.inner.clone();
217 Self {
218 inner,
219 accept_compression_encodings: self.accept_compression_encodings,
220 send_compression_encodings: self.send_compression_encodings,
221 }
222 }
223 }
224 impl<T: Messenger> Clone for _Inner<T> {
225 fn clone(&self) -> Self {
226 Self(self.0.clone())
227 }
228 }
229 impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
230 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
231 write!(f, "{:?}", self.0)
232 }
233 }
234 impl<T: Messenger> tonic::server::NamedService for MessengerServer<T> {
235 const NAME: &'static str = "messenger.Messenger";
236 }
237}