use crate::java_binding::*;
impl serde::Serialize for KeyRange {
#[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.left.is_empty() {
len += 1;
}
if !self.right.is_empty() {
len += 1;
}
if self.left_bound != 0 {
len += 1;
}
if self.right_bound != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("java_binding.KeyRange", len)?;
if !self.left.is_empty() {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("left", pbjson::private::base64::encode(&self.left).as_str())?;
}
if !self.right.is_empty() {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("right", pbjson::private::base64::encode(&self.right).as_str())?;
}
if self.left_bound != 0 {
let v = key_range::Bound::try_from(self.left_bound)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.left_bound)))?;
struct_ser.serialize_field("leftBound", &v)?;
}
if self.right_bound != 0 {
let v = key_range::Bound::try_from(self.right_bound)
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", self.right_bound)))?;
struct_ser.serialize_field("rightBound", &v)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for KeyRange {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"left",
"right",
"left_bound",
"leftBound",
"right_bound",
"rightBound",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
Left,
Right,
LeftBound,
RightBound,
}
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 {
"left" => Ok(GeneratedField::Left),
"right" => Ok(GeneratedField::Right),
"leftBound" | "left_bound" => Ok(GeneratedField::LeftBound),
"rightBound" | "right_bound" => Ok(GeneratedField::RightBound),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = KeyRange;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct java_binding.KeyRange")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<KeyRange, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut left__ = None;
let mut right__ = None;
let mut left_bound__ = None;
let mut right_bound__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Left => {
if left__.is_some() {
return Err(serde::de::Error::duplicate_field("left"));
}
left__ =
Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
}
GeneratedField::Right => {
if right__.is_some() {
return Err(serde::de::Error::duplicate_field("right"));
}
right__ =
Some(map_.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
}
GeneratedField::LeftBound => {
if left_bound__.is_some() {
return Err(serde::de::Error::duplicate_field("leftBound"));
}
left_bound__ = Some(map_.next_value::<key_range::Bound>()? as i32);
}
GeneratedField::RightBound => {
if right_bound__.is_some() {
return Err(serde::de::Error::duplicate_field("rightBound"));
}
right_bound__ = Some(map_.next_value::<key_range::Bound>()? as i32);
}
}
}
Ok(KeyRange {
left: left__.unwrap_or_default(),
right: right__.unwrap_or_default(),
left_bound: left_bound__.unwrap_or_default(),
right_bound: right_bound__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("java_binding.KeyRange", FIELDS, GeneratedVisitor)
}
}
impl serde::Serialize for key_range::Bound {
#[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::Unbounded => "UNBOUNDED",
Self::Included => "INCLUDED",
Self::Excluded => "EXCLUDED",
};
serializer.serialize_str(variant)
}
}
impl<'de> serde::Deserialize<'de> for key_range::Bound {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"UNSPECIFIED",
"UNBOUNDED",
"INCLUDED",
"EXCLUDED",
];
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = key_range::Bound;
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(key_range::Bound::Unspecified),
"UNBOUNDED" => Ok(key_range::Bound::Unbounded),
"INCLUDED" => Ok(key_range::Bound::Included),
"EXCLUDED" => Ok(key_range::Bound::Excluded),
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
}
}
}
deserializer.deserialize_any(GeneratedVisitor)
}
}
impl serde::Serialize for ReadPlan {
#[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.object_store_url.is_empty() {
len += 1;
}
if !self.data_dir.is_empty() {
len += 1;
}
if self.key_range.is_some() {
len += 1;
}
if self.table_id != 0 {
len += 1;
}
if self.epoch != 0 {
len += 1;
}
if self.version.is_some() {
len += 1;
}
if self.table_catalog.is_some() {
len += 1;
}
if !self.vnode_ids.is_empty() {
len += 1;
}
if self.use_new_object_prefix_strategy {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("java_binding.ReadPlan", len)?;
if !self.object_store_url.is_empty() {
struct_ser.serialize_field("objectStoreUrl", &self.object_store_url)?;
}
if !self.data_dir.is_empty() {
struct_ser.serialize_field("dataDir", &self.data_dir)?;
}
if let Some(v) = self.key_range.as_ref() {
struct_ser.serialize_field("keyRange", v)?;
}
if self.table_id != 0 {
struct_ser.serialize_field("tableId", &self.table_id)?;
}
if self.epoch != 0 {
#[allow(clippy::needless_borrow)]
#[allow(clippy::needless_borrows_for_generic_args)]
struct_ser.serialize_field("epoch", ToString::to_string(&self.epoch).as_str())?;
}
if let Some(v) = self.version.as_ref() {
struct_ser.serialize_field("version", v)?;
}
if let Some(v) = self.table_catalog.as_ref() {
struct_ser.serialize_field("tableCatalog", v)?;
}
if !self.vnode_ids.is_empty() {
struct_ser.serialize_field("vnodeIds", &self.vnode_ids)?;
}
if self.use_new_object_prefix_strategy {
struct_ser.serialize_field("useNewObjectPrefixStrategy", &self.use_new_object_prefix_strategy)?;
}
struct_ser.end()
}
}
impl<'de> serde::Deserialize<'de> for ReadPlan {
#[allow(deprecated)]
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
const FIELDS: &[&str] = &[
"object_store_url",
"objectStoreUrl",
"data_dir",
"dataDir",
"key_range",
"keyRange",
"table_id",
"tableId",
"epoch",
"version",
"table_catalog",
"tableCatalog",
"vnode_ids",
"vnodeIds",
"use_new_object_prefix_strategy",
"useNewObjectPrefixStrategy",
];
#[allow(clippy::enum_variant_names)]
enum GeneratedField {
ObjectStoreUrl,
DataDir,
KeyRange,
TableId,
Epoch,
Version,
TableCatalog,
VnodeIds,
UseNewObjectPrefixStrategy,
}
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 {
"objectStoreUrl" | "object_store_url" => Ok(GeneratedField::ObjectStoreUrl),
"dataDir" | "data_dir" => Ok(GeneratedField::DataDir),
"keyRange" | "key_range" => Ok(GeneratedField::KeyRange),
"tableId" | "table_id" => Ok(GeneratedField::TableId),
"epoch" => Ok(GeneratedField::Epoch),
"version" => Ok(GeneratedField::Version),
"tableCatalog" | "table_catalog" => Ok(GeneratedField::TableCatalog),
"vnodeIds" | "vnode_ids" => Ok(GeneratedField::VnodeIds),
"useNewObjectPrefixStrategy" | "use_new_object_prefix_strategy" => Ok(GeneratedField::UseNewObjectPrefixStrategy),
_ => Err(serde::de::Error::unknown_field(value, FIELDS)),
}
}
}
deserializer.deserialize_identifier(GeneratedVisitor)
}
}
struct GeneratedVisitor;
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
type Value = ReadPlan;
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("struct java_binding.ReadPlan")
}
fn visit_map<V>(self, mut map_: V) -> std::result::Result<ReadPlan, V::Error>
where
V: serde::de::MapAccess<'de>,
{
let mut object_store_url__ = None;
let mut data_dir__ = None;
let mut key_range__ = None;
let mut table_id__ = None;
let mut epoch__ = None;
let mut version__ = None;
let mut table_catalog__ = None;
let mut vnode_ids__ = None;
let mut use_new_object_prefix_strategy__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::ObjectStoreUrl => {
if object_store_url__.is_some() {
return Err(serde::de::Error::duplicate_field("objectStoreUrl"));
}
object_store_url__ = Some(map_.next_value()?);
}
GeneratedField::DataDir => {
if data_dir__.is_some() {
return Err(serde::de::Error::duplicate_field("dataDir"));
}
data_dir__ = Some(map_.next_value()?);
}
GeneratedField::KeyRange => {
if key_range__.is_some() {
return Err(serde::de::Error::duplicate_field("keyRange"));
}
key_range__ = map_.next_value()?;
}
GeneratedField::TableId => {
if table_id__.is_some() {
return Err(serde::de::Error::duplicate_field("tableId"));
}
table_id__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::Epoch => {
if epoch__.is_some() {
return Err(serde::de::Error::duplicate_field("epoch"));
}
epoch__ =
Some(map_.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
GeneratedField::Version => {
if version__.is_some() {
return Err(serde::de::Error::duplicate_field("version"));
}
version__ = map_.next_value()?;
}
GeneratedField::TableCatalog => {
if table_catalog__.is_some() {
return Err(serde::de::Error::duplicate_field("tableCatalog"));
}
table_catalog__ = map_.next_value()?;
}
GeneratedField::VnodeIds => {
if vnode_ids__.is_some() {
return Err(serde::de::Error::duplicate_field("vnodeIds"));
}
vnode_ids__ =
Some(map_.next_value::<Vec<::pbjson::private::NumberDeserialize<_>>>()?
.into_iter().map(|x| x.0).collect())
;
}
GeneratedField::UseNewObjectPrefixStrategy => {
if use_new_object_prefix_strategy__.is_some() {
return Err(serde::de::Error::duplicate_field("useNewObjectPrefixStrategy"));
}
use_new_object_prefix_strategy__ = Some(map_.next_value()?);
}
}
}
Ok(ReadPlan {
object_store_url: object_store_url__.unwrap_or_default(),
data_dir: data_dir__.unwrap_or_default(),
key_range: key_range__,
table_id: table_id__.unwrap_or_default(),
epoch: epoch__.unwrap_or_default(),
version: version__,
table_catalog: table_catalog__,
vnode_ids: vnode_ids__.unwrap_or_default(),
use_new_object_prefix_strategy: use_new_object_prefix_strategy__.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct("java_binding.ReadPlan", FIELDS, GeneratedVisitor)
}
}