#[derive(Clone, PartialEq, Default)]
#[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
#[cfg_attr(feature = "json", serde(default))]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct Tile {
#[cfg_attr(
feature = "json",
serde(
rename = "layers",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
deserialize_with = "::buffa::json_helpers::null_as_default"
)
)]
pub layers: ::buffa::alloc::vec::Vec<tile::Layer>,
}
impl ::core::fmt::Debug for Tile {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("Tile").field("layers", &self.layers).finish()
}
}
impl Tile {
pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile";
}
impl ::buffa::DefaultInstance for Tile {
fn default_instance() -> &'static Self {
static VALUE: ::buffa::__private::OnceBox<Tile> = ::buffa::__private::OnceBox::new();
VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
}
}
impl ::buffa::MessageName for Tile {
const PACKAGE: &'static str = "vector_tile";
const NAME: &'static str = "Tile";
const FULL_NAME: &'static str = "vector_tile.Tile";
const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile";
}
impl ::buffa::Message for Tile {
#[allow(clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
for v in &self.layers {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size
}
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.layers {
::buffa::encoding::Tag::new(
3u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
v.write_to(__cache, buf);
}
}
fn merge_field(
&mut self,
tag: ::buffa::encoding::Tag,
buf: &mut impl ::buffa::bytes::Buf,
depth: u32,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::bytes::Buf as _;
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match tag.field_number() {
3u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 3u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
let mut elem = ::core::default::Default::default();
::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
self.layers.push(elem);
}
_ => {
::buffa::encoding::skip_field_depth(tag, buf, depth)?;
}
}
::core::result::Result::Ok(())
}
fn clear(&mut self) {
self.layers.clear();
}
}
#[cfg(feature = "json")]
impl ::buffa::json_helpers::ProtoElemJson for Tile {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
#[cfg(feature = "json")]
#[doc(hidden)]
pub const __TILE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
type_url: "type.googleapis.com/vector_tile.Tile",
to_json: ::buffa::type_registry::any_to_json::<Tile>,
from_json: ::buffa::type_registry::any_from_json::<Tile>,
is_wkt: false,
};
pub mod tile {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
#[repr(i32)]
pub enum GeomType {
UNKNOWN = 0i32,
POINT = 1i32,
LINESTRING = 2i32,
POLYGON = 3i32,
}
impl GeomType {
#[allow(non_upper_case_globals)]
pub const Unknown: Self = Self::UNKNOWN;
#[allow(non_upper_case_globals)]
pub const Point: Self = Self::POINT;
#[allow(non_upper_case_globals)]
pub const Linestring: Self = Self::LINESTRING;
#[allow(non_upper_case_globals)]
pub const Polygon: Self = Self::POLYGON;
}
impl ::core::default::Default for GeomType {
fn default() -> Self {
Self::UNKNOWN
}
}
#[cfg(feature = "json")]
const _: () = {
impl ::serde::Serialize for GeomType {
fn serialize<S: ::serde::Serializer>(
&self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
s.serialize_str(::buffa::Enumeration::proto_name(self))
}
}
impl<'de> ::serde::Deserialize<'de> for GeomType {
fn deserialize<D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
struct _V;
impl ::serde::de::Visitor<'_> for _V {
type Value = GeomType;
fn expecting(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.write_str(
concat!(
"a string, integer, or null for ", stringify!(GeomType)
),
)
}
fn visit_str<E: ::serde::de::Error>(
self,
v: &str,
) -> ::core::result::Result<GeomType, E> {
<GeomType as ::buffa::Enumeration>::from_proto_name(v)
.ok_or_else(|| {
::serde::de::Error::unknown_variant(v, &[])
})
}
fn visit_i64<E: ::serde::de::Error>(
self,
v: i64,
) -> ::core::result::Result<GeomType, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<GeomType as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_u64<E: ::serde::de::Error>(
self,
v: u64,
) -> ::core::result::Result<GeomType, E> {
let v32 = i32::try_from(v)
.map_err(|_| {
::serde::de::Error::custom(
::buffa::alloc::format!("enum value {v} out of i32 range"),
)
})?;
<GeomType as ::buffa::Enumeration>::from_i32(v32)
.ok_or_else(|| {
::serde::de::Error::custom(
::buffa::alloc::format!("unknown enum value {v32}"),
)
})
}
fn visit_unit<E: ::serde::de::Error>(
self,
) -> ::core::result::Result<GeomType, E> {
::core::result::Result::Ok(::core::default::Default::default())
}
}
d.deserialize_any(_V)
}
}
impl ::buffa::json_helpers::ProtoElemJson for GeomType {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
};
impl ::buffa::Enumeration for GeomType {
fn from_i32(value: i32) -> ::core::option::Option<Self> {
match value {
0i32 => ::core::option::Option::Some(Self::UNKNOWN),
1i32 => ::core::option::Option::Some(Self::POINT),
2i32 => ::core::option::Option::Some(Self::LINESTRING),
3i32 => ::core::option::Option::Some(Self::POLYGON),
_ => ::core::option::Option::None,
}
}
fn to_i32(&self) -> i32 {
*self as i32
}
fn proto_name(&self) -> &'static str {
match self {
Self::UNKNOWN => "UNKNOWN",
Self::POINT => "POINT",
Self::LINESTRING => "LINESTRING",
Self::POLYGON => "POLYGON",
}
}
fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
match name {
"UNKNOWN" => ::core::option::Option::Some(Self::UNKNOWN),
"POINT" => ::core::option::Option::Some(Self::POINT),
"LINESTRING" => ::core::option::Option::Some(Self::LINESTRING),
"POLYGON" => ::core::option::Option::Some(Self::POLYGON),
_ => ::core::option::Option::None,
}
}
fn values() -> &'static [Self] {
&[Self::UNKNOWN, Self::POINT, Self::LINESTRING, Self::POLYGON]
}
}
#[derive(Clone, PartialEq, Default)]
#[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
#[cfg_attr(feature = "json", serde(default))]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct Value {
#[cfg_attr(
feature = "json",
serde(
rename = "stringValue",
alias = "string_value",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub string_value: ::core::option::Option<::buffa::alloc::string::String>,
#[cfg_attr(
feature = "json",
serde(
rename = "floatValue",
alias = "float_value",
with = "::buffa::json_helpers::opt_float",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub float_value: ::core::option::Option<f32>,
#[cfg_attr(
feature = "json",
serde(
rename = "doubleValue",
alias = "double_value",
with = "::buffa::json_helpers::opt_double",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub double_value: ::core::option::Option<f64>,
#[cfg_attr(
feature = "json",
serde(
rename = "intValue",
alias = "int_value",
with = "::buffa::json_helpers::opt_int64",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub int_value: ::core::option::Option<i64>,
#[cfg_attr(
feature = "json",
serde(
rename = "uintValue",
alias = "uint_value",
with = "::buffa::json_helpers::opt_uint64",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub uint_value: ::core::option::Option<u64>,
#[cfg_attr(
feature = "json",
serde(
rename = "sintValue",
alias = "sint_value",
with = "::buffa::json_helpers::opt_int64",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub sint_value: ::core::option::Option<i64>,
#[cfg_attr(
feature = "json",
serde(
rename = "boolValue",
alias = "bool_value",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub bool_value: ::core::option::Option<bool>,
}
impl ::core::fmt::Debug for Value {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("Value")
.field("string_value", &self.string_value)
.field("float_value", &self.float_value)
.field("double_value", &self.double_value)
.field("int_value", &self.int_value)
.field("uint_value", &self.uint_value)
.field("sint_value", &self.sint_value)
.field("bool_value", &self.bool_value)
.finish()
}
}
impl Value {
pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Value";
}
impl Value {
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_string_value(
mut self,
value: impl Into<::buffa::alloc::string::String>,
) -> Self {
self.string_value = Some(value.into());
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_float_value(mut self, value: f32) -> Self {
self.float_value = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_double_value(mut self, value: f64) -> Self {
self.double_value = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_int_value(mut self, value: i64) -> Self {
self.int_value = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_uint_value(mut self, value: u64) -> Self {
self.uint_value = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_sint_value(mut self, value: i64) -> Self {
self.sint_value = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_bool_value(mut self, value: bool) -> Self {
self.bool_value = Some(value);
self
}
}
impl ::buffa::DefaultInstance for Value {
fn default_instance() -> &'static Self {
static VALUE: ::buffa::__private::OnceBox<Value> = ::buffa::__private::OnceBox::new();
VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
}
}
impl ::buffa::MessageName for Value {
const PACKAGE: &'static str = "vector_tile";
const NAME: &'static str = "Tile.Value";
const FULL_NAME: &'static str = "vector_tile.Tile.Value";
const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Value";
}
impl ::buffa::Message for Value {
#[allow(clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
if let Some(ref v) = self.string_value {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.float_value.is_some() {
size += 1u32 + ::buffa::types::FIXED32_ENCODED_LEN as u32;
}
if self.double_value.is_some() {
size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
}
if let Some(v) = self.int_value {
size += 1u32 + ::buffa::types::int64_encoded_len(v) as u32;
}
if let Some(v) = self.uint_value {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.sint_value {
size += 1u32 + ::buffa::types::sint64_encoded_len(v) as u32;
}
if self.bool_value.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
size
}
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.string_value {
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::types::encode_string(v, buf);
}
if let Some(v) = self.float_value {
::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Fixed32)
.encode(buf);
::buffa::types::encode_float(v, buf);
}
if let Some(v) = self.double_value {
::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Fixed64)
.encode(buf);
::buffa::types::encode_double(v, buf);
}
if let Some(v) = self.int_value {
::buffa::encoding::Tag::new(4u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_int64(v, buf);
}
if let Some(v) = self.uint_value {
::buffa::encoding::Tag::new(5u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_uint64(v, buf);
}
if let Some(v) = self.sint_value {
::buffa::encoding::Tag::new(6u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_sint64(v, buf);
}
if let Some(v) = self.bool_value {
::buffa::encoding::Tag::new(7u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_bool(v, buf);
}
}
fn merge_field(
&mut self,
tag: ::buffa::encoding::Tag,
buf: &mut impl ::buffa::bytes::Buf,
depth: u32,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::bytes::Buf as _;
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match tag.field_number() {
1u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 1u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
::buffa::types::merge_string(
self
.string_value
.get_or_insert_with(::buffa::alloc::string::String::new),
buf,
)?;
}
2u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Fixed32 {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 2u32,
expected: 5u8,
actual: tag.wire_type() as u8,
});
}
self.float_value = ::core::option::Option::Some(
::buffa::types::decode_float(buf)?,
);
}
3u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 3u32,
expected: 1u8,
actual: tag.wire_type() as u8,
});
}
self.double_value = ::core::option::Option::Some(
::buffa::types::decode_double(buf)?,
);
}
4u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 4u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.int_value = ::core::option::Option::Some(
::buffa::types::decode_int64(buf)?,
);
}
5u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 5u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.uint_value = ::core::option::Option::Some(
::buffa::types::decode_uint64(buf)?,
);
}
6u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 6u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.sint_value = ::core::option::Option::Some(
::buffa::types::decode_sint64(buf)?,
);
}
7u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 7u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.bool_value = ::core::option::Option::Some(
::buffa::types::decode_bool(buf)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, buf, depth)?;
}
}
::core::result::Result::Ok(())
}
fn clear(&mut self) {
self.string_value = ::core::option::Option::None;
self.float_value = ::core::option::Option::None;
self.double_value = ::core::option::Option::None;
self.int_value = ::core::option::Option::None;
self.uint_value = ::core::option::Option::None;
self.sint_value = ::core::option::Option::None;
self.bool_value = ::core::option::Option::None;
}
}
#[cfg(feature = "json")]
impl ::buffa::json_helpers::ProtoElemJson for Value {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
#[cfg(feature = "json")]
#[doc(hidden)]
pub const __VALUE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
type_url: "type.googleapis.com/vector_tile.Tile.Value",
to_json: ::buffa::type_registry::any_to_json::<Value>,
from_json: ::buffa::type_registry::any_from_json::<Value>,
is_wkt: false,
};
#[derive(Clone, PartialEq, Default)]
#[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
#[cfg_attr(feature = "json", serde(default))]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct Feature {
#[cfg_attr(
feature = "json",
serde(
rename = "id",
with = "::buffa::json_helpers::opt_uint64",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub id: ::core::option::Option<u64>,
#[cfg_attr(
feature = "json",
serde(
rename = "tags",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
deserialize_with = "::buffa::json_helpers::null_as_default"
)
)]
pub tags: ::buffa::alloc::vec::Vec<u32>,
#[cfg_attr(
feature = "json",
serde(
rename = "type",
with = "::buffa::json_helpers::opt_closed_enum",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub r#type: ::core::option::Option<super::tile::GeomType>,
#[cfg_attr(
feature = "json",
serde(
rename = "geometry",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
deserialize_with = "::buffa::json_helpers::null_as_default"
)
)]
pub geometry: ::buffa::alloc::vec::Vec<u32>,
}
impl ::core::fmt::Debug for Feature {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("Feature")
.field("id", &self.id)
.field("tags", &self.tags)
.field("type", &self.r#type)
.field("geometry", &self.geometry)
.finish()
}
}
impl Feature {
pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Feature";
}
impl Feature {
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_id(mut self, value: u64) -> Self {
self.id = Some(value);
self
}
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_type(mut self, value: impl Into<super::tile::GeomType>) -> Self {
self.r#type = Some(value.into());
self
}
}
impl ::buffa::DefaultInstance for Feature {
fn default_instance() -> &'static Self {
static VALUE: ::buffa::__private::OnceBox<Feature> = ::buffa::__private::OnceBox::new();
VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
}
}
impl ::buffa::MessageName for Feature {
const PACKAGE: &'static str = "vector_tile";
const NAME: &'static str = "Tile.Feature";
const FULL_NAME: &'static str = "vector_tile.Tile.Feature";
const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Feature";
}
impl ::buffa::Message for Feature {
#[allow(clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
if let Some(v) = self.id {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if !self.tags.is_empty() {
let payload: u32 = self
.tags
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u32)
.sum::<u32>();
size
+= 1u32 + ::buffa::encoding::varint_len(payload as u64) as u32
+ payload;
}
if let Some(ref v) = self.r#type {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if !self.geometry.is_empty() {
let payload: u32 = self
.geometry
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u32)
.sum::<u32>();
size
+= 1u32 + ::buffa::encoding::varint_len(payload as u64) as u32
+ payload;
}
size
}
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.id {
::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_uint64(v, buf);
}
if !self.tags.is_empty() {
let payload: u32 = self
.tags
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u32)
.sum::<u32>();
::buffa::encoding::Tag::new(
2u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(payload as u64, buf);
for &v in &self.tags {
::buffa::types::encode_uint32(v, buf);
}
}
if let Some(ref v) = self.r#type {
::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_int32(v.to_i32(), buf);
}
if !self.geometry.is_empty() {
let payload: u32 = self
.geometry
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u32)
.sum::<u32>();
::buffa::encoding::Tag::new(
4u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(payload as u64, buf);
for &v in &self.geometry {
::buffa::types::encode_uint32(v, buf);
}
}
}
fn merge_field(
&mut self,
tag: ::buffa::encoding::Tag,
buf: &mut impl ::buffa::bytes::Buf,
depth: u32,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::bytes::Buf as _;
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match tag.field_number() {
1u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 1u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.id = ::core::option::Option::Some(
::buffa::types::decode_uint64(buf)?,
);
}
2u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let len = ::buffa::encoding::decode_varint(buf)?;
let len = usize::try_from(len)
.map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
if buf.remaining() < len {
return ::core::result::Result::Err(
::buffa::DecodeError::UnexpectedEof,
);
}
self.tags.reserve(len);
let mut limited = buf.take(len);
while limited.has_remaining() {
self.tags.push(::buffa::types::decode_uint32(&mut limited)?);
}
let leftover = limited.remaining();
if leftover > 0 {
limited.advance(leftover);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
self.tags.push(::buffa::types::decode_uint32(buf)?);
} else {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 2u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
}
3u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 3u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
let __raw = ::buffa::types::decode_int32(buf)?;
if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
__raw,
) {
self.r#type = ::core::option::Option::Some(__v);
} else {}
}
4u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let len = ::buffa::encoding::decode_varint(buf)?;
let len = usize::try_from(len)
.map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
if buf.remaining() < len {
return ::core::result::Result::Err(
::buffa::DecodeError::UnexpectedEof,
);
}
self.geometry.reserve(len);
let mut limited = buf.take(len);
while limited.has_remaining() {
self.geometry
.push(::buffa::types::decode_uint32(&mut limited)?);
}
let leftover = limited.remaining();
if leftover > 0 {
limited.advance(leftover);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
self.geometry.push(::buffa::types::decode_uint32(buf)?);
} else {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 4u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, buf, depth)?;
}
}
::core::result::Result::Ok(())
}
fn clear(&mut self) {
self.id = ::core::option::Option::None;
self.tags.clear();
self.r#type = ::core::option::Option::None;
self.geometry.clear();
}
}
#[cfg(feature = "json")]
impl ::buffa::json_helpers::ProtoElemJson for Feature {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
#[cfg(feature = "json")]
#[doc(hidden)]
pub const __FEATURE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
type_url: "type.googleapis.com/vector_tile.Tile.Feature",
to_json: ::buffa::type_registry::any_to_json::<Feature>,
from_json: ::buffa::type_registry::any_from_json::<Feature>,
is_wkt: false,
};
#[derive(Clone, PartialEq)]
#[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
#[cfg_attr(feature = "json", serde(default))]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct Layer {
#[cfg_attr(
feature = "json",
serde(rename = "version", with = "::buffa::json_helpers::uint32")
)]
pub version: u32,
#[cfg_attr(
feature = "json",
serde(rename = "name", with = "::buffa::json_helpers::proto_string")
)]
pub name: ::buffa::alloc::string::String,
#[cfg_attr(
feature = "json",
serde(
rename = "features",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
deserialize_with = "::buffa::json_helpers::null_as_default"
)
)]
pub features: ::buffa::alloc::vec::Vec<super::tile::Feature>,
#[cfg_attr(
feature = "json",
serde(
rename = "keys",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
deserialize_with = "::buffa::json_helpers::null_as_default"
)
)]
pub keys: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>,
#[cfg_attr(
feature = "json",
serde(
rename = "values",
skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
deserialize_with = "::buffa::json_helpers::null_as_default"
)
)]
pub values: ::buffa::alloc::vec::Vec<super::tile::Value>,
#[cfg_attr(
feature = "json",
serde(
rename = "extent",
with = "::buffa::json_helpers::opt_uint32",
skip_serializing_if = "::core::option::Option::is_none"
)
)]
pub extent: ::core::option::Option<u32>,
}
impl ::core::fmt::Debug for Layer {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("Layer")
.field("version", &self.version)
.field("name", &self.name)
.field("features", &self.features)
.field("keys", &self.keys)
.field("values", &self.values)
.field("extent", &self.extent)
.finish()
}
}
impl ::core::default::Default for Layer {
fn default() -> Self {
Self {
version: 1u32,
name: ::core::default::Default::default(),
features: ::core::default::Default::default(),
keys: ::core::default::Default::default(),
values: ::core::default::Default::default(),
extent: ::core::default::Default::default(),
}
}
}
impl Layer {
pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Layer";
}
impl Layer {
#[must_use = "with_* setters return `self` by value; assign or chain the result"]
#[inline]
pub fn with_extent(mut self, value: u32) -> Self {
self.extent = Some(value);
self
}
}
impl ::buffa::DefaultInstance for Layer {
fn default_instance() -> &'static Self {
static VALUE: ::buffa::__private::OnceBox<Layer> = ::buffa::__private::OnceBox::new();
VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
}
}
impl ::buffa::MessageName for Layer {
const PACKAGE: &'static str = "vector_tile";
const NAME: &'static str = "Tile.Layer";
const FULL_NAME: &'static str = "vector_tile.Tile.Layer";
const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Layer";
}
impl ::buffa::Message for Layer {
#[allow(clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
size += 1u32 + ::buffa::types::string_encoded_len(&self.name) as u32;
for v in &self.features {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.keys {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.values {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if let Some(v) = self.extent {
size += 1u32 + ::buffa::types::uint32_encoded_len(v) as u32;
}
size += 1u32 + ::buffa::types::uint32_encoded_len(self.version) as u32;
size
}
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::types::encode_string(&self.name, buf);
for v in &self.features {
::buffa::encoding::Tag::new(
2u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
v.write_to(__cache, buf);
}
for v in &self.keys {
::buffa::encoding::Tag::new(
3u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::types::encode_string(v, buf);
}
for v in &self.values {
::buffa::encoding::Tag::new(
4u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
v.write_to(__cache, buf);
}
if let Some(v) = self.extent {
::buffa::encoding::Tag::new(5u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_uint32(v, buf);
}
::buffa::encoding::Tag::new(15u32, ::buffa::encoding::WireType::Varint)
.encode(buf);
::buffa::types::encode_uint32(self.version, buf);
}
fn merge_field(
&mut self,
tag: ::buffa::encoding::Tag,
buf: &mut impl ::buffa::bytes::Buf,
depth: u32,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::bytes::Buf as _;
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match tag.field_number() {
1u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 1u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
::buffa::types::merge_string(&mut self.name, buf)?;
}
2u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 2u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
let mut elem = ::core::default::Default::default();
::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
self.features.push(elem);
}
3u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 3u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
self.keys.push(::buffa::types::decode_string(buf)?);
}
4u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 4u32,
expected: 2u8,
actual: tag.wire_type() as u8,
});
}
let mut elem = ::core::default::Default::default();
::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
self.values.push(elem);
}
5u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 5u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.extent = ::core::option::Option::Some(
::buffa::types::decode_uint32(buf)?,
);
}
15u32 => {
if tag.wire_type() != ::buffa::encoding::WireType::Varint {
return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
field_number: 15u32,
expected: 0u8,
actual: tag.wire_type() as u8,
});
}
self.version = ::buffa::types::decode_uint32(buf)?;
}
_ => {
::buffa::encoding::skip_field_depth(tag, buf, depth)?;
}
}
::core::result::Result::Ok(())
}
fn clear(&mut self) {
self.name.clear();
self.features.clear();
self.keys.clear();
self.values.clear();
self.extent = ::core::option::Option::None;
self.version = 1u32;
}
}
#[cfg(feature = "json")]
impl ::buffa::json_helpers::ProtoElemJson for Layer {
fn serialize_proto_json<S: ::serde::Serializer>(
v: &Self,
s: S,
) -> ::core::result::Result<S::Ok, S::Error> {
::serde::Serialize::serialize(v, s)
}
fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
d: D,
) -> ::core::result::Result<Self, D::Error> {
<Self as ::serde::Deserialize>::deserialize(d)
}
}
#[cfg(feature = "json")]
#[doc(hidden)]
pub const __LAYER_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
type_url: "type.googleapis.com/vector_tile.Tile.Layer",
to_json: ::buffa::type_registry::any_to_json::<Layer>,
from_json: ::buffa::type_registry::any_from_json::<Layer>,
is_wkt: false,
};
#[cfg(feature = "views")]
#[doc(inline)]
pub use super::__buffa::view::tile::ValueView;
#[cfg(feature = "views")]
#[doc(inline)]
pub use super::__buffa::view::tile::ValueOwnedView;
#[cfg(feature = "views")]
#[doc(inline)]
pub use super::__buffa::view::tile::FeatureView;
#[cfg(feature = "views")]
#[doc(inline)]
pub use super::__buffa::view::tile::FeatureOwnedView;
#[cfg(feature = "views")]
#[doc(inline)]
pub use super::__buffa::view::tile::LayerView;
#[cfg(feature = "views")]
#[doc(inline)]
pub use super::__buffa::view::tile::LayerOwnedView;
}