1#[derive(prost_helpers::AnyPB)]
4#[derive(Clone, PartialEq, ::prost::Message)]
5pub struct AuthInfo {
6 #[prost(enumeration = "auth_info::EncryptionType", tag = "1")]
7 pub encryption_type: i32,
8 #[prost(bytes = "vec", tag = "2")]
9 pub encrypted_value: ::prost::alloc::vec::Vec<u8>,
10 #[prost(map = "string, string", tag = "3")]
11 pub metadata: ::std::collections::HashMap<
12 ::prost::alloc::string::String,
13 ::prost::alloc::string::String,
14 >,
15}
16pub mod auth_info {
18 #[derive(prost_helpers::AnyPB)]
19 #[derive(
20 Clone,
21 Copy,
22 Debug,
23 PartialEq,
24 Eq,
25 Hash,
26 PartialOrd,
27 Ord,
28 ::prost::Enumeration
29 )]
30 #[repr(i32)]
31 pub enum EncryptionType {
32 Unspecified = 0,
33 Plaintext = 1,
34 Sha256 = 2,
35 Md5 = 3,
36 Oauth = 4,
37 }
38 impl EncryptionType {
39 pub fn as_str_name(&self) -> &'static str {
44 match self {
45 Self::Unspecified => "UNSPECIFIED",
46 Self::Plaintext => "PLAINTEXT",
47 Self::Sha256 => "SHA256",
48 Self::Md5 => "MD5",
49 Self::Oauth => "OAUTH",
50 }
51 }
52 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
54 match value {
55 "UNSPECIFIED" => Some(Self::Unspecified),
56 "PLAINTEXT" => Some(Self::Plaintext),
57 "SHA256" => Some(Self::Sha256),
58 "MD5" => Some(Self::Md5),
59 "OAUTH" => Some(Self::Oauth),
60 _ => None,
61 }
62 }
63 }
64}
65#[derive(prost_helpers::AnyPB)]
67#[derive(Clone, PartialEq, ::prost::Message)]
68pub struct UserInfo {
69 #[prost(uint32, tag = "1")]
70 pub id: u32,
71 #[prost(string, tag = "2")]
72 pub name: ::prost::alloc::string::String,
73 #[prost(bool, tag = "3")]
74 pub is_super: bool,
75 #[prost(bool, tag = "4")]
76 pub can_create_db: bool,
77 #[prost(bool, tag = "5")]
78 pub can_create_user: bool,
79 #[prost(bool, tag = "6")]
80 pub can_login: bool,
81 #[prost(message, optional, tag = "7")]
82 pub auth_info: ::core::option::Option<AuthInfo>,
83 #[prost(message, repeated, tag = "8")]
85 pub grant_privileges: ::prost::alloc::vec::Vec<GrantPrivilege>,
86}
87#[derive(prost_helpers::AnyPB)]
89#[derive(Clone, PartialEq, ::prost::Message)]
90pub struct GrantPrivilege {
91 #[prost(message, repeated, tag = "20")]
92 pub action_with_opts: ::prost::alloc::vec::Vec<
93 grant_privilege::ActionWithGrantOption,
94 >,
95 #[prost(oneof = "grant_privilege::Object", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10")]
96 pub object: ::core::option::Option<grant_privilege::Object>,
97}
98pub mod grant_privilege {
100 #[derive(prost_helpers::AnyPB)]
101 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
102 pub struct ActionWithGrantOption {
103 #[prost(enumeration = "super::Action", tag = "1")]
104 pub action: i32,
105 #[prost(bool, tag = "2")]
106 pub with_grant_option: bool,
107 #[prost(uint32, tag = "3")]
108 pub granted_by: u32,
109 }
110 #[derive(prost_helpers::AnyPB)]
111 #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
112 pub enum Object {
113 #[prost(uint32, tag = "1")]
114 DatabaseId(u32),
115 #[prost(uint32, tag = "2")]
116 SchemaId(u32),
117 #[prost(uint32, tag = "3")]
118 TableId(u32),
119 #[prost(uint32, tag = "4")]
120 SourceId(u32),
121 #[prost(uint32, tag = "5")]
122 SinkId(u32),
123 #[prost(uint32, tag = "6")]
124 ViewId(u32),
125 #[prost(uint32, tag = "7")]
126 FunctionId(u32),
127 #[prost(uint32, tag = "8")]
128 SubscriptionId(u32),
129 #[prost(uint32, tag = "9")]
130 ConnectionId(u32),
131 #[prost(uint32, tag = "10")]
132 SecretId(u32),
133 }
134}
135#[derive(prost_helpers::AnyPB)]
136#[derive(Clone, PartialEq, ::prost::Message)]
137pub struct CreateUserRequest {
138 #[prost(message, optional, tag = "1")]
139 pub user: ::core::option::Option<UserInfo>,
140}
141#[derive(prost_helpers::AnyPB)]
142#[derive(Clone, PartialEq, ::prost::Message)]
143pub struct CreateUserResponse {
144 #[prost(message, optional, tag = "1")]
145 pub status: ::core::option::Option<super::common::Status>,
146 #[prost(uint64, tag = "2")]
147 pub version: u64,
148}
149#[derive(prost_helpers::AnyPB)]
150#[derive(Clone, Copy, PartialEq, ::prost::Message)]
151pub struct DropUserRequest {
152 #[prost(uint32, tag = "1")]
153 pub user_id: u32,
154}
155#[derive(prost_helpers::AnyPB)]
156#[derive(Clone, PartialEq, ::prost::Message)]
157pub struct DropUserResponse {
158 #[prost(message, optional, tag = "1")]
159 pub status: ::core::option::Option<super::common::Status>,
160 #[prost(uint64, tag = "2")]
161 pub version: u64,
162}
163#[derive(prost_helpers::AnyPB)]
164#[derive(Clone, PartialEq, ::prost::Message)]
165pub struct UpdateUserRequest {
166 #[prost(message, optional, tag = "1")]
167 pub user: ::core::option::Option<UserInfo>,
168 #[prost(enumeration = "update_user_request::UpdateField", repeated, tag = "2")]
169 pub update_fields: ::prost::alloc::vec::Vec<i32>,
170}
171pub mod update_user_request {
173 #[derive(prost_helpers::AnyPB)]
174 #[derive(
175 Clone,
176 Copy,
177 Debug,
178 PartialEq,
179 Eq,
180 Hash,
181 PartialOrd,
182 Ord,
183 ::prost::Enumeration
184 )]
185 #[repr(i32)]
186 pub enum UpdateField {
187 Unspecified = 0,
188 Super = 1,
189 Login = 2,
190 CreateDb = 3,
191 AuthInfo = 4,
192 Rename = 5,
193 CreateUser = 6,
194 }
195 impl UpdateField {
196 pub fn as_str_name(&self) -> &'static str {
201 match self {
202 Self::Unspecified => "UNSPECIFIED",
203 Self::Super => "SUPER",
204 Self::Login => "LOGIN",
205 Self::CreateDb => "CREATE_DB",
206 Self::AuthInfo => "AUTH_INFO",
207 Self::Rename => "RENAME",
208 Self::CreateUser => "CREATE_USER",
209 }
210 }
211 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
213 match value {
214 "UNSPECIFIED" => Some(Self::Unspecified),
215 "SUPER" => Some(Self::Super),
216 "LOGIN" => Some(Self::Login),
217 "CREATE_DB" => Some(Self::CreateDb),
218 "AUTH_INFO" => Some(Self::AuthInfo),
219 "RENAME" => Some(Self::Rename),
220 "CREATE_USER" => Some(Self::CreateUser),
221 _ => None,
222 }
223 }
224 }
225}
226#[derive(prost_helpers::AnyPB)]
227#[derive(Clone, PartialEq, ::prost::Message)]
228pub struct UpdateUserResponse {
229 #[prost(message, optional, tag = "1")]
230 pub status: ::core::option::Option<super::common::Status>,
231 #[prost(uint64, tag = "2")]
232 pub version: u64,
233}
234#[derive(prost_helpers::AnyPB)]
235#[derive(Clone, PartialEq, ::prost::Message)]
236pub struct GrantPrivilegeRequest {
237 #[prost(uint32, repeated, tag = "1")]
238 pub user_ids: ::prost::alloc::vec::Vec<u32>,
239 #[prost(message, repeated, tag = "2")]
240 pub privileges: ::prost::alloc::vec::Vec<GrantPrivilege>,
241 #[prost(bool, tag = "3")]
242 pub with_grant_option: bool,
243 #[prost(uint32, tag = "4")]
244 pub granted_by: u32,
245}
246#[derive(prost_helpers::AnyPB)]
247#[derive(Clone, PartialEq, ::prost::Message)]
248pub struct GrantPrivilegeResponse {
249 #[prost(message, optional, tag = "1")]
250 pub status: ::core::option::Option<super::common::Status>,
251 #[prost(uint64, tag = "2")]
252 pub version: u64,
253}
254#[derive(prost_helpers::AnyPB)]
255#[derive(Clone, PartialEq, ::prost::Message)]
256pub struct RevokePrivilegeRequest {
257 #[prost(uint32, repeated, tag = "1")]
258 pub user_ids: ::prost::alloc::vec::Vec<u32>,
259 #[prost(message, repeated, tag = "2")]
260 pub privileges: ::prost::alloc::vec::Vec<GrantPrivilege>,
261 #[prost(uint32, tag = "3")]
262 pub granted_by: u32,
263 #[prost(uint32, tag = "4")]
264 pub revoke_by: u32,
265 #[prost(bool, tag = "5")]
266 pub revoke_grant_option: bool,
267 #[prost(bool, tag = "6")]
268 pub cascade: bool,
269}
270#[derive(prost_helpers::AnyPB)]
271#[derive(Clone, PartialEq, ::prost::Message)]
272pub struct RevokePrivilegeResponse {
273 #[prost(message, optional, tag = "1")]
274 pub status: ::core::option::Option<super::common::Status>,
275 #[prost(uint64, tag = "2")]
276 pub version: u64,
277}
278#[derive(prost_helpers::AnyPB)]
279#[derive(Clone, PartialEq, ::prost::Message)]
280pub struct AlterDefaultPrivilegeRequest {
281 #[prost(uint32, repeated, tag = "1")]
282 pub user_ids: ::prost::alloc::vec::Vec<u32>,
283 #[prost(uint32, tag = "2")]
284 pub database_id: u32,
285 #[prost(uint32, repeated, tag = "3")]
286 pub schema_ids: ::prost::alloc::vec::Vec<u32>,
287 #[prost(uint32, tag = "6")]
288 pub granted_by: u32,
289 #[prost(oneof = "alter_default_privilege_request::Operation", tags = "4, 5")]
290 pub operation: ::core::option::Option<alter_default_privilege_request::Operation>,
291}
292pub mod alter_default_privilege_request {
294 #[derive(prost_helpers::AnyPB)]
295 #[derive(Clone, PartialEq, ::prost::Message)]
296 pub struct GrantPrivilege {
297 #[prost(enumeration = "super::Action", repeated, tag = "1")]
298 pub actions: ::prost::alloc::vec::Vec<i32>,
299 #[prost(enumeration = "super::super::common::ObjectType", tag = "2")]
300 pub object_type: i32,
301 #[prost(uint32, repeated, tag = "3")]
302 pub grantees: ::prost::alloc::vec::Vec<u32>,
303 #[prost(bool, tag = "4")]
304 pub with_grant_option: bool,
305 }
306 #[derive(prost_helpers::AnyPB)]
307 #[derive(Clone, PartialEq, ::prost::Message)]
308 pub struct RevokePrivilege {
309 #[prost(enumeration = "super::Action", repeated, tag = "1")]
310 pub actions: ::prost::alloc::vec::Vec<i32>,
311 #[prost(enumeration = "super::super::common::ObjectType", tag = "2")]
312 pub object_type: i32,
313 #[prost(uint32, repeated, tag = "3")]
314 pub grantees: ::prost::alloc::vec::Vec<u32>,
315 #[prost(bool, tag = "4")]
316 pub revoke_grant_option: bool,
317 }
318 #[derive(prost_helpers::AnyPB)]
319 #[derive(Clone, PartialEq, ::prost::Oneof)]
320 pub enum Operation {
321 #[prost(message, tag = "4")]
322 GrantPrivilege(GrantPrivilege),
323 #[prost(message, tag = "5")]
324 RevokePrivilege(RevokePrivilege),
325 }
326}
327#[derive(prost_helpers::AnyPB)]
328#[derive(Clone, PartialEq, ::prost::Message)]
329pub struct AlterDefaultPrivilegeResponse {
330 #[prost(message, optional, tag = "1")]
331 pub status: ::core::option::Option<super::common::Status>,
332}
333#[derive(prost_helpers::AnyPB)]
334#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
335#[repr(i32)]
336pub enum Action {
337 Unspecified = 0,
338 Select = 1,
339 Insert = 2,
340 Update = 3,
341 Delete = 4,
342 Create = 5,
343 Connect = 6,
344 Usage = 7,
345 Execute = 8,
346}
347impl Action {
348 pub fn as_str_name(&self) -> &'static str {
353 match self {
354 Self::Unspecified => "UNSPECIFIED",
355 Self::Select => "SELECT",
356 Self::Insert => "INSERT",
357 Self::Update => "UPDATE",
358 Self::Delete => "DELETE",
359 Self::Create => "CREATE",
360 Self::Connect => "CONNECT",
361 Self::Usage => "USAGE",
362 Self::Execute => "EXECUTE",
363 }
364 }
365 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
367 match value {
368 "UNSPECIFIED" => Some(Self::Unspecified),
369 "SELECT" => Some(Self::Select),
370 "INSERT" => Some(Self::Insert),
371 "UPDATE" => Some(Self::Update),
372 "DELETE" => Some(Self::Delete),
373 "CREATE" => Some(Self::Create),
374 "CONNECT" => Some(Self::Connect),
375 "USAGE" => Some(Self::Usage),
376 "EXECUTE" => Some(Self::Execute),
377 _ => None,
378 }
379 }
380}
381pub mod user_service_client {
383 #![allow(
384 unused_variables,
385 dead_code,
386 missing_docs,
387 clippy::wildcard_imports,
388 clippy::let_unit_value,
389 )]
390 use tonic::codegen::*;
391 use tonic::codegen::http::Uri;
392 #[derive(Debug, Clone)]
393 pub struct UserServiceClient<T> {
394 inner: tonic::client::Grpc<T>,
395 }
396 impl UserServiceClient<tonic::transport::Channel> {
397 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
399 where
400 D: TryInto<tonic::transport::Endpoint>,
401 D::Error: Into<StdError>,
402 {
403 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
404 Ok(Self::new(conn))
405 }
406 }
407 impl<T> UserServiceClient<T>
408 where
409 T: tonic::client::GrpcService<tonic::body::BoxBody>,
410 T::Error: Into<StdError>,
411 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
412 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
413 {
414 pub fn new(inner: T) -> Self {
415 let inner = tonic::client::Grpc::new(inner);
416 Self { inner }
417 }
418 pub fn with_origin(inner: T, origin: Uri) -> Self {
419 let inner = tonic::client::Grpc::with_origin(inner, origin);
420 Self { inner }
421 }
422 pub fn with_interceptor<F>(
423 inner: T,
424 interceptor: F,
425 ) -> UserServiceClient<InterceptedService<T, F>>
426 where
427 F: tonic::service::Interceptor,
428 T::ResponseBody: Default,
429 T: tonic::codegen::Service<
430 http::Request<tonic::body::BoxBody>,
431 Response = http::Response<
432 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
433 >,
434 >,
435 <T as tonic::codegen::Service<
436 http::Request<tonic::body::BoxBody>,
437 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
438 {
439 UserServiceClient::new(InterceptedService::new(inner, interceptor))
440 }
441 #[must_use]
446 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
447 self.inner = self.inner.send_compressed(encoding);
448 self
449 }
450 #[must_use]
452 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
453 self.inner = self.inner.accept_compressed(encoding);
454 self
455 }
456 #[must_use]
460 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
461 self.inner = self.inner.max_decoding_message_size(limit);
462 self
463 }
464 #[must_use]
468 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
469 self.inner = self.inner.max_encoding_message_size(limit);
470 self
471 }
472 pub async fn create_user(
473 &mut self,
474 request: impl tonic::IntoRequest<super::CreateUserRequest>,
475 ) -> std::result::Result<
476 tonic::Response<super::CreateUserResponse>,
477 tonic::Status,
478 > {
479 self.inner
480 .ready()
481 .await
482 .map_err(|e| {
483 tonic::Status::unknown(
484 format!("Service was not ready: {}", e.into()),
485 )
486 })?;
487 let codec = tonic::codec::ProstCodec::default();
488 let path = http::uri::PathAndQuery::from_static(
489 "/user.UserService/CreateUser",
490 );
491 let mut req = request.into_request();
492 req.extensions_mut()
493 .insert(GrpcMethod::new("user.UserService", "CreateUser"));
494 self.inner.unary(req, path, codec).await
495 }
496 pub async fn drop_user(
497 &mut self,
498 request: impl tonic::IntoRequest<super::DropUserRequest>,
499 ) -> std::result::Result<
500 tonic::Response<super::DropUserResponse>,
501 tonic::Status,
502 > {
503 self.inner
504 .ready()
505 .await
506 .map_err(|e| {
507 tonic::Status::unknown(
508 format!("Service was not ready: {}", e.into()),
509 )
510 })?;
511 let codec = tonic::codec::ProstCodec::default();
512 let path = http::uri::PathAndQuery::from_static(
513 "/user.UserService/DropUser",
514 );
515 let mut req = request.into_request();
516 req.extensions_mut().insert(GrpcMethod::new("user.UserService", "DropUser"));
517 self.inner.unary(req, path, codec).await
518 }
519 pub async fn update_user(
520 &mut self,
521 request: impl tonic::IntoRequest<super::UpdateUserRequest>,
522 ) -> std::result::Result<
523 tonic::Response<super::UpdateUserResponse>,
524 tonic::Status,
525 > {
526 self.inner
527 .ready()
528 .await
529 .map_err(|e| {
530 tonic::Status::unknown(
531 format!("Service was not ready: {}", e.into()),
532 )
533 })?;
534 let codec = tonic::codec::ProstCodec::default();
535 let path = http::uri::PathAndQuery::from_static(
536 "/user.UserService/UpdateUser",
537 );
538 let mut req = request.into_request();
539 req.extensions_mut()
540 .insert(GrpcMethod::new("user.UserService", "UpdateUser"));
541 self.inner.unary(req, path, codec).await
542 }
543 pub async fn grant_privilege(
545 &mut self,
546 request: impl tonic::IntoRequest<super::GrantPrivilegeRequest>,
547 ) -> std::result::Result<
548 tonic::Response<super::GrantPrivilegeResponse>,
549 tonic::Status,
550 > {
551 self.inner
552 .ready()
553 .await
554 .map_err(|e| {
555 tonic::Status::unknown(
556 format!("Service was not ready: {}", e.into()),
557 )
558 })?;
559 let codec = tonic::codec::ProstCodec::default();
560 let path = http::uri::PathAndQuery::from_static(
561 "/user.UserService/GrantPrivilege",
562 );
563 let mut req = request.into_request();
564 req.extensions_mut()
565 .insert(GrpcMethod::new("user.UserService", "GrantPrivilege"));
566 self.inner.unary(req, path, codec).await
567 }
568 pub async fn revoke_privilege(
570 &mut self,
571 request: impl tonic::IntoRequest<super::RevokePrivilegeRequest>,
572 ) -> std::result::Result<
573 tonic::Response<super::RevokePrivilegeResponse>,
574 tonic::Status,
575 > {
576 self.inner
577 .ready()
578 .await
579 .map_err(|e| {
580 tonic::Status::unknown(
581 format!("Service was not ready: {}", e.into()),
582 )
583 })?;
584 let codec = tonic::codec::ProstCodec::default();
585 let path = http::uri::PathAndQuery::from_static(
586 "/user.UserService/RevokePrivilege",
587 );
588 let mut req = request.into_request();
589 req.extensions_mut()
590 .insert(GrpcMethod::new("user.UserService", "RevokePrivilege"));
591 self.inner.unary(req, path, codec).await
592 }
593 pub async fn alter_default_privilege(
595 &mut self,
596 request: impl tonic::IntoRequest<super::AlterDefaultPrivilegeRequest>,
597 ) -> std::result::Result<
598 tonic::Response<super::AlterDefaultPrivilegeResponse>,
599 tonic::Status,
600 > {
601 self.inner
602 .ready()
603 .await
604 .map_err(|e| {
605 tonic::Status::unknown(
606 format!("Service was not ready: {}", e.into()),
607 )
608 })?;
609 let codec = tonic::codec::ProstCodec::default();
610 let path = http::uri::PathAndQuery::from_static(
611 "/user.UserService/AlterDefaultPrivilege",
612 );
613 let mut req = request.into_request();
614 req.extensions_mut()
615 .insert(GrpcMethod::new("user.UserService", "AlterDefaultPrivilege"));
616 self.inner.unary(req, path, codec).await
617 }
618 }
619}
620pub mod user_service_server {
622 #![allow(
623 unused_variables,
624 dead_code,
625 missing_docs,
626 clippy::wildcard_imports,
627 clippy::let_unit_value,
628 )]
629 use tonic::codegen::*;
630 #[async_trait]
632 pub trait UserService: std::marker::Send + std::marker::Sync + 'static {
633 async fn create_user(
634 &self,
635 request: tonic::Request<super::CreateUserRequest>,
636 ) -> std::result::Result<
637 tonic::Response<super::CreateUserResponse>,
638 tonic::Status,
639 >;
640 async fn drop_user(
641 &self,
642 request: tonic::Request<super::DropUserRequest>,
643 ) -> std::result::Result<
644 tonic::Response<super::DropUserResponse>,
645 tonic::Status,
646 >;
647 async fn update_user(
648 &self,
649 request: tonic::Request<super::UpdateUserRequest>,
650 ) -> std::result::Result<
651 tonic::Response<super::UpdateUserResponse>,
652 tonic::Status,
653 >;
654 async fn grant_privilege(
656 &self,
657 request: tonic::Request<super::GrantPrivilegeRequest>,
658 ) -> std::result::Result<
659 tonic::Response<super::GrantPrivilegeResponse>,
660 tonic::Status,
661 >;
662 async fn revoke_privilege(
664 &self,
665 request: tonic::Request<super::RevokePrivilegeRequest>,
666 ) -> std::result::Result<
667 tonic::Response<super::RevokePrivilegeResponse>,
668 tonic::Status,
669 >;
670 async fn alter_default_privilege(
672 &self,
673 request: tonic::Request<super::AlterDefaultPrivilegeRequest>,
674 ) -> std::result::Result<
675 tonic::Response<super::AlterDefaultPrivilegeResponse>,
676 tonic::Status,
677 >;
678 }
679 #[derive(Debug)]
680 pub struct UserServiceServer<T> {
681 inner: Arc<T>,
682 accept_compression_encodings: EnabledCompressionEncodings,
683 send_compression_encodings: EnabledCompressionEncodings,
684 max_decoding_message_size: Option<usize>,
685 max_encoding_message_size: Option<usize>,
686 }
687 impl<T> UserServiceServer<T> {
688 pub fn new(inner: T) -> Self {
689 Self::from_arc(Arc::new(inner))
690 }
691 pub fn from_arc(inner: Arc<T>) -> Self {
692 Self {
693 inner,
694 accept_compression_encodings: Default::default(),
695 send_compression_encodings: Default::default(),
696 max_decoding_message_size: None,
697 max_encoding_message_size: None,
698 }
699 }
700 pub fn with_interceptor<F>(
701 inner: T,
702 interceptor: F,
703 ) -> InterceptedService<Self, F>
704 where
705 F: tonic::service::Interceptor,
706 {
707 InterceptedService::new(Self::new(inner), interceptor)
708 }
709 #[must_use]
711 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
712 self.accept_compression_encodings.enable(encoding);
713 self
714 }
715 #[must_use]
717 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
718 self.send_compression_encodings.enable(encoding);
719 self
720 }
721 #[must_use]
725 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
726 self.max_decoding_message_size = Some(limit);
727 self
728 }
729 #[must_use]
733 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
734 self.max_encoding_message_size = Some(limit);
735 self
736 }
737 }
738 impl<T, B> tonic::codegen::Service<http::Request<B>> for UserServiceServer<T>
739 where
740 T: UserService,
741 B: Body + std::marker::Send + 'static,
742 B::Error: Into<StdError> + std::marker::Send + 'static,
743 {
744 type Response = http::Response<tonic::body::BoxBody>;
745 type Error = std::convert::Infallible;
746 type Future = BoxFuture<Self::Response, Self::Error>;
747 fn poll_ready(
748 &mut self,
749 _cx: &mut Context<'_>,
750 ) -> Poll<std::result::Result<(), Self::Error>> {
751 Poll::Ready(Ok(()))
752 }
753 fn call(&mut self, req: http::Request<B>) -> Self::Future {
754 match req.uri().path() {
755 "/user.UserService/CreateUser" => {
756 #[allow(non_camel_case_types)]
757 struct CreateUserSvc<T: UserService>(pub Arc<T>);
758 impl<
759 T: UserService,
760 > tonic::server::UnaryService<super::CreateUserRequest>
761 for CreateUserSvc<T> {
762 type Response = super::CreateUserResponse;
763 type Future = BoxFuture<
764 tonic::Response<Self::Response>,
765 tonic::Status,
766 >;
767 fn call(
768 &mut self,
769 request: tonic::Request<super::CreateUserRequest>,
770 ) -> Self::Future {
771 let inner = Arc::clone(&self.0);
772 let fut = async move {
773 <T as UserService>::create_user(&inner, request).await
774 };
775 Box::pin(fut)
776 }
777 }
778 let accept_compression_encodings = self.accept_compression_encodings;
779 let send_compression_encodings = self.send_compression_encodings;
780 let max_decoding_message_size = self.max_decoding_message_size;
781 let max_encoding_message_size = self.max_encoding_message_size;
782 let inner = self.inner.clone();
783 let fut = async move {
784 let method = CreateUserSvc(inner);
785 let codec = tonic::codec::ProstCodec::default();
786 let mut grpc = tonic::server::Grpc::new(codec)
787 .apply_compression_config(
788 accept_compression_encodings,
789 send_compression_encodings,
790 )
791 .apply_max_message_size_config(
792 max_decoding_message_size,
793 max_encoding_message_size,
794 );
795 let res = grpc.unary(method, req).await;
796 Ok(res)
797 };
798 Box::pin(fut)
799 }
800 "/user.UserService/DropUser" => {
801 #[allow(non_camel_case_types)]
802 struct DropUserSvc<T: UserService>(pub Arc<T>);
803 impl<
804 T: UserService,
805 > tonic::server::UnaryService<super::DropUserRequest>
806 for DropUserSvc<T> {
807 type Response = super::DropUserResponse;
808 type Future = BoxFuture<
809 tonic::Response<Self::Response>,
810 tonic::Status,
811 >;
812 fn call(
813 &mut self,
814 request: tonic::Request<super::DropUserRequest>,
815 ) -> Self::Future {
816 let inner = Arc::clone(&self.0);
817 let fut = async move {
818 <T as UserService>::drop_user(&inner, request).await
819 };
820 Box::pin(fut)
821 }
822 }
823 let accept_compression_encodings = self.accept_compression_encodings;
824 let send_compression_encodings = self.send_compression_encodings;
825 let max_decoding_message_size = self.max_decoding_message_size;
826 let max_encoding_message_size = self.max_encoding_message_size;
827 let inner = self.inner.clone();
828 let fut = async move {
829 let method = DropUserSvc(inner);
830 let codec = tonic::codec::ProstCodec::default();
831 let mut grpc = tonic::server::Grpc::new(codec)
832 .apply_compression_config(
833 accept_compression_encodings,
834 send_compression_encodings,
835 )
836 .apply_max_message_size_config(
837 max_decoding_message_size,
838 max_encoding_message_size,
839 );
840 let res = grpc.unary(method, req).await;
841 Ok(res)
842 };
843 Box::pin(fut)
844 }
845 "/user.UserService/UpdateUser" => {
846 #[allow(non_camel_case_types)]
847 struct UpdateUserSvc<T: UserService>(pub Arc<T>);
848 impl<
849 T: UserService,
850 > tonic::server::UnaryService<super::UpdateUserRequest>
851 for UpdateUserSvc<T> {
852 type Response = super::UpdateUserResponse;
853 type Future = BoxFuture<
854 tonic::Response<Self::Response>,
855 tonic::Status,
856 >;
857 fn call(
858 &mut self,
859 request: tonic::Request<super::UpdateUserRequest>,
860 ) -> Self::Future {
861 let inner = Arc::clone(&self.0);
862 let fut = async move {
863 <T as UserService>::update_user(&inner, request).await
864 };
865 Box::pin(fut)
866 }
867 }
868 let accept_compression_encodings = self.accept_compression_encodings;
869 let send_compression_encodings = self.send_compression_encodings;
870 let max_decoding_message_size = self.max_decoding_message_size;
871 let max_encoding_message_size = self.max_encoding_message_size;
872 let inner = self.inner.clone();
873 let fut = async move {
874 let method = UpdateUserSvc(inner);
875 let codec = tonic::codec::ProstCodec::default();
876 let mut grpc = tonic::server::Grpc::new(codec)
877 .apply_compression_config(
878 accept_compression_encodings,
879 send_compression_encodings,
880 )
881 .apply_max_message_size_config(
882 max_decoding_message_size,
883 max_encoding_message_size,
884 );
885 let res = grpc.unary(method, req).await;
886 Ok(res)
887 };
888 Box::pin(fut)
889 }
890 "/user.UserService/GrantPrivilege" => {
891 #[allow(non_camel_case_types)]
892 struct GrantPrivilegeSvc<T: UserService>(pub Arc<T>);
893 impl<
894 T: UserService,
895 > tonic::server::UnaryService<super::GrantPrivilegeRequest>
896 for GrantPrivilegeSvc<T> {
897 type Response = super::GrantPrivilegeResponse;
898 type Future = BoxFuture<
899 tonic::Response<Self::Response>,
900 tonic::Status,
901 >;
902 fn call(
903 &mut self,
904 request: tonic::Request<super::GrantPrivilegeRequest>,
905 ) -> Self::Future {
906 let inner = Arc::clone(&self.0);
907 let fut = async move {
908 <T as UserService>::grant_privilege(&inner, request).await
909 };
910 Box::pin(fut)
911 }
912 }
913 let accept_compression_encodings = self.accept_compression_encodings;
914 let send_compression_encodings = self.send_compression_encodings;
915 let max_decoding_message_size = self.max_decoding_message_size;
916 let max_encoding_message_size = self.max_encoding_message_size;
917 let inner = self.inner.clone();
918 let fut = async move {
919 let method = GrantPrivilegeSvc(inner);
920 let codec = tonic::codec::ProstCodec::default();
921 let mut grpc = tonic::server::Grpc::new(codec)
922 .apply_compression_config(
923 accept_compression_encodings,
924 send_compression_encodings,
925 )
926 .apply_max_message_size_config(
927 max_decoding_message_size,
928 max_encoding_message_size,
929 );
930 let res = grpc.unary(method, req).await;
931 Ok(res)
932 };
933 Box::pin(fut)
934 }
935 "/user.UserService/RevokePrivilege" => {
936 #[allow(non_camel_case_types)]
937 struct RevokePrivilegeSvc<T: UserService>(pub Arc<T>);
938 impl<
939 T: UserService,
940 > tonic::server::UnaryService<super::RevokePrivilegeRequest>
941 for RevokePrivilegeSvc<T> {
942 type Response = super::RevokePrivilegeResponse;
943 type Future = BoxFuture<
944 tonic::Response<Self::Response>,
945 tonic::Status,
946 >;
947 fn call(
948 &mut self,
949 request: tonic::Request<super::RevokePrivilegeRequest>,
950 ) -> Self::Future {
951 let inner = Arc::clone(&self.0);
952 let fut = async move {
953 <T as UserService>::revoke_privilege(&inner, request).await
954 };
955 Box::pin(fut)
956 }
957 }
958 let accept_compression_encodings = self.accept_compression_encodings;
959 let send_compression_encodings = self.send_compression_encodings;
960 let max_decoding_message_size = self.max_decoding_message_size;
961 let max_encoding_message_size = self.max_encoding_message_size;
962 let inner = self.inner.clone();
963 let fut = async move {
964 let method = RevokePrivilegeSvc(inner);
965 let codec = tonic::codec::ProstCodec::default();
966 let mut grpc = tonic::server::Grpc::new(codec)
967 .apply_compression_config(
968 accept_compression_encodings,
969 send_compression_encodings,
970 )
971 .apply_max_message_size_config(
972 max_decoding_message_size,
973 max_encoding_message_size,
974 );
975 let res = grpc.unary(method, req).await;
976 Ok(res)
977 };
978 Box::pin(fut)
979 }
980 "/user.UserService/AlterDefaultPrivilege" => {
981 #[allow(non_camel_case_types)]
982 struct AlterDefaultPrivilegeSvc<T: UserService>(pub Arc<T>);
983 impl<
984 T: UserService,
985 > tonic::server::UnaryService<super::AlterDefaultPrivilegeRequest>
986 for AlterDefaultPrivilegeSvc<T> {
987 type Response = super::AlterDefaultPrivilegeResponse;
988 type Future = BoxFuture<
989 tonic::Response<Self::Response>,
990 tonic::Status,
991 >;
992 fn call(
993 &mut self,
994 request: tonic::Request<super::AlterDefaultPrivilegeRequest>,
995 ) -> Self::Future {
996 let inner = Arc::clone(&self.0);
997 let fut = async move {
998 <T as UserService>::alter_default_privilege(&inner, request)
999 .await
1000 };
1001 Box::pin(fut)
1002 }
1003 }
1004 let accept_compression_encodings = self.accept_compression_encodings;
1005 let send_compression_encodings = self.send_compression_encodings;
1006 let max_decoding_message_size = self.max_decoding_message_size;
1007 let max_encoding_message_size = self.max_encoding_message_size;
1008 let inner = self.inner.clone();
1009 let fut = async move {
1010 let method = AlterDefaultPrivilegeSvc(inner);
1011 let codec = tonic::codec::ProstCodec::default();
1012 let mut grpc = tonic::server::Grpc::new(codec)
1013 .apply_compression_config(
1014 accept_compression_encodings,
1015 send_compression_encodings,
1016 )
1017 .apply_max_message_size_config(
1018 max_decoding_message_size,
1019 max_encoding_message_size,
1020 );
1021 let res = grpc.unary(method, req).await;
1022 Ok(res)
1023 };
1024 Box::pin(fut)
1025 }
1026 _ => {
1027 Box::pin(async move {
1028 let mut response = http::Response::new(empty_body());
1029 let headers = response.headers_mut();
1030 headers
1031 .insert(
1032 tonic::Status::GRPC_STATUS,
1033 (tonic::Code::Unimplemented as i32).into(),
1034 );
1035 headers
1036 .insert(
1037 http::header::CONTENT_TYPE,
1038 tonic::metadata::GRPC_CONTENT_TYPE,
1039 );
1040 Ok(response)
1041 })
1042 }
1043 }
1044 }
1045 }
1046 impl<T> Clone for UserServiceServer<T> {
1047 fn clone(&self) -> Self {
1048 let inner = self.inner.clone();
1049 Self {
1050 inner,
1051 accept_compression_encodings: self.accept_compression_encodings,
1052 send_compression_encodings: self.send_compression_encodings,
1053 max_decoding_message_size: self.max_decoding_message_size,
1054 max_encoding_message_size: self.max_encoding_message_size,
1055 }
1056 }
1057 }
1058 pub const SERVICE_NAME: &str = "user.UserService";
1060 impl<T> tonic::server::NamedService for UserServiceServer<T> {
1061 const NAME: &'static str = SERVICE_NAME;
1062 }
1063}