use crate::cloud_service::*;
impl serde::Serialize for RwCloudValidateSourceRequest {
#[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.source_type != 0 {
len += 1;
}
if !self.source_config.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("cloud_service.RwCloudValidateSourceRequest", len)?;
if self.source_type != 0 {
let v = SourceType::try_from(self.source_type)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.source_type)))?;
struct_ser.serialize_field("sourceType", &v)?;
}
if !self.source_config.is_empty() {
struct_ser.serialize_field("sourceConfig", &self.source_config)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for RwCloudValidateSourceRequest {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"source_type",
"sourceType",
"source_config",
"sourceConfig",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
SourceType,
SourceConfig,
}
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 {
"sourceType" | "source_type" => Ok(GeneratedField::SourceType),
"sourceConfig" | "source_config" => Ok(GeneratedField::SourceConfig),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = RwCloudValidateSourceRequest;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct cloud_service.RwCloudValidateSourceRequest")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<RwCloudValidateSourceRequest, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut source_type__ = None;
let mut source_config__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::SourceType => {
if source_type__.is_some() {
return Err(serde::de::Error::duplicate_field("sourceType"));
}
source_type__ = Some(map_.next_value::<SourceType>()? as i32);
}
GeneratedField::SourceConfig => {
if source_config__.is_some() {
return Err(serde::de::Error::duplicate_field("sourceConfig"));
}
source_config__ = Some(
map_.next_value::<std::collections::HashMap<_, _>>()?
);
}
}
}
Ok(RwCloudValidateSourceRequest {
source_type: source_type__.unwrap_or_default(),
source_config: source_config__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("cloud_service.RwCloudValidateSourceRequest", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for RwCloudValidateSourceResponse {
#[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.ok {
len += 1;
}
if self.error.is_some() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("cloud_service.RwCloudValidateSourceResponse", len)?;
if self.ok {
struct_ser.serialize_field("ok", &self.ok)?;
}
if let Some(v) = self.error.as_ref() {
struct_ser.serialize_field("error", v)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for RwCloudValidateSourceResponse {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"ok",
"error",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Ok,
Error,
}
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 {
"ok" => Ok(GeneratedField::Ok),
"error" => Ok(GeneratedField::Error),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = RwCloudValidateSourceResponse;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct cloud_service.RwCloudValidateSourceResponse")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<RwCloudValidateSourceResponse, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut ok__ = None;
let mut error__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Ok => {
if ok__.is_some() {
return Err(serde::de::Error::duplicate_field("ok"));
}
ok__ = Some(map_.next_value()?);
}
GeneratedField::Error => {
if error__.is_some() {
return Err(serde::de::Error::duplicate_field("error"));
}
error__ = map_.next_value()?;
}
}
}
Ok(RwCloudValidateSourceResponse {
ok: ok__.unwrap_or_default(),
error: error__,
})
}
}
deserializer.deserialize_struct("cloud_service.RwCloudValidateSourceResponse", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for rw_cloud_validate_source_response::Error {
#[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.error_type != 0 {
len += 1;
}
if !self.error_message.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("cloud_service.RwCloudValidateSourceResponse.Error", len)?;
if self.error_type != 0 {
let v = rw_cloud_validate_source_response::ErrorType::try_from(self.error_type)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.error_type)))?;
struct_ser.serialize_field("errorType", &v)?;
}
if !self.error_message.is_empty() {
struct_ser.serialize_field("errorMessage", &self.error_message)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for rw_cloud_validate_source_response::Error {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"error_type",
"errorType",
"error_message",
"errorMessage",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
ErrorType,
ErrorMessage,
}
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 {
"errorType" | "error_type" => Ok(GeneratedField::ErrorType),
"errorMessage" | "error_message" => Ok(GeneratedField::ErrorMessage),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = rw_cloud_validate_source_response::Error;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct cloud_service.RwCloudValidateSourceResponse.Error")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<rw_cloud_validate_source_response::Error, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut error_type__ = None;
let mut error_message__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::ErrorType => {
if error_type__.is_some() {
return Err(serde::de::Error::duplicate_field("errorType"));
}
error_type__ = Some(map_.next_value::<rw_cloud_validate_source_response::ErrorType>()? as i32);
}
GeneratedField::ErrorMessage => {
if error_message__.is_some() {
return Err(serde::de::Error::duplicate_field("errorMessage"));
}
error_message__ = Some(map_.next_value()?);
}
}
}
Ok(rw_cloud_validate_source_response::Error {
error_type: error_type__.unwrap_or_default(),
error_message: error_message__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("cloud_service.RwCloudValidateSourceResponse.Error", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for rw_cloud_validate_source_response::ErrorType {
#[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::PrivatelinkConnectionNotFound => "PRIVATELINK_CONNECTION_NOT_FOUND",
Self::PrivatelinkUnavailable => "PRIVATELINK_UNAVAILABLE",
Self::PrivatelinkResolveErr => "PRIVATELINK_RESOLVE_ERR",
Self::KafkaInvalidProperties => "KAFKA_INVALID_PROPERTIES",
Self::KafkaTopicNotFound => "KAFKA_TOPIC_NOT_FOUND",
Self::KafkaBrokerUnreachable => "KAFKA_BROKER_UNREACHABLE",
Self::KafkaOther => "KAFKA_OTHER",
Self::AwsClientNotConfigured => "AWS_CLIENT_NOT_CONFIGURED",
};
serializer.serialize_str(variant)
}
}
impl<'de> serde::Deserialize<'de> for rw_cloud_validate_source_response::ErrorType {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"UNSPECIFIED",
"PRIVATELINK_CONNECTION_NOT_FOUND",
"PRIVATELINK_UNAVAILABLE",
"PRIVATELINK_RESOLVE_ERR",
"KAFKA_INVALID_PROPERTIES",
"KAFKA_TOPIC_NOT_FOUND",
"KAFKA_BROKER_UNREACHABLE",
"KAFKA_OTHER",
"AWS_CLIENT_NOT_CONFIGURED",
];
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = rw_cloud_validate_source_response::ErrorType;
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(rw_cloud_validate_source_response::ErrorType::Unspecified),
"PRIVATELINK_CONNECTION_NOT_FOUND" => Ok(rw_cloud_validate_source_response::ErrorType::PrivatelinkConnectionNotFound),
"PRIVATELINK_UNAVAILABLE" => Ok(rw_cloud_validate_source_response::ErrorType::PrivatelinkUnavailable),
"PRIVATELINK_RESOLVE_ERR" => Ok(rw_cloud_validate_source_response::ErrorType::PrivatelinkResolveErr),
"KAFKA_INVALID_PROPERTIES" => Ok(rw_cloud_validate_source_response::ErrorType::KafkaInvalidProperties),
"KAFKA_TOPIC_NOT_FOUND" => Ok(rw_cloud_validate_source_response::ErrorType::KafkaTopicNotFound),
"KAFKA_BROKER_UNREACHABLE" => Ok(rw_cloud_validate_source_response::ErrorType::KafkaBrokerUnreachable),
"KAFKA_OTHER" => Ok(rw_cloud_validate_source_response::ErrorType::KafkaOther),
"AWS_CLIENT_NOT_CONFIGURED" => Ok(rw_cloud_validate_source_response::ErrorType::AwsClientNotConfigured),
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
}
}
}
deserializer.deserialize_any(GeneratedVisitor)
}
}
impl serde::Serialize for SourceType {
#[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::Kafka => "KAFKA",
};
serializer.serialize_str(variant)
}
}
impl<'de> serde::Deserialize<'de> for SourceType {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"UNSPECIFIED",
"KAFKA",
];
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = SourceType;
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(SourceType::Unspecified),
"KAFKA" => Ok(SourceType::Kafka),
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
}
}
}
deserializer.deserialize_any(GeneratedVisitor)
}
}