#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AuthInfo {
#[prost(enumeration = "auth_info::EncryptionType", tag = "1")]
pub encryption_type: i32,
#[prost(bytes = "vec", tag = "2")]
pub encrypted_value: ::prost::alloc::vec::Vec<u8>,
#[prost(map = "string, string", tag = "3")]
pub metadata: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
pub mod auth_info {
#[derive(prost_helpers::AnyPB)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum EncryptionType {
Unspecified = 0,
Plaintext = 1,
Sha256 = 2,
Md5 = 3,
Oauth = 4,
}
impl EncryptionType {
pub fn as_str_name(&self) -> &'static str {
match self {
EncryptionType::Unspecified => "UNSPECIFIED",
EncryptionType::Plaintext => "PLAINTEXT",
EncryptionType::Sha256 => "SHA256",
EncryptionType::Md5 => "MD5",
EncryptionType::Oauth => "OAUTH",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSPECIFIED" => Some(Self::Unspecified),
"PLAINTEXT" => Some(Self::Plaintext),
"SHA256" => Some(Self::Sha256),
"MD5" => Some(Self::Md5),
"OAUTH" => Some(Self::Oauth),
_ => None,
}
}
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UserInfo {
#[prost(uint32, tag = "1")]
pub id: u32,
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(bool, tag = "3")]
pub is_super: bool,
#[prost(bool, tag = "4")]
pub can_create_db: bool,
#[prost(bool, tag = "5")]
pub can_create_user: bool,
#[prost(bool, tag = "6")]
pub can_login: bool,
#[prost(message, optional, tag = "7")]
pub auth_info: ::core::option::Option<AuthInfo>,
#[prost(message, repeated, tag = "8")]
pub grant_privileges: ::prost::alloc::vec::Vec<GrantPrivilege>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GrantPrivilege {
#[prost(message, repeated, tag = "7")]
pub action_with_opts: ::prost::alloc::vec::Vec<
grant_privilege::ActionWithGrantOption,
>,
#[prost(
oneof = "grant_privilege::Object",
tags = "1, 2, 3, 4, 5, 6, 8, 11, 12, 13, 14"
)]
pub object: ::core::option::Option<grant_privilege::Object>,
}
pub mod grant_privilege {
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ActionWithGrantOption {
#[prost(enumeration = "Action", tag = "1")]
pub action: i32,
#[prost(bool, tag = "2")]
pub with_grant_option: bool,
#[prost(uint32, tag = "3")]
pub granted_by: u32,
}
#[derive(prost_helpers::AnyPB)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Action {
Unspecified = 0,
Select = 1,
Insert = 2,
Update = 3,
Delete = 4,
Create = 5,
Connect = 6,
Usage = 7,
Execute = 8,
}
impl Action {
pub fn as_str_name(&self) -> &'static str {
match self {
Action::Unspecified => "UNSPECIFIED",
Action::Select => "SELECT",
Action::Insert => "INSERT",
Action::Update => "UPDATE",
Action::Delete => "DELETE",
Action::Create => "CREATE",
Action::Connect => "CONNECT",
Action::Usage => "USAGE",
Action::Execute => "EXECUTE",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSPECIFIED" => Some(Self::Unspecified),
"SELECT" => Some(Self::Select),
"INSERT" => Some(Self::Insert),
"UPDATE" => Some(Self::Update),
"DELETE" => Some(Self::Delete),
"CREATE" => Some(Self::Create),
"CONNECT" => Some(Self::Connect),
"USAGE" => Some(Self::Usage),
"EXECUTE" => Some(Self::Execute),
_ => None,
}
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
pub enum Object {
#[prost(uint32, tag = "1")]
DatabaseId(u32),
#[prost(uint32, tag = "2")]
SchemaId(u32),
#[prost(uint32, tag = "3")]
TableId(u32),
#[prost(uint32, tag = "4")]
SourceId(u32),
#[prost(uint32, tag = "5")]
SinkId(u32),
#[prost(uint32, tag = "6")]
ViewId(u32),
#[prost(uint32, tag = "8")]
FunctionId(u32),
#[prost(uint32, tag = "11")]
AllTablesSchemaId(u32),
#[prost(uint32, tag = "12")]
AllSourcesSchemaId(u32),
#[prost(uint32, tag = "13")]
AllDmlRelationsSchemaId(u32),
#[prost(uint32, tag = "14")]
SubscriptionId(u32),
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateUserRequest {
#[prost(message, optional, tag = "1")]
pub user: ::core::option::Option<UserInfo>,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateUserResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::common::Status>,
#[prost(uint64, tag = "2")]
pub version: u64,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DropUserRequest {
#[prost(uint32, tag = "1")]
pub user_id: u32,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DropUserResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::common::Status>,
#[prost(uint64, tag = "2")]
pub version: u64,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateUserRequest {
#[prost(message, optional, tag = "1")]
pub user: ::core::option::Option<UserInfo>,
#[prost(enumeration = "update_user_request::UpdateField", repeated, tag = "2")]
pub update_fields: ::prost::alloc::vec::Vec<i32>,
}
pub mod update_user_request {
#[derive(prost_helpers::AnyPB)]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum UpdateField {
Unspecified = 0,
Super = 1,
Login = 2,
CreateDb = 3,
AuthInfo = 4,
Rename = 5,
CreateUser = 6,
}
impl UpdateField {
pub fn as_str_name(&self) -> &'static str {
match self {
UpdateField::Unspecified => "UNSPECIFIED",
UpdateField::Super => "SUPER",
UpdateField::Login => "LOGIN",
UpdateField::CreateDb => "CREATE_DB",
UpdateField::AuthInfo => "AUTH_INFO",
UpdateField::Rename => "RENAME",
UpdateField::CreateUser => "CREATE_USER",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSPECIFIED" => Some(Self::Unspecified),
"SUPER" => Some(Self::Super),
"LOGIN" => Some(Self::Login),
"CREATE_DB" => Some(Self::CreateDb),
"AUTH_INFO" => Some(Self::AuthInfo),
"RENAME" => Some(Self::Rename),
"CREATE_USER" => Some(Self::CreateUser),
_ => None,
}
}
}
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateUserResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::common::Status>,
#[prost(uint64, tag = "2")]
pub version: u64,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GrantPrivilegeRequest {
#[prost(uint32, repeated, tag = "1")]
pub user_ids: ::prost::alloc::vec::Vec<u32>,
#[prost(message, repeated, tag = "2")]
pub privileges: ::prost::alloc::vec::Vec<GrantPrivilege>,
#[prost(bool, tag = "3")]
pub with_grant_option: bool,
#[prost(uint32, tag = "4")]
pub granted_by: u32,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GrantPrivilegeResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::common::Status>,
#[prost(uint64, tag = "2")]
pub version: u64,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RevokePrivilegeRequest {
#[prost(uint32, repeated, tag = "1")]
pub user_ids: ::prost::alloc::vec::Vec<u32>,
#[prost(message, repeated, tag = "2")]
pub privileges: ::prost::alloc::vec::Vec<GrantPrivilege>,
#[prost(uint32, tag = "3")]
pub granted_by: u32,
#[prost(uint32, tag = "4")]
pub revoke_by: u32,
#[prost(bool, tag = "5")]
pub revoke_grant_option: bool,
#[prost(bool, tag = "6")]
pub cascade: bool,
}
#[derive(prost_helpers::AnyPB)]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RevokePrivilegeResponse {
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::common::Status>,
#[prost(uint64, tag = "2")]
pub version: u64,
}
pub mod user_service_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct UserServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl UserServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> UserServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> UserServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
UserServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn create_user(
&mut self,
request: impl tonic::IntoRequest<super::CreateUserRequest>,
) -> std::result::Result<
tonic::Response<super::CreateUserResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/user.UserService/CreateUser",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("user.UserService", "CreateUser"));
self.inner.unary(req, path, codec).await
}
pub async fn drop_user(
&mut self,
request: impl tonic::IntoRequest<super::DropUserRequest>,
) -> std::result::Result<
tonic::Response<super::DropUserResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/user.UserService/DropUser",
);
let mut req = request.into_request();
req.extensions_mut().insert(GrpcMethod::new("user.UserService", "DropUser"));
self.inner.unary(req, path, codec).await
}
pub async fn update_user(
&mut self,
request: impl tonic::IntoRequest<super::UpdateUserRequest>,
) -> std::result::Result<
tonic::Response<super::UpdateUserResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/user.UserService/UpdateUser",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("user.UserService", "UpdateUser"));
self.inner.unary(req, path, codec).await
}
pub async fn grant_privilege(
&mut self,
request: impl tonic::IntoRequest<super::GrantPrivilegeRequest>,
) -> std::result::Result<
tonic::Response<super::GrantPrivilegeResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/user.UserService/GrantPrivilege",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("user.UserService", "GrantPrivilege"));
self.inner.unary(req, path, codec).await
}
pub async fn revoke_privilege(
&mut self,
request: impl tonic::IntoRequest<super::RevokePrivilegeRequest>,
) -> std::result::Result<
tonic::Response<super::RevokePrivilegeResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/user.UserService/RevokePrivilege",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("user.UserService", "RevokePrivilege"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod user_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait UserService: std::marker::Send + std::marker::Sync + 'static {
async fn create_user(
&self,
request: tonic::Request<super::CreateUserRequest>,
) -> std::result::Result<
tonic::Response<super::CreateUserResponse>,
tonic::Status,
>;
async fn drop_user(
&self,
request: tonic::Request<super::DropUserRequest>,
) -> std::result::Result<
tonic::Response<super::DropUserResponse>,
tonic::Status,
>;
async fn update_user(
&self,
request: tonic::Request<super::UpdateUserRequest>,
) -> std::result::Result<
tonic::Response<super::UpdateUserResponse>,
tonic::Status,
>;
async fn grant_privilege(
&self,
request: tonic::Request<super::GrantPrivilegeRequest>,
) -> std::result::Result<
tonic::Response<super::GrantPrivilegeResponse>,
tonic::Status,
>;
async fn revoke_privilege(
&self,
request: tonic::Request<super::RevokePrivilegeRequest>,
) -> std::result::Result<
tonic::Response<super::RevokePrivilegeResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct UserServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> UserServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for UserServiceServer<T>
where
T: UserService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/user.UserService/CreateUser" => {
#[allow(non_camel_case_types)]
struct CreateUserSvc<T: UserService>(pub Arc<T>);
impl<
T: UserService,
> tonic::server::UnaryService<super::CreateUserRequest>
for CreateUserSvc<T> {
type Response = super::CreateUserResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::CreateUserRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as UserService>::create_user(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = CreateUserSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/user.UserService/DropUser" => {
#[allow(non_camel_case_types)]
struct DropUserSvc<T: UserService>(pub Arc<T>);
impl<
T: UserService,
> tonic::server::UnaryService<super::DropUserRequest>
for DropUserSvc<T> {
type Response = super::DropUserResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::DropUserRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as UserService>::drop_user(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = DropUserSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/user.UserService/UpdateUser" => {
#[allow(non_camel_case_types)]
struct UpdateUserSvc<T: UserService>(pub Arc<T>);
impl<
T: UserService,
> tonic::server::UnaryService<super::UpdateUserRequest>
for UpdateUserSvc<T> {
type Response = super::UpdateUserResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::UpdateUserRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as UserService>::update_user(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = UpdateUserSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/user.UserService/GrantPrivilege" => {
#[allow(non_camel_case_types)]
struct GrantPrivilegeSvc<T: UserService>(pub Arc<T>);
impl<
T: UserService,
> tonic::server::UnaryService<super::GrantPrivilegeRequest>
for GrantPrivilegeSvc<T> {
type Response = super::GrantPrivilegeResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GrantPrivilegeRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as UserService>::grant_privilege(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GrantPrivilegeSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/user.UserService/RevokePrivilege" => {
#[allow(non_camel_case_types)]
struct RevokePrivilegeSvc<T: UserService>(pub Arc<T>);
impl<
T: UserService,
> tonic::server::UnaryService<super::RevokePrivilegeRequest>
for RevokePrivilegeSvc<T> {
type Response = super::RevokePrivilegeResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::RevokePrivilegeRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as UserService>::revoke_privilege(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = RevokePrivilegeSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", tonic::Code::Unimplemented as i32)
.header(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
)
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T> Clone for UserServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "user.UserService";
impl<T> tonic::server::NamedService for UserServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}