1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct GenerateDisposableTokenRequest {
4 #[prost(message, optional, tag = "1")]
5 pub expires: ::core::option::Option<generate_disposable_token_request::Expires>,
6 #[prost(string, tag = "2")]
7 pub auth_token: ::prost::alloc::string::String,
8 #[prost(message, optional, tag = "3")]
9 pub permissions: ::core::option::Option<super::permission_messages::Permissions>,
10 #[prost(string, tag = "4")]
11 pub token_id: ::prost::alloc::string::String,
12}
13pub mod generate_disposable_token_request {
15 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
17 pub struct Expires {
18 #[prost(uint32, tag = "1")]
20 pub valid_for_seconds: u32,
21 }
22}
23#[derive(Clone, PartialEq, ::prost::Message)]
24pub struct GenerateDisposableTokenResponse {
25 #[prost(string, tag = "1")]
27 pub api_key: ::prost::alloc::string::String,
28 #[prost(string, tag = "2")]
30 pub endpoint: ::prost::alloc::string::String,
31 #[prost(uint64, tag = "3")]
33 pub valid_until: u64,
34}
35pub mod token_client {
37 #![allow(
38 unused_variables,
39 dead_code,
40 missing_docs,
41 clippy::wildcard_imports,
42 clippy::let_unit_value,
43 )]
44 use tonic::codegen::*;
45 use tonic::codegen::http::Uri;
46 #[derive(Debug, Clone)]
47 pub struct TokenClient<T> {
48 inner: tonic::client::Grpc<T>,
49 }
50 impl TokenClient<tonic::transport::Channel> {
51 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
53 where
54 D: TryInto<tonic::transport::Endpoint>,
55 D::Error: Into<StdError>,
56 {
57 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
58 Ok(Self::new(conn))
59 }
60 }
61 impl<T> TokenClient<T>
62 where
63 T: tonic::client::GrpcService<tonic::body::Body>,
64 T::Error: Into<StdError>,
65 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
66 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
67 {
68 pub fn new(inner: T) -> Self {
69 let inner = tonic::client::Grpc::new(inner);
70 Self { inner }
71 }
72 pub fn with_origin(inner: T, origin: Uri) -> Self {
73 let inner = tonic::client::Grpc::with_origin(inner, origin);
74 Self { inner }
75 }
76 pub fn with_interceptor<F>(
77 inner: T,
78 interceptor: F,
79 ) -> TokenClient<InterceptedService<T, F>>
80 where
81 F: tonic::service::Interceptor,
82 T::ResponseBody: Default,
83 T: tonic::codegen::Service<
84 http::Request<tonic::body::Body>,
85 Response = http::Response<
86 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
87 >,
88 >,
89 <T as tonic::codegen::Service<
90 http::Request<tonic::body::Body>,
91 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
92 {
93 TokenClient::new(InterceptedService::new(inner, interceptor))
94 }
95 #[must_use]
100 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
101 self.inner = self.inner.send_compressed(encoding);
102 self
103 }
104 #[must_use]
106 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
107 self.inner = self.inner.accept_compressed(encoding);
108 self
109 }
110 #[must_use]
114 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
115 self.inner = self.inner.max_decoding_message_size(limit);
116 self
117 }
118 #[must_use]
122 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
123 self.inner = self.inner.max_encoding_message_size(limit);
124 self
125 }
126 pub async fn generate_disposable_token(
127 &mut self,
128 request: impl tonic::IntoRequest<super::GenerateDisposableTokenRequest>,
129 ) -> std::result::Result<
130 tonic::Response<super::GenerateDisposableTokenResponse>,
131 tonic::Status,
132 > {
133 self.inner
134 .ready()
135 .await
136 .map_err(|e| {
137 tonic::Status::unknown(
138 format!("Service was not ready: {}", e.into()),
139 )
140 })?;
141 let codec = tonic::codec::ProstCodec::default();
142 let path = http::uri::PathAndQuery::from_static(
143 "/token.Token/GenerateDisposableToken",
144 );
145 let mut req = request.into_request();
146 req.extensions_mut()
147 .insert(GrpcMethod::new("token.Token", "GenerateDisposableToken"));
148 self.inner.unary(req, path, codec).await
149 }
150 }
151}
152pub mod token_server {
154 #![allow(
155 unused_variables,
156 dead_code,
157 missing_docs,
158 clippy::wildcard_imports,
159 clippy::let_unit_value,
160 )]
161 use tonic::codegen::*;
162 #[async_trait]
164 pub trait Token: std::marker::Send + std::marker::Sync + 'static {
165 async fn generate_disposable_token(
166 &self,
167 request: tonic::Request<super::GenerateDisposableTokenRequest>,
168 ) -> std::result::Result<
169 tonic::Response<super::GenerateDisposableTokenResponse>,
170 tonic::Status,
171 >;
172 }
173 #[derive(Debug)]
174 pub struct TokenServer<T> {
175 inner: Arc<T>,
176 accept_compression_encodings: EnabledCompressionEncodings,
177 send_compression_encodings: EnabledCompressionEncodings,
178 max_decoding_message_size: Option<usize>,
179 max_encoding_message_size: Option<usize>,
180 }
181 impl<T> TokenServer<T> {
182 pub fn new(inner: T) -> Self {
183 Self::from_arc(Arc::new(inner))
184 }
185 pub fn from_arc(inner: Arc<T>) -> Self {
186 Self {
187 inner,
188 accept_compression_encodings: Default::default(),
189 send_compression_encodings: Default::default(),
190 max_decoding_message_size: None,
191 max_encoding_message_size: None,
192 }
193 }
194 pub fn with_interceptor<F>(
195 inner: T,
196 interceptor: F,
197 ) -> InterceptedService<Self, F>
198 where
199 F: tonic::service::Interceptor,
200 {
201 InterceptedService::new(Self::new(inner), interceptor)
202 }
203 #[must_use]
205 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
206 self.accept_compression_encodings.enable(encoding);
207 self
208 }
209 #[must_use]
211 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
212 self.send_compression_encodings.enable(encoding);
213 self
214 }
215 #[must_use]
219 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
220 self.max_decoding_message_size = Some(limit);
221 self
222 }
223 #[must_use]
227 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
228 self.max_encoding_message_size = Some(limit);
229 self
230 }
231 }
232 impl<T, B> tonic::codegen::Service<http::Request<B>> for TokenServer<T>
233 where
234 T: Token,
235 B: Body + std::marker::Send + 'static,
236 B::Error: Into<StdError> + std::marker::Send + 'static,
237 {
238 type Response = http::Response<tonic::body::Body>;
239 type Error = std::convert::Infallible;
240 type Future = BoxFuture<Self::Response, Self::Error>;
241 fn poll_ready(
242 &mut self,
243 _cx: &mut Context<'_>,
244 ) -> Poll<std::result::Result<(), Self::Error>> {
245 Poll::Ready(Ok(()))
246 }
247 fn call(&mut self, req: http::Request<B>) -> Self::Future {
248 match req.uri().path() {
249 "/token.Token/GenerateDisposableToken" => {
250 #[allow(non_camel_case_types)]
251 struct GenerateDisposableTokenSvc<T: Token>(pub Arc<T>);
252 impl<
253 T: Token,
254 > tonic::server::UnaryService<super::GenerateDisposableTokenRequest>
255 for GenerateDisposableTokenSvc<T> {
256 type Response = super::GenerateDisposableTokenResponse;
257 type Future = BoxFuture<
258 tonic::Response<Self::Response>,
259 tonic::Status,
260 >;
261 fn call(
262 &mut self,
263 request: tonic::Request<
264 super::GenerateDisposableTokenRequest,
265 >,
266 ) -> Self::Future {
267 let inner = Arc::clone(&self.0);
268 let fut = async move {
269 <T as Token>::generate_disposable_token(&inner, request)
270 .await
271 };
272 Box::pin(fut)
273 }
274 }
275 let accept_compression_encodings = self.accept_compression_encodings;
276 let send_compression_encodings = self.send_compression_encodings;
277 let max_decoding_message_size = self.max_decoding_message_size;
278 let max_encoding_message_size = self.max_encoding_message_size;
279 let inner = self.inner.clone();
280 let fut = async move {
281 let method = GenerateDisposableTokenSvc(inner);
282 let codec = tonic::codec::ProstCodec::default();
283 let mut grpc = tonic::server::Grpc::new(codec)
284 .apply_compression_config(
285 accept_compression_encodings,
286 send_compression_encodings,
287 )
288 .apply_max_message_size_config(
289 max_decoding_message_size,
290 max_encoding_message_size,
291 );
292 let res = grpc.unary(method, req).await;
293 Ok(res)
294 };
295 Box::pin(fut)
296 }
297 _ => {
298 Box::pin(async move {
299 let mut response = http::Response::new(
300 tonic::body::Body::default(),
301 );
302 let headers = response.headers_mut();
303 headers
304 .insert(
305 tonic::Status::GRPC_STATUS,
306 (tonic::Code::Unimplemented as i32).into(),
307 );
308 headers
309 .insert(
310 http::header::CONTENT_TYPE,
311 tonic::metadata::GRPC_CONTENT_TYPE,
312 );
313 Ok(response)
314 })
315 }
316 }
317 }
318 }
319 impl<T> Clone for TokenServer<T> {
320 fn clone(&self) -> Self {
321 let inner = self.inner.clone();
322 Self {
323 inner,
324 accept_compression_encodings: self.accept_compression_encodings,
325 send_compression_encodings: self.send_compression_encodings,
326 max_decoding_message_size: self.max_decoding_message_size,
327 max_encoding_message_size: self.max_encoding_message_size,
328 }
329 }
330 }
331 pub const SERVICE_NAME: &str = "token.Token";
333 impl<T> tonic::server::NamedService for TokenServer<T> {
334 const NAME: &'static str = SERVICE_NAME;
335 }
336}