use crate::user::*;
impl serde::Serialize for AuthInfo {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.encryption_type != 0 {
len += 1;
}
if !self.encrypted_value.is_empty() {
len += 1;
}
if !self.metadata.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.AuthInfo", len)?;
if self.encryption_type != 0 {
let v = auth_info::EncryptionType::try_from(self.encryption_type)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.encryption_type)))?;
struct_ser.serialize_field("encryptionType", &v)?;
}
if !self.encrypted_value.is_empty() {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("encryptedValue", pbjson::private::base64::encode(&self.encrypted_value).as_str())?;
}
if !self.metadata.is_empty() {
struct_ser.serialize_field("metadata", &self.metadata)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for AuthInfo {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"encryption_type",
"encryptionType",
"encrypted_value",
"encryptedValue",
"metadata",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
EncryptionType,
EncryptedValue,
Metadata,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"encryptionType" | "encryption_type" => Ok(GeneratedField::EncryptionType),
"encryptedValue" | "encrypted_value" => Ok(GeneratedField::EncryptedValue),
"metadata" => Ok(GeneratedField::Metadata),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = AuthInfo;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.AuthInfo")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<AuthInfo, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut encryption_type__ = None;
let mut encrypted_value__ = None;
let mut metadata__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::EncryptionType => {
if encryption_type__.is_some() {
return Err(serde::de::Error::duplicate_field("encryptionType"));
}
encryption_type__ = Some(map_.next_value::<auth_info::EncryptionType>()? as i32);
}
GeneratedField::EncryptedValue => {
if encrypted_value__.is_some() {
return Err(serde::de::Error::duplicate_field("encryptedValue"));
}
encrypted_value__ =
Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
}
GeneratedField::Metadata => {
if metadata__.is_some() {
return Err(serde::de::Error::duplicate_field("metadata"));
}
metadata__ = Some(
map_.next_value::<std::collections::HashMap<_, _>>()?
);
}
}
}
Ok(AuthInfo {
encryption_type: encryption_type__.unwrap_or_default(),
encrypted_value: encrypted_value__.unwrap_or_default(),
metadata: metadata__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.AuthInfo", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for auth_info::EncryptionType {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let variant = match self {
Self::Unspecified => "UNSPECIFIED",
Self::Plaintext => "PLAINTEXT",
Self::Sha256 => "SHA256",
Self::Md5 => "MD5",
Self::Oauth => "OAUTH",
};
serializer.serialize_str(variant)
}
}
impl<'de> serde::Deserialize<'de> for auth_info::EncryptionType {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"UNSPECIFIED",
"PLAINTEXT",
"SHA256",
"MD5",
"OAUTH",
];
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = auth_info::EncryptionType;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
fn visit_i64<E>(self, v: i64) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
i32::try_from(v)
.ok()
.and_then(|x| x.try_into().ok())
.ok_or_else(|| {
serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self)
})
}
fn visit_u64<E>(self, v: u64) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
i32::try_from(v)
.ok()
.and_then(|x| x.try_into().ok())
.ok_or_else(|| {
serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self)
})
}
fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
match value {
"UNSPECIFIED" => Ok(auth_info::EncryptionType::Unspecified),
"PLAINTEXT" => Ok(auth_info::EncryptionType::Plaintext),
"SHA256" => Ok(auth_info::EncryptionType::Sha256),
"MD5" => Ok(auth_info::EncryptionType::Md5),
"OAUTH" => Ok(auth_info::EncryptionType::Oauth),
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
}
}
}
deserializer.deserialize_any(GeneratedVisitor)
}
}
impl serde::Serialize for CreateUserRequest {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.user.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.CreateUserRequest", len)?;
if let Some(v) = self.user.as_ref() {
struct_ser.serialize_field("user", v)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for CreateUserRequest {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"user",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
User,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"user" => Ok(GeneratedField::User),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = CreateUserRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.CreateUserRequest")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<CreateUserRequest, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut user__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::User => {
if user__.is_some() {
return Err(serde::de::Error::duplicate_field("user"));
}
user__ = map_.next_value()?;
}
}
}
Ok(CreateUserRequest {
user: user__,
})
}
}
deserializer.deserialize_struct("user.CreateUserRequest", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for CreateUserResponse {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.status.is_some() {
len += 1;
}
if self.version != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.CreateUserResponse", len)?;
if let Some(v) = self.status.as_ref() {
struct_ser.serialize_field("status", v)?;
}
if self.version != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("version", ToString::to_string(&self.version).as_str())?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for CreateUserResponse {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"status",
"version",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Status,
Version,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"status" => Ok(GeneratedField::Status),
"version" => Ok(GeneratedField::Version),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = CreateUserResponse;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.CreateUserResponse")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<CreateUserResponse, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut status__ = None;
let mut version__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Status => {
if status__.is_some() {
return Err(serde::de::Error::duplicate_field("status"));
}
status__ = map_.next_value()?;
}
GeneratedField::Version => {
if version__.is_some() {
return Err(serde::de::Error::duplicate_field("version"));
}
version__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(CreateUserResponse {
status: status__,
version: version__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.CreateUserResponse", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for DropUserRequest {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.user_id != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.DropUserRequest", len)?;
if self.user_id != 0 {
struct_ser.serialize_field("userId", &self.user_id)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for DropUserRequest {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"user_id",
"userId",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
UserId,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"userId" | "user_id" => Ok(GeneratedField::UserId),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = DropUserRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.DropUserRequest")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<DropUserRequest, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut user_id__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::UserId => {
if user_id__.is_some() {
return Err(serde::de::Error::duplicate_field("userId"));
}
user_id__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(DropUserRequest {
user_id: user_id__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.DropUserRequest", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for DropUserResponse {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.status.is_some() {
len += 1;
}
if self.version != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.DropUserResponse", len)?;
if let Some(v) = self.status.as_ref() {
struct_ser.serialize_field("status", v)?;
}
if self.version != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("version", ToString::to_string(&self.version).as_str())?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for DropUserResponse {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"status",
"version",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Status,
Version,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"status" => Ok(GeneratedField::Status),
"version" => Ok(GeneratedField::Version),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = DropUserResponse;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.DropUserResponse")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<DropUserResponse, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut status__ = None;
let mut version__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Status => {
if status__.is_some() {
return Err(serde::de::Error::duplicate_field("status"));
}
status__ = map_.next_value()?;
}
GeneratedField::Version => {
if version__.is_some() {
return Err(serde::de::Error::duplicate_field("version"));
}
version__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(DropUserResponse {
status: status__,
version: version__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.DropUserResponse", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for GrantPrivilege {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if !self.action_with_opts.is_empty() {
len += 1;
}
if self.object.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.GrantPrivilege", len)?;
if !self.action_with_opts.is_empty() {
struct_ser.serialize_field("actionWithOpts", &self.action_with_opts)?;
}
if let Some(v) = self.object.as_ref() {
match v {
grant_privilege::Object::DatabaseId(v) => {
struct_ser.serialize_field("databaseId", v)?;
}
grant_privilege::Object::SchemaId(v) => {
struct_ser.serialize_field("schemaId", v)?;
}
grant_privilege::Object::TableId(v) => {
struct_ser.serialize_field("tableId", v)?;
}
grant_privilege::Object::SourceId(v) => {
struct_ser.serialize_field("sourceId", v)?;
}
grant_privilege::Object::SinkId(v) => {
struct_ser.serialize_field("sinkId", v)?;
}
grant_privilege::Object::ViewId(v) => {
struct_ser.serialize_field("viewId", v)?;
}
grant_privilege::Object::FunctionId(v) => {
struct_ser.serialize_field("functionId", v)?;
}
grant_privilege::Object::AllTablesSchemaId(v) => {
struct_ser.serialize_field("allTablesSchemaId", v)?;
}
grant_privilege::Object::AllSourcesSchemaId(v) => {
struct_ser.serialize_field("allSourcesSchemaId", v)?;
}
grant_privilege::Object::AllDmlRelationsSchemaId(v) => {
struct_ser.serialize_field("allDmlRelationsSchemaId", v)?;
}
grant_privilege::Object::SubscriptionId(v) => {
struct_ser.serialize_field("subscriptionId", v)?;
}
}
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for GrantPrivilege {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"action_with_opts",
"actionWithOpts",
"database_id",
"databaseId",
"schema_id",
"schemaId",
"table_id",
"tableId",
"source_id",
"sourceId",
"sink_id",
"sinkId",
"view_id",
"viewId",
"function_id",
"functionId",
"all_tables_schema_id",
"allTablesSchemaId",
"all_sources_schema_id",
"allSourcesSchemaId",
"all_dml_relations_schema_id",
"allDmlRelationsSchemaId",
"subscription_id",
"subscriptionId",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
ActionWithOpts,
DatabaseId,
SchemaId,
TableId,
SourceId,
SinkId,
ViewId,
FunctionId,
AllTablesSchemaId,
AllSourcesSchemaId,
AllDmlRelationsSchemaId,
SubscriptionId,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"actionWithOpts" | "action_with_opts" => Ok(GeneratedField::ActionWithOpts),
"databaseId" | "database_id" => Ok(GeneratedField::DatabaseId),
"schemaId" | "schema_id" => Ok(GeneratedField::SchemaId),
"tableId" | "table_id" => Ok(GeneratedField::TableId),
"sourceId" | "source_id" => Ok(GeneratedField::SourceId),
"sinkId" | "sink_id" => Ok(GeneratedField::SinkId),
"viewId" | "view_id" => Ok(GeneratedField::ViewId),
"functionId" | "function_id" => Ok(GeneratedField::FunctionId),
"allTablesSchemaId" | "all_tables_schema_id" => Ok(GeneratedField::AllTablesSchemaId),
"allSourcesSchemaId" | "all_sources_schema_id" => Ok(GeneratedField::AllSourcesSchemaId),
"allDmlRelationsSchemaId" | "all_dml_relations_schema_id" => Ok(GeneratedField::AllDmlRelationsSchemaId),
"subscriptionId" | "subscription_id" => Ok(GeneratedField::SubscriptionId),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GrantPrivilege;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.GrantPrivilege")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<GrantPrivilege, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut action_with_opts__ = None;
let mut object__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::ActionWithOpts => {
if action_with_opts__.is_some() {
return Err(serde::de::Error::duplicate_field("actionWithOpts"));
}
action_with_opts__ = Some(map_.next_value()?);
}
GeneratedField::DatabaseId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("databaseId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::DatabaseId(x.0));
}
GeneratedField::SchemaId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("schemaId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::SchemaId(x.0));
}
GeneratedField::TableId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("tableId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::TableId(x.0));
}
GeneratedField::SourceId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("sourceId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::SourceId(x.0));
}
GeneratedField::SinkId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("sinkId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::SinkId(x.0));
}
GeneratedField::ViewId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("viewId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::ViewId(x.0));
}
GeneratedField::FunctionId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("functionId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::FunctionId(x.0));
}
GeneratedField::AllTablesSchemaId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("allTablesSchemaId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::AllTablesSchemaId(x.0));
}
GeneratedField::AllSourcesSchemaId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("allSourcesSchemaId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::AllSourcesSchemaId(x.0));
}
GeneratedField::AllDmlRelationsSchemaId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("allDmlRelationsSchemaId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::AllDmlRelationsSchemaId(x.0));
}
GeneratedField::SubscriptionId => {
if object__.is_some() {
return Err(serde::de::Error::duplicate_field("subscriptionId"));
}
object__ = map_.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| grant_privilege::Object::SubscriptionId(x.0));
}
}
}
Ok(GrantPrivilege {
action_with_opts: action_with_opts__.unwrap_or_default(),
object: object__,
})
}
}
deserializer.deserialize_struct("user.GrantPrivilege", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for grant_privilege::Action {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let variant = match self {
Self::Unspecified => "UNSPECIFIED",
Self::Select => "SELECT",
Self::Insert => "INSERT",
Self::Update => "UPDATE",
Self::Delete => "DELETE",
Self::Create => "CREATE",
Self::Connect => "CONNECT",
Self::Usage => "USAGE",
Self::Execute => "EXECUTE",
};
serializer.serialize_str(variant)
}
}
impl<'de> serde::Deserialize<'de> for grant_privilege::Action {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"UNSPECIFIED",
"SELECT",
"INSERT",
"UPDATE",
"DELETE",
"CREATE",
"CONNECT",
"USAGE",
"EXECUTE",
];
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = grant_privilege::Action;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
fn visit_i64<E>(self, v: i64) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
i32::try_from(v)
.ok()
.and_then(|x| x.try_into().ok())
.ok_or_else(|| {
serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self)
})
}
fn visit_u64<E>(self, v: u64) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
i32::try_from(v)
.ok()
.and_then(|x| x.try_into().ok())
.ok_or_else(|| {
serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self)
})
}
fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
match value {
"UNSPECIFIED" => Ok(grant_privilege::Action::Unspecified),
"SELECT" => Ok(grant_privilege::Action::Select),
"INSERT" => Ok(grant_privilege::Action::Insert),
"UPDATE" => Ok(grant_privilege::Action::Update),
"DELETE" => Ok(grant_privilege::Action::Delete),
"CREATE" => Ok(grant_privilege::Action::Create),
"CONNECT" => Ok(grant_privilege::Action::Connect),
"USAGE" => Ok(grant_privilege::Action::Usage),
"EXECUTE" => Ok(grant_privilege::Action::Execute),
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
}
}
}
deserializer.deserialize_any(GeneratedVisitor)
}
}
impl serde::Serialize for grant_privilege::ActionWithGrantOption {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.action != 0 {
len += 1;
}
if self.with_grant_option {
len += 1;
}
if self.granted_by != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.GrantPrivilege.ActionWithGrantOption", len)?;
if self.action != 0 {
let v = grant_privilege::Action::try_from(self.action)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.action)))?;
struct_ser.serialize_field("action", &v)?;
}
if self.with_grant_option {
struct_ser.serialize_field("withGrantOption", &self.with_grant_option)?;
}
if self.granted_by != 0 {
struct_ser.serialize_field("grantedBy", &self.granted_by)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for grant_privilege::ActionWithGrantOption {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"action",
"with_grant_option",
"withGrantOption",
"granted_by",
"grantedBy",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Action,
WithGrantOption,
GrantedBy,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"action" => Ok(GeneratedField::Action),
"withGrantOption" | "with_grant_option" => Ok(GeneratedField::WithGrantOption),
"grantedBy" | "granted_by" => Ok(GeneratedField::GrantedBy),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = grant_privilege::ActionWithGrantOption;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.GrantPrivilege.ActionWithGrantOption")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<grant_privilege::ActionWithGrantOption, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut action__ = None;
let mut with_grant_option__ = None;
let mut granted_by__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Action => {
if action__.is_some() {
return Err(serde::de::Error::duplicate_field("action"));
}
action__ = Some(map_.next_value::<grant_privilege::Action>()? as i32);
}
GeneratedField::WithGrantOption => {
if with_grant_option__.is_some() {
return Err(serde::de::Error::duplicate_field("withGrantOption"));
}
with_grant_option__ = Some(map_.next_value()?);
}
GeneratedField::GrantedBy => {
if granted_by__.is_some() {
return Err(serde::de::Error::duplicate_field("grantedBy"));
}
granted_by__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(grant_privilege::ActionWithGrantOption {
action: action__.unwrap_or_default(),
with_grant_option: with_grant_option__.unwrap_or_default(),
granted_by: granted_by__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.GrantPrivilege.ActionWithGrantOption", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for GrantPrivilegeRequest {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if !self.user_ids.is_empty() {
len += 1;
}
if !self.privileges.is_empty() {
len += 1;
}
if self.with_grant_option {
len += 1;
}
if self.granted_by != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.GrantPrivilegeRequest", len)?;
if !self.user_ids.is_empty() {
struct_ser.serialize_field("userIds", &self.user_ids)?;
}
if !self.privileges.is_empty() {
struct_ser.serialize_field("privileges", &self.privileges)?;
}
if self.with_grant_option {
struct_ser.serialize_field("withGrantOption", &self.with_grant_option)?;
}
if self.granted_by != 0 {
struct_ser.serialize_field("grantedBy", &self.granted_by)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for GrantPrivilegeRequest {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"user_ids",
"userIds",
"privileges",
"with_grant_option",
"withGrantOption",
"granted_by",
"grantedBy",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
UserIds,
Privileges,
WithGrantOption,
GrantedBy,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"userIds" | "user_ids" => Ok(GeneratedField::UserIds),
"privileges" => Ok(GeneratedField::Privileges),
"withGrantOption" | "with_grant_option" => Ok(GeneratedField::WithGrantOption),
"grantedBy" | "granted_by" => Ok(GeneratedField::GrantedBy),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GrantPrivilegeRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.GrantPrivilegeRequest")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<GrantPrivilegeRequest, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut user_ids__ = None;
let mut privileges__ = None;
let mut with_grant_option__ = None;
let mut granted_by__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::UserIds => {
if user_ids__.is_some() {
return Err(serde::de::Error::duplicate_field("userIds"));
}
user_ids__ =
Some(map_.next_value::<Vec<::pbjson::private::NumberDeserialize<_>>>()?
.into_iter().map(|x| x.0).collect())
;
}
GeneratedField::Privileges => {
if privileges__.is_some() {
return Err(serde::de::Error::duplicate_field("privileges"));
}
privileges__ = Some(map_.next_value()?);
}
GeneratedField::WithGrantOption => {
if with_grant_option__.is_some() {
return Err(serde::de::Error::duplicate_field("withGrantOption"));
}
with_grant_option__ = Some(map_.next_value()?);
}
GeneratedField::GrantedBy => {
if granted_by__.is_some() {
return Err(serde::de::Error::duplicate_field("grantedBy"));
}
granted_by__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(GrantPrivilegeRequest {
user_ids: user_ids__.unwrap_or_default(),
privileges: privileges__.unwrap_or_default(),
with_grant_option: with_grant_option__.unwrap_or_default(),
granted_by: granted_by__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.GrantPrivilegeRequest", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for GrantPrivilegeResponse {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.status.is_some() {
len += 1;
}
if self.version != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.GrantPrivilegeResponse", len)?;
if let Some(v) = self.status.as_ref() {
struct_ser.serialize_field("status", v)?;
}
if self.version != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("version", ToString::to_string(&self.version).as_str())?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for GrantPrivilegeResponse {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"status",
"version",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Status,
Version,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"status" => Ok(GeneratedField::Status),
"version" => Ok(GeneratedField::Version),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GrantPrivilegeResponse;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.GrantPrivilegeResponse")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<GrantPrivilegeResponse, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut status__ = None;
let mut version__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Status => {
if status__.is_some() {
return Err(serde::de::Error::duplicate_field("status"));
}
status__ = map_.next_value()?;
}
GeneratedField::Version => {
if version__.is_some() {
return Err(serde::de::Error::duplicate_field("version"));
}
version__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(GrantPrivilegeResponse {
status: status__,
version: version__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.GrantPrivilegeResponse", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for RevokePrivilegeRequest {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if !self.user_ids.is_empty() {
len += 1;
}
if !self.privileges.is_empty() {
len += 1;
}
if self.granted_by != 0 {
len += 1;
}
if self.revoke_by != 0 {
len += 1;
}
if self.revoke_grant_option {
len += 1;
}
if self.cascade {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.RevokePrivilegeRequest", len)?;
if !self.user_ids.is_empty() {
struct_ser.serialize_field("userIds", &self.user_ids)?;
}
if !self.privileges.is_empty() {
struct_ser.serialize_field("privileges", &self.privileges)?;
}
if self.granted_by != 0 {
struct_ser.serialize_field("grantedBy", &self.granted_by)?;
}
if self.revoke_by != 0 {
struct_ser.serialize_field("revokeBy", &self.revoke_by)?;
}
if self.revoke_grant_option {
struct_ser.serialize_field("revokeGrantOption", &self.revoke_grant_option)?;
}
if self.cascade {
struct_ser.serialize_field("cascade", &self.cascade)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for RevokePrivilegeRequest {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"user_ids",
"userIds",
"privileges",
"granted_by",
"grantedBy",
"revoke_by",
"revokeBy",
"revoke_grant_option",
"revokeGrantOption",
"cascade",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
UserIds,
Privileges,
GrantedBy,
RevokeBy,
RevokeGrantOption,
Cascade,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"userIds" | "user_ids" => Ok(GeneratedField::UserIds),
"privileges" => Ok(GeneratedField::Privileges),
"grantedBy" | "granted_by" => Ok(GeneratedField::GrantedBy),
"revokeBy" | "revoke_by" => Ok(GeneratedField::RevokeBy),
"revokeGrantOption" | "revoke_grant_option" => Ok(GeneratedField::RevokeGrantOption),
"cascade" => Ok(GeneratedField::Cascade),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = RevokePrivilegeRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.RevokePrivilegeRequest")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<RevokePrivilegeRequest, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut user_ids__ = None;
let mut privileges__ = None;
let mut granted_by__ = None;
let mut revoke_by__ = None;
let mut revoke_grant_option__ = None;
let mut cascade__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::UserIds => {
if user_ids__.is_some() {
return Err(serde::de::Error::duplicate_field("userIds"));
}
user_ids__ =
Some(map_.next_value::<Vec<::pbjson::private::NumberDeserialize<_>>>()?
.into_iter().map(|x| x.0).collect())
;
}
GeneratedField::Privileges => {
if privileges__.is_some() {
return Err(serde::de::Error::duplicate_field("privileges"));
}
privileges__ = Some(map_.next_value()?);
}
GeneratedField::GrantedBy => {
if granted_by__.is_some() {
return Err(serde::de::Error::duplicate_field("grantedBy"));
}
granted_by__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::RevokeBy => {
if revoke_by__.is_some() {
return Err(serde::de::Error::duplicate_field("revokeBy"));
}
revoke_by__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::RevokeGrantOption => {
if revoke_grant_option__.is_some() {
return Err(serde::de::Error::duplicate_field("revokeGrantOption"));
}
revoke_grant_option__ = Some(map_.next_value()?);
}
GeneratedField::Cascade => {
if cascade__.is_some() {
return Err(serde::de::Error::duplicate_field("cascade"));
}
cascade__ = Some(map_.next_value()?);
}
}
}
Ok(RevokePrivilegeRequest {
user_ids: user_ids__.unwrap_or_default(),
privileges: privileges__.unwrap_or_default(),
granted_by: granted_by__.unwrap_or_default(),
revoke_by: revoke_by__.unwrap_or_default(),
revoke_grant_option: revoke_grant_option__.unwrap_or_default(),
cascade: cascade__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.RevokePrivilegeRequest", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for RevokePrivilegeResponse {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.status.is_some() {
len += 1;
}
if self.version != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.RevokePrivilegeResponse", len)?;
if let Some(v) = self.status.as_ref() {
struct_ser.serialize_field("status", v)?;
}
if self.version != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("version", ToString::to_string(&self.version).as_str())?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for RevokePrivilegeResponse {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"status",
"version",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Status,
Version,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"status" => Ok(GeneratedField::Status),
"version" => Ok(GeneratedField::Version),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = RevokePrivilegeResponse;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.RevokePrivilegeResponse")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<RevokePrivilegeResponse, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut status__ = None;
let mut version__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Status => {
if status__.is_some() {
return Err(serde::de::Error::duplicate_field("status"));
}
status__ = map_.next_value()?;
}
GeneratedField::Version => {
if version__.is_some() {
return Err(serde::de::Error::duplicate_field("version"));
}
version__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(RevokePrivilegeResponse {
status: status__,
version: version__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.RevokePrivilegeResponse", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for UpdateUserRequest {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.user.is_some() {
len += 1;
}
if !self.update_fields.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.UpdateUserRequest", len)?;
if let Some(v) = self.user.as_ref() {
struct_ser.serialize_field("user", v)?;
}
if !self.update_fields.is_empty() {
let v = self.update_fields.iter().cloned().map(|v| {
update_user_request::UpdateField::try_from(v)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", v)))
}).collect::<std::result::Result<Vec<_>, _>>()?;
struct_ser.serialize_field("updateFields", &v)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for UpdateUserRequest {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"user",
"update_fields",
"updateFields",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
User,
UpdateFields,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"user" => Ok(GeneratedField::User),
"updateFields" | "update_fields" => Ok(GeneratedField::UpdateFields),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = UpdateUserRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.UpdateUserRequest")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<UpdateUserRequest, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut user__ = None;
let mut update_fields__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::User => {
if user__.is_some() {
return Err(serde::de::Error::duplicate_field("user"));
}
user__ = map_.next_value()?;
}
GeneratedField::UpdateFields => {
if update_fields__.is_some() {
return Err(serde::de::Error::duplicate_field("updateFields"));
}
update_fields__ = Some(map_.next_value::<Vec<update_user_request::UpdateField>>()?.into_iter().map(|x| x as i32).collect());
}
}
}
Ok(UpdateUserRequest {
user: user__,
update_fields: update_fields__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.UpdateUserRequest", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for update_user_request::UpdateField {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let variant = match self {
Self::Unspecified => "UNSPECIFIED",
Self::Super => "SUPER",
Self::Login => "LOGIN",
Self::CreateDb => "CREATE_DB",
Self::AuthInfo => "AUTH_INFO",
Self::Rename => "RENAME",
Self::CreateUser => "CREATE_USER",
};
serializer.serialize_str(variant)
}
}
impl<'de> serde::Deserialize<'de> for update_user_request::UpdateField {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"UNSPECIFIED",
"SUPER",
"LOGIN",
"CREATE_DB",
"AUTH_INFO",
"RENAME",
"CREATE_USER",
];
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = update_user_request::UpdateField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
fn visit_i64<E>(self, v: i64) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
i32::try_from(v)
.ok()
.and_then(|x| x.try_into().ok())
.ok_or_else(|| {
serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self)
})
}
fn visit_u64<E>(self, v: u64) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
i32::try_from(v)
.ok()
.and_then(|x| x.try_into().ok())
.ok_or_else(|| {
serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self)
})
}
fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
{
match value {
"UNSPECIFIED" => Ok(update_user_request::UpdateField::Unspecified),
"SUPER" => Ok(update_user_request::UpdateField::Super),
"LOGIN" => Ok(update_user_request::UpdateField::Login),
"CREATE_DB" => Ok(update_user_request::UpdateField::CreateDb),
"AUTH_INFO" => Ok(update_user_request::UpdateField::AuthInfo),
"RENAME" => Ok(update_user_request::UpdateField::Rename),
"CREATE_USER" => Ok(update_user_request::UpdateField::CreateUser),
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
}
}
}
deserializer.deserialize_any(GeneratedVisitor)
}
}
impl serde::Serialize for UpdateUserResponse {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.status.is_some() {
len += 1;
}
if self.version != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.UpdateUserResponse", len)?;
if let Some(v) = self.status.as_ref() {
struct_ser.serialize_field("status", v)?;
}
if self.version != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("version", ToString::to_string(&self.version).as_str())?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for UpdateUserResponse {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"status",
"version",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Status,
Version,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"status" => Ok(GeneratedField::Status),
"version" => Ok(GeneratedField::Version),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = UpdateUserResponse;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.UpdateUserResponse")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<UpdateUserResponse, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut status__ = None;
let mut version__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Status => {
if status__.is_some() {
return Err(serde::de::Error::duplicate_field("status"));
}
status__ = map_.next_value()?;
}
GeneratedField::Version => {
if version__.is_some() {
return Err(serde::de::Error::duplicate_field("version"));
}
version__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(UpdateUserResponse {
status: status__,
version: version__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.UpdateUserResponse", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for UserInfo {
#[allow(deprecated)]
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.id != 0 {
len += 1;
}
if !self.name.is_empty() {
len += 1;
}
if self.is_super {
len += 1;
}
if self.can_create_db {
len += 1;
}
if self.can_create_user {
len += 1;
}
if self.can_login {
len += 1;
}
if self.auth_info.is_some() {
len += 1;
}
if !self.grant_privileges.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("user.UserInfo", len)?;
if self.id != 0 {
struct_ser.serialize_field("id", &self.id)?;
}
if !self.name.is_empty() {
struct_ser.serialize_field("name", &self.name)?;
}
if self.is_super {
struct_ser.serialize_field("isSuper", &self.is_super)?;
}
if self.can_create_db {
struct_ser.serialize_field("canCreateDb", &self.can_create_db)?;
}
if self.can_create_user {
struct_ser.serialize_field("canCreateUser", &self.can_create_user)?;
}
if self.can_login {
struct_ser.serialize_field("canLogin", &self.can_login)?;
}
if let Some(v) = self.auth_info.as_ref() {
struct_ser.serialize_field("authInfo", v)?;
}
if !self.grant_privileges.is_empty() {
struct_ser.serialize_field("grantPrivileges", &self.grant_privileges)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for UserInfo {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"id",
"name",
"is_super",
"isSuper",
"can_create_db",
"canCreateDb",
"can_create_user",
"canCreateUser",
"can_login",
"canLogin",
"auth_info",
"authInfo",
"grant_privileges",
"grantPrivileges",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Id,
Name,
IsSuper,
CanCreateDb,
CanCreateUser,
CanLogin,
AuthInfo,
GrantPrivileges,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
fn deserialize<D>(deserializer: D) -> std::result::Result<GeneratedField, D::Error>
where
D: serde::Deserializer<'de>,
{
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = GeneratedField;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(formatter, "expected one of: {:?}", &FIELDS)
}
#[allow(unused_variables)]
fn visit_str<E>(self, value: &str) -> std::result::Result<GeneratedField, E>
where
E: serde::de::Error,
{
match value {
"id" => Ok(GeneratedField::Id),
"name" => Ok(GeneratedField::Name),
"isSuper" | "is_super" => Ok(GeneratedField::IsSuper),
"canCreateDb" | "can_create_db" => Ok(GeneratedField::CanCreateDb),
"canCreateUser" | "can_create_user" => Ok(GeneratedField::CanCreateUser),
"canLogin" | "can_login" => Ok(GeneratedField::CanLogin),
"authInfo" | "auth_info" => Ok(GeneratedField::AuthInfo),
"grantPrivileges" | "grant_privileges" => Ok(GeneratedField::GrantPrivileges),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = UserInfo;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct user.UserInfo")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<UserInfo, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut id__ = None;
let mut name__ = None;
let mut is_super__ = None;
let mut can_create_db__ = None;
let mut can_create_user__ = None;
let mut can_login__ = None;
let mut auth_info__ = None;
let mut grant_privileges__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Id => {
if id__.is_some() {
return Err(serde::de::Error::duplicate_field("id"));
}
id__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::Name => {
if name__.is_some() {
return Err(serde::de::Error::duplicate_field("name"));
}
name__ = Some(map_.next_value()?);
}
GeneratedField::IsSuper => {
if is_super__.is_some() {
return Err(serde::de::Error::duplicate_field("isSuper"));
}
is_super__ = Some(map_.next_value()?);
}
GeneratedField::CanCreateDb => {
if can_create_db__.is_some() {
return Err(serde::de::Error::duplicate_field("canCreateDb"));
}
can_create_db__ = Some(map_.next_value()?);
}
GeneratedField::CanCreateUser => {
if can_create_user__.is_some() {
return Err(serde::de::Error::duplicate_field("canCreateUser"));
}
can_create_user__ = Some(map_.next_value()?);
}
GeneratedField::CanLogin => {
if can_login__.is_some() {
return Err(serde::de::Error::duplicate_field("canLogin"));
}
can_login__ = Some(map_.next_value()?);
}
GeneratedField::AuthInfo => {
if auth_info__.is_some() {
return Err(serde::de::Error::duplicate_field("authInfo"));
}
auth_info__ = map_.next_value()?;
}
GeneratedField::GrantPrivileges => {
if grant_privileges__.is_some() {
return Err(serde::de::Error::duplicate_field("grantPrivileges"));
}
grant_privileges__ = Some(map_.next_value()?);
}
}
}
Ok(UserInfo {
id: id__.unwrap_or_default(),
name: name__.unwrap_or_default(),
is_super: is_super__.unwrap_or_default(),
can_create_db: can_create_db__.unwrap_or_default(),
can_create_user: can_create_user__.unwrap_or_default(),
can_login: can_login__.unwrap_or_default(),
auth_info: auth_info__,
grant_privileges: grant_privileges__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("user.UserInfo", FIELDS, GeneratedVisitor)
}
}