1#[derive(Clone, PartialEq, Default)]
5#[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
6#[cfg_attr(feature = "json", serde(default))]
7#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
8pub struct Tile {
9 #[cfg_attr(
11 feature = "json",
12 serde(
13 rename = "layers",
14 skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
15 deserialize_with = "::buffa::json_helpers::null_as_default"
16 )
17 )]
18 pub layers: ::buffa::alloc::vec::Vec<tile::Layer>,
19}
20impl ::core::fmt::Debug for Tile {
21 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
22 f.debug_struct("Tile").field("layers", &self.layers).finish()
23 }
24}
25impl Tile {
26 pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile";
31}
32::buffa::impl_default_instance!(Tile);
33impl ::buffa::MessageName for Tile {
34 const PACKAGE: &'static str = "vector_tile";
35 const NAME: &'static str = "Tile";
36 const FULL_NAME: &'static str = "vector_tile.Tile";
37 const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile";
38}
39impl ::buffa::Message for Tile {
40 #[allow(clippy::let_and_return)]
48 fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
49 #[allow(unused_imports)]
50 use ::buffa::Enumeration as _;
51 let mut size = 0u64;
52 for v in &self.layers {
53 let __slot = __cache.reserve();
54 let inner_size = v.compute_size(__cache);
55 __cache.set(__slot, inner_size);
56 size
57 += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
58 + inner_size as u64;
59 }
60 ::buffa::saturate_size(size)
61 }
62 fn write_to(
63 &self,
64 __cache: &mut ::buffa::SizeCache,
65 buf: &mut impl ::buffa::EncodeSink,
66 ) {
67 #[allow(unused_imports)]
68 use ::buffa::Enumeration as _;
69 for v in &self.layers {
70 ::buffa::types::put_len_delimited_header(
71 3u32,
72 u64::from(__cache.consume_next()),
73 buf,
74 );
75 v.write_to(__cache, buf);
76 }
77 }
78 fn merge_field(
79 &mut self,
80 tag: ::buffa::encoding::Tag,
81 buf: &mut impl ::buffa::bytes::Buf,
82 ctx: ::buffa::DecodeContext<'_>,
83 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
84 #[allow(unused_imports)]
85 use ::buffa::bytes::Buf as _;
86 #[allow(unused_imports)]
87 use ::buffa::Enumeration as _;
88 match tag.field_number() {
89 3u32 => {
90 ::buffa::encoding::check_wire_type(
91 tag,
92 ::buffa::encoding::WireType::LengthDelimited,
93 )?;
94 let mut elem = ::core::default::Default::default();
95 ctx.register_element_memory(
96 ::buffa::__private::element_footprint(&elem),
97 )?;
98 ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?;
99 self.layers.push(elem);
100 }
101 _ => {
102 ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
103 }
104 }
105 ::core::result::Result::Ok(())
106 }
107 fn clear(&mut self) {
108 self.layers.clear();
109 }
110}
111#[cfg(feature = "json")]
112impl ::buffa::json_helpers::ProtoElemJson for Tile {
113 fn serialize_proto_json<S: ::serde::Serializer>(
114 v: &Self,
115 s: S,
116 ) -> ::core::result::Result<S::Ok, S::Error> {
117 ::serde::Serialize::serialize(v, s)
118 }
119 fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
120 d: D,
121 ) -> ::core::result::Result<Self, D::Error> {
122 <Self as ::serde::Deserialize>::deserialize(d)
123 }
124}
125#[cfg(feature = "json")]
126#[doc(hidden)]
127pub const __TILE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
128 type_url: "type.googleapis.com/vector_tile.Tile",
129 to_json: ::buffa::type_registry::any_to_json::<Tile>,
130 from_json: ::buffa::type_registry::any_from_json::<Tile>,
131 is_wkt: false,
132};
133pub mod tile {
134 #[allow(unused_imports)]
135 use super::*;
136 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
138 #[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
139 #[repr(i32)]
140 pub enum GeomType {
141 UNKNOWN = 0i32,
142 POINT = 1i32,
143 LINESTRING = 2i32,
144 POLYGON = 3i32,
145 }
146 impl GeomType {
147 #[allow(non_upper_case_globals)]
149 pub const Unknown: Self = Self::UNKNOWN;
150 #[allow(non_upper_case_globals)]
152 pub const Point: Self = Self::POINT;
153 #[allow(non_upper_case_globals)]
155 pub const Linestring: Self = Self::LINESTRING;
156 #[allow(non_upper_case_globals)]
158 pub const Polygon: Self = Self::POLYGON;
159 }
160 impl ::core::default::Default for GeomType {
161 fn default() -> Self {
162 Self::UNKNOWN
163 }
164 }
165 #[cfg(feature = "json")]
166 const _: () = {
167 impl ::serde::Serialize for GeomType {
168 fn serialize<S: ::serde::Serializer>(
169 &self,
170 s: S,
171 ) -> ::core::result::Result<S::Ok, S::Error> {
172 s.serialize_str(::buffa::Enumeration::proto_name(self))
173 }
174 }
175 impl<'de> ::serde::Deserialize<'de> for GeomType {
176 fn deserialize<D: ::serde::Deserializer<'de>>(
177 d: D,
178 ) -> ::core::result::Result<Self, D::Error> {
179 struct _V;
180 impl ::serde::de::Visitor<'_> for _V {
181 type Value = GeomType;
182 fn expecting(
183 &self,
184 f: &mut ::core::fmt::Formatter<'_>,
185 ) -> ::core::fmt::Result {
186 f.write_str(
187 concat!(
188 "a string, integer, or null for ", stringify!(GeomType)
189 ),
190 )
191 }
192 fn visit_str<E: ::serde::de::Error>(
193 self,
194 v: &str,
195 ) -> ::core::result::Result<GeomType, E> {
196 <GeomType as ::buffa::Enumeration>::from_proto_name(v)
197 .ok_or_else(|| {
198 ::serde::de::Error::unknown_variant(v, &[])
199 })
200 }
201 fn visit_i64<E: ::serde::de::Error>(
202 self,
203 v: i64,
204 ) -> ::core::result::Result<GeomType, E> {
205 let v32 = i32::try_from(v)
206 .map_err(|_| {
207 ::serde::de::Error::custom(
208 ::buffa::alloc::format!("enum value {v} out of i32 range"),
209 )
210 })?;
211 <GeomType as ::buffa::Enumeration>::from_i32(v32)
212 .ok_or_else(|| {
213 ::serde::de::Error::custom(
214 ::buffa::alloc::format!("unknown enum value {v32}"),
215 )
216 })
217 }
218 fn visit_u64<E: ::serde::de::Error>(
219 self,
220 v: u64,
221 ) -> ::core::result::Result<GeomType, E> {
222 let v32 = i32::try_from(v)
223 .map_err(|_| {
224 ::serde::de::Error::custom(
225 ::buffa::alloc::format!("enum value {v} out of i32 range"),
226 )
227 })?;
228 <GeomType as ::buffa::Enumeration>::from_i32(v32)
229 .ok_or_else(|| {
230 ::serde::de::Error::custom(
231 ::buffa::alloc::format!("unknown enum value {v32}"),
232 )
233 })
234 }
235 fn visit_unit<E: ::serde::de::Error>(
236 self,
237 ) -> ::core::result::Result<GeomType, E> {
238 ::core::result::Result::Ok(::core::default::Default::default())
239 }
240 }
241 d.deserialize_any(_V)
242 }
243 }
244 impl ::buffa::json_helpers::ProtoElemJson for GeomType {
245 fn serialize_proto_json<S: ::serde::Serializer>(
246 v: &Self,
247 s: S,
248 ) -> ::core::result::Result<S::Ok, S::Error> {
249 ::serde::Serialize::serialize(v, s)
250 }
251 fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
252 d: D,
253 ) -> ::core::result::Result<Self, D::Error> {
254 <Self as ::serde::Deserialize>::deserialize(d)
255 }
256 }
257 };
258 impl ::buffa::Enumeration for GeomType {
259 fn from_i32(value: i32) -> ::core::option::Option<Self> {
260 match value {
261 0i32 => ::core::option::Option::Some(Self::UNKNOWN),
262 1i32 => ::core::option::Option::Some(Self::POINT),
263 2i32 => ::core::option::Option::Some(Self::LINESTRING),
264 3i32 => ::core::option::Option::Some(Self::POLYGON),
265 _ => ::core::option::Option::None,
266 }
267 }
268 fn to_i32(&self) -> i32 {
269 *self as i32
270 }
271 fn proto_name(&self) -> &'static str {
272 match self {
273 Self::UNKNOWN => "UNKNOWN",
274 Self::POINT => "POINT",
275 Self::LINESTRING => "LINESTRING",
276 Self::POLYGON => "POLYGON",
277 }
278 }
279 fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
280 match name {
281 "UNKNOWN" => ::core::option::Option::Some(Self::UNKNOWN),
282 "POINT" => ::core::option::Option::Some(Self::POINT),
283 "LINESTRING" => ::core::option::Option::Some(Self::LINESTRING),
284 "POLYGON" => ::core::option::Option::Some(Self::POLYGON),
285 _ => ::core::option::Option::None,
286 }
287 }
288 fn values() -> &'static [Self] {
289 &[Self::UNKNOWN, Self::POINT, Self::LINESTRING, Self::POLYGON]
290 }
291 }
292 #[derive(Clone, PartialEq, Default)]
295 #[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
296 #[cfg_attr(feature = "json", serde(default))]
297 #[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
298 pub struct Value {
299 #[cfg_attr(
303 feature = "json",
304 serde(
305 rename = "stringValue",
306 alias = "string_value",
307 skip_serializing_if = "::core::option::Option::is_none"
308 )
309 )]
310 pub string_value: ::core::option::Option<::buffa::alloc::string::String>,
311 #[cfg_attr(
313 feature = "json",
314 serde(
315 rename = "floatValue",
316 alias = "float_value",
317 with = "::buffa::json_helpers::opt_float",
318 skip_serializing_if = "::core::option::Option::is_none"
319 )
320 )]
321 pub float_value: ::core::option::Option<f32>,
322 #[cfg_attr(
324 feature = "json",
325 serde(
326 rename = "doubleValue",
327 alias = "double_value",
328 with = "::buffa::json_helpers::opt_double",
329 skip_serializing_if = "::core::option::Option::is_none"
330 )
331 )]
332 pub double_value: ::core::option::Option<f64>,
333 #[cfg_attr(
335 feature = "json",
336 serde(
337 rename = "intValue",
338 alias = "int_value",
339 with = "::buffa::json_helpers::opt_int64",
340 skip_serializing_if = "::core::option::Option::is_none"
341 )
342 )]
343 pub int_value: ::core::option::Option<i64>,
344 #[cfg_attr(
346 feature = "json",
347 serde(
348 rename = "uintValue",
349 alias = "uint_value",
350 with = "::buffa::json_helpers::opt_uint64",
351 skip_serializing_if = "::core::option::Option::is_none"
352 )
353 )]
354 pub uint_value: ::core::option::Option<u64>,
355 #[cfg_attr(
357 feature = "json",
358 serde(
359 rename = "sintValue",
360 alias = "sint_value",
361 with = "::buffa::json_helpers::opt_int64",
362 skip_serializing_if = "::core::option::Option::is_none"
363 )
364 )]
365 pub sint_value: ::core::option::Option<i64>,
366 #[cfg_attr(
368 feature = "json",
369 serde(
370 rename = "boolValue",
371 alias = "bool_value",
372 skip_serializing_if = "::core::option::Option::is_none"
373 )
374 )]
375 pub bool_value: ::core::option::Option<bool>,
376 }
377 impl ::core::fmt::Debug for Value {
378 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
379 f.debug_struct("Value")
380 .field("string_value", &self.string_value)
381 .field("float_value", &self.float_value)
382 .field("double_value", &self.double_value)
383 .field("int_value", &self.int_value)
384 .field("uint_value", &self.uint_value)
385 .field("sint_value", &self.sint_value)
386 .field("bool_value", &self.bool_value)
387 .finish()
388 }
389 }
390 impl Value {
391 pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Value";
396 }
397 impl Value {
398 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
399 #[inline]
400 pub fn with_string_value(
402 mut self,
403 value: impl Into<::buffa::alloc::string::String>,
404 ) -> Self {
405 self.string_value = Some(value.into());
406 self
407 }
408 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
409 #[inline]
410 pub fn with_float_value(mut self, value: f32) -> Self {
412 self.float_value = Some(value);
413 self
414 }
415 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
416 #[inline]
417 pub fn with_double_value(mut self, value: f64) -> Self {
419 self.double_value = Some(value);
420 self
421 }
422 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
423 #[inline]
424 pub fn with_int_value(mut self, value: i64) -> Self {
426 self.int_value = Some(value);
427 self
428 }
429 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
430 #[inline]
431 pub fn with_uint_value(mut self, value: u64) -> Self {
433 self.uint_value = Some(value);
434 self
435 }
436 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
437 #[inline]
438 pub fn with_sint_value(mut self, value: i64) -> Self {
440 self.sint_value = Some(value);
441 self
442 }
443 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
444 #[inline]
445 pub fn with_bool_value(mut self, value: bool) -> Self {
447 self.bool_value = Some(value);
448 self
449 }
450 }
451 ::buffa::impl_default_instance!(Value);
452 impl ::buffa::MessageName for Value {
453 const PACKAGE: &'static str = "vector_tile";
454 const NAME: &'static str = "Tile.Value";
455 const FULL_NAME: &'static str = "vector_tile.Tile.Value";
456 const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Value";
457 }
458 impl ::buffa::Message for Value {
459 #[allow(clippy::let_and_return)]
467 fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
468 #[allow(unused_imports)]
469 use ::buffa::Enumeration as _;
470 let mut size = 0u64;
471 if let Some(ref v) = self.string_value {
472 size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
473 }
474 if self.float_value.is_some() {
475 size += 1u64 + ::buffa::types::FIXED32_ENCODED_LEN as u64;
476 }
477 if self.double_value.is_some() {
478 size += 1u64 + ::buffa::types::FIXED64_ENCODED_LEN as u64;
479 }
480 if let Some(v) = self.int_value {
481 size += 1u64 + ::buffa::types::int64_encoded_len(v) as u64;
482 }
483 if let Some(v) = self.uint_value {
484 size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64;
485 }
486 if let Some(v) = self.sint_value {
487 size += 1u64 + ::buffa::types::sint64_encoded_len(v) as u64;
488 }
489 if self.bool_value.is_some() {
490 size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
491 }
492 ::buffa::saturate_size(size)
493 }
494 fn write_to(
495 &self,
496 _cache: &mut ::buffa::SizeCache,
497 buf: &mut impl ::buffa::EncodeSink,
498 ) {
499 #[allow(unused_imports)]
500 use ::buffa::Enumeration as _;
501 if let Some(ref v) = self.string_value {
502 ::buffa::types::put_string_field(1u32, v, buf);
503 }
504 if let Some(v) = self.float_value {
505 ::buffa::types::put_float_field(2u32, v, buf);
506 }
507 if let Some(v) = self.double_value {
508 ::buffa::types::put_double_field(3u32, v, buf);
509 }
510 if let Some(v) = self.int_value {
511 ::buffa::types::put_int64_field(4u32, v, buf);
512 }
513 if let Some(v) = self.uint_value {
514 ::buffa::types::put_uint64_field(5u32, v, buf);
515 }
516 if let Some(v) = self.sint_value {
517 ::buffa::types::put_sint64_field(6u32, v, buf);
518 }
519 if let Some(v) = self.bool_value {
520 ::buffa::types::put_bool_field(7u32, v, buf);
521 }
522 }
523 fn merge_field(
524 &mut self,
525 tag: ::buffa::encoding::Tag,
526 buf: &mut impl ::buffa::bytes::Buf,
527 ctx: ::buffa::DecodeContext<'_>,
528 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
529 #[allow(unused_imports)]
530 use ::buffa::bytes::Buf as _;
531 #[allow(unused_imports)]
532 use ::buffa::Enumeration as _;
533 match tag.field_number() {
534 1u32 => {
535 ::buffa::encoding::check_wire_type(
536 tag,
537 ::buffa::encoding::WireType::LengthDelimited,
538 )?;
539 ::buffa::types::merge_string(
540 self
541 .string_value
542 .get_or_insert_with(::buffa::alloc::string::String::new),
543 buf,
544 )?;
545 }
546 2u32 => {
547 ::buffa::encoding::check_wire_type(
548 tag,
549 ::buffa::encoding::WireType::Fixed32,
550 )?;
551 self.float_value = ::core::option::Option::Some(
552 ::buffa::types::decode_float(buf)?,
553 );
554 }
555 3u32 => {
556 ::buffa::encoding::check_wire_type(
557 tag,
558 ::buffa::encoding::WireType::Fixed64,
559 )?;
560 self.double_value = ::core::option::Option::Some(
561 ::buffa::types::decode_double(buf)?,
562 );
563 }
564 4u32 => {
565 ::buffa::encoding::check_wire_type(
566 tag,
567 ::buffa::encoding::WireType::Varint,
568 )?;
569 self.int_value = ::core::option::Option::Some(
570 ::buffa::types::decode_int64(buf)?,
571 );
572 }
573 5u32 => {
574 ::buffa::encoding::check_wire_type(
575 tag,
576 ::buffa::encoding::WireType::Varint,
577 )?;
578 self.uint_value = ::core::option::Option::Some(
579 ::buffa::types::decode_uint64(buf)?,
580 );
581 }
582 6u32 => {
583 ::buffa::encoding::check_wire_type(
584 tag,
585 ::buffa::encoding::WireType::Varint,
586 )?;
587 self.sint_value = ::core::option::Option::Some(
588 ::buffa::types::decode_sint64(buf)?,
589 );
590 }
591 7u32 => {
592 ::buffa::encoding::check_wire_type(
593 tag,
594 ::buffa::encoding::WireType::Varint,
595 )?;
596 self.bool_value = ::core::option::Option::Some(
597 ::buffa::types::decode_bool(buf)?,
598 );
599 }
600 _ => {
601 ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
602 }
603 }
604 ::core::result::Result::Ok(())
605 }
606 fn clear(&mut self) {
607 self.string_value = ::core::option::Option::None;
608 self.float_value = ::core::option::Option::None;
609 self.double_value = ::core::option::Option::None;
610 self.int_value = ::core::option::Option::None;
611 self.uint_value = ::core::option::Option::None;
612 self.sint_value = ::core::option::Option::None;
613 self.bool_value = ::core::option::Option::None;
614 }
615 }
616 #[cfg(feature = "json")]
617 impl ::buffa::json_helpers::ProtoElemJson for Value {
618 fn serialize_proto_json<S: ::serde::Serializer>(
619 v: &Self,
620 s: S,
621 ) -> ::core::result::Result<S::Ok, S::Error> {
622 ::serde::Serialize::serialize(v, s)
623 }
624 fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
625 d: D,
626 ) -> ::core::result::Result<Self, D::Error> {
627 <Self as ::serde::Deserialize>::deserialize(d)
628 }
629 }
630 #[cfg(feature = "json")]
631 #[doc(hidden)]
632 pub const __VALUE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
633 type_url: "type.googleapis.com/vector_tile.Tile.Value",
634 to_json: ::buffa::type_registry::any_to_json::<Value>,
635 from_json: ::buffa::type_registry::any_from_json::<Value>,
636 is_wkt: false,
637 };
638 #[derive(Clone, PartialEq, Default)]
640 #[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
641 #[cfg_attr(feature = "json", serde(default))]
642 #[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
643 pub struct Feature {
644 #[cfg_attr(
646 feature = "json",
647 serde(
648 rename = "id",
649 with = "::buffa::json_helpers::opt_uint64",
650 skip_serializing_if = "::core::option::Option::is_none"
651 )
652 )]
653 pub id: ::core::option::Option<u64>,
654 #[cfg_attr(
661 feature = "json",
662 serde(
663 rename = "tags",
664 skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
665 deserialize_with = "::buffa::json_helpers::null_as_default"
666 )
667 )]
668 pub tags: ::buffa::alloc::vec::Vec<u32>,
669 #[cfg_attr(
673 feature = "json",
674 serde(
675 rename = "type",
676 with = "::buffa::json_helpers::opt_closed_enum",
677 skip_serializing_if = "::core::option::Option::is_none"
678 )
679 )]
680 pub r#type: ::core::option::Option<super::tile::GeomType>,
681 #[cfg_attr(
687 feature = "json",
688 serde(
689 rename = "geometry",
690 skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
691 deserialize_with = "::buffa::json_helpers::null_as_default"
692 )
693 )]
694 pub geometry: ::buffa::alloc::vec::Vec<u32>,
695 }
696 impl ::core::fmt::Debug for Feature {
697 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
698 f.debug_struct("Feature")
699 .field("id", &self.id)
700 .field("tags", &self.tags)
701 .field("type", &self.r#type)
702 .field("geometry", &self.geometry)
703 .finish()
704 }
705 }
706 impl Feature {
707 pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Feature";
712 }
713 impl Feature {
714 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
715 #[inline]
716 pub fn with_id(mut self, value: u64) -> Self {
718 self.id = Some(value);
719 self
720 }
721 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
722 #[inline]
723 pub fn with_type(mut self, value: impl Into<super::tile::GeomType>) -> Self {
725 self.r#type = Some(value.into());
726 self
727 }
728 }
729 ::buffa::impl_default_instance!(Feature);
730 impl ::buffa::MessageName for Feature {
731 const PACKAGE: &'static str = "vector_tile";
732 const NAME: &'static str = "Tile.Feature";
733 const FULL_NAME: &'static str = "vector_tile.Tile.Feature";
734 const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Feature";
735 }
736 impl ::buffa::Message for Feature {
737 #[allow(clippy::let_and_return)]
745 fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
746 #[allow(unused_imports)]
747 use ::buffa::Enumeration as _;
748 let mut size = 0u64;
749 if let Some(v) = self.id {
750 size += 1u64 + ::buffa::types::uint64_encoded_len(v) as u64;
751 }
752 if !self.tags.is_empty() {
753 let payload: u64 = self
754 .tags
755 .iter()
756 .map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
757 .sum::<u64>();
758 size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
759 }
760 if let Some(ref v) = self.r#type {
761 size += 1u64 + ::buffa::types::int32_encoded_len(v.to_i32()) as u64;
762 }
763 if !self.geometry.is_empty() {
764 let payload: u64 = self
765 .geometry
766 .iter()
767 .map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
768 .sum::<u64>();
769 size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
770 }
771 ::buffa::saturate_size(size)
772 }
773 fn write_to(
774 &self,
775 _cache: &mut ::buffa::SizeCache,
776 buf: &mut impl ::buffa::EncodeSink,
777 ) {
778 #[allow(unused_imports)]
779 use ::buffa::Enumeration as _;
780 if let Some(v) = self.id {
781 ::buffa::types::put_uint64_field(1u32, v, buf);
782 }
783 if !self.tags.is_empty() {
784 let payload: u64 = self
785 .tags
786 .iter()
787 .map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
788 .sum::<u64>();
789 ::buffa::types::put_len_delimited_header(2u32, payload, buf);
790 for &v in &self.tags {
791 ::buffa::types::encode_uint32(v, buf);
792 }
793 }
794 if let Some(ref v) = self.r#type {
795 ::buffa::types::put_int32_field(3u32, v.to_i32(), buf);
796 }
797 if !self.geometry.is_empty() {
798 let payload: u64 = self
799 .geometry
800 .iter()
801 .map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
802 .sum::<u64>();
803 ::buffa::types::put_len_delimited_header(4u32, payload, buf);
804 for &v in &self.geometry {
805 ::buffa::types::encode_uint32(v, buf);
806 }
807 }
808 }
809 fn merge_field(
810 &mut self,
811 tag: ::buffa::encoding::Tag,
812 buf: &mut impl ::buffa::bytes::Buf,
813 ctx: ::buffa::DecodeContext<'_>,
814 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
815 #[allow(unused_imports)]
816 use ::buffa::bytes::Buf as _;
817 #[allow(unused_imports)]
818 use ::buffa::Enumeration as _;
819 match tag.field_number() {
820 1u32 => {
821 ::buffa::encoding::check_wire_type(
822 tag,
823 ::buffa::encoding::WireType::Varint,
824 )?;
825 self.id = ::core::option::Option::Some(
826 ::buffa::types::decode_uint64(buf)?,
827 );
828 }
829 2u32 => {
830 if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
831 let len = ::buffa::encoding::decode_varint(buf)?;
832 let len = usize::try_from(len)
833 .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
834 if buf.remaining() < len {
835 return ::core::result::Result::Err(
836 ::buffa::DecodeError::UnexpectedEof,
837 );
838 }
839 if buf.chunk().len() >= len {
840 ::buffa::types::extend_packed_uint32(
841 &buf.chunk()[..len],
842 &mut self.tags,
843 len,
844 )?;
845 buf.advance(len);
846 } else {
847 self.tags.reserve(len);
848 let mut limited = buf.take(len);
849 while limited.has_remaining() {
850 self.tags
851 .push(::buffa::types::decode_uint32_packed(&mut limited)?);
852 }
853 let leftover = limited.remaining();
854 if leftover > 0 {
855 limited.advance(leftover);
856 }
857 }
858 } else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
859 self.tags.push(::buffa::types::decode_uint32(buf)?);
860 } else {
861 return ::core::result::Result::Err(
862 ::buffa::encoding::wire_type_mismatch(
863 tag,
864 ::buffa::encoding::WireType::LengthDelimited,
865 ),
866 );
867 }
868 }
869 3u32 => {
870 ::buffa::encoding::check_wire_type(
871 tag,
872 ::buffa::encoding::WireType::Varint,
873 )?;
874 let __raw = ::buffa::types::decode_int32(buf)?;
875 if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
876 __raw,
877 ) {
878 self.r#type = ::core::option::Option::Some(__v);
879 }
880 }
881 4u32 => {
882 if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
883 let len = ::buffa::encoding::decode_varint(buf)?;
884 let len = usize::try_from(len)
885 .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
886 if buf.remaining() < len {
887 return ::core::result::Result::Err(
888 ::buffa::DecodeError::UnexpectedEof,
889 );
890 }
891 if buf.chunk().len() >= len {
892 ::buffa::types::extend_packed_uint32(
893 &buf.chunk()[..len],
894 &mut self.geometry,
895 len,
896 )?;
897 buf.advance(len);
898 } else {
899 self.geometry.reserve(len);
900 let mut limited = buf.take(len);
901 while limited.has_remaining() {
902 self.geometry
903 .push(::buffa::types::decode_uint32_packed(&mut limited)?);
904 }
905 let leftover = limited.remaining();
906 if leftover > 0 {
907 limited.advance(leftover);
908 }
909 }
910 } else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
911 self.geometry.push(::buffa::types::decode_uint32(buf)?);
912 } else {
913 return ::core::result::Result::Err(
914 ::buffa::encoding::wire_type_mismatch(
915 tag,
916 ::buffa::encoding::WireType::LengthDelimited,
917 ),
918 );
919 }
920 }
921 _ => {
922 ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
923 }
924 }
925 ::core::result::Result::Ok(())
926 }
927 fn clear(&mut self) {
928 self.id = ::core::option::Option::None;
929 self.tags.clear();
930 self.r#type = ::core::option::Option::None;
931 self.geometry.clear();
932 }
933 }
934 #[cfg(feature = "json")]
935 impl ::buffa::json_helpers::ProtoElemJson for Feature {
936 fn serialize_proto_json<S: ::serde::Serializer>(
937 v: &Self,
938 s: S,
939 ) -> ::core::result::Result<S::Ok, S::Error> {
940 ::serde::Serialize::serialize(v, s)
941 }
942 fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
943 d: D,
944 ) -> ::core::result::Result<Self, D::Error> {
945 <Self as ::serde::Deserialize>::deserialize(d)
946 }
947 }
948 #[cfg(feature = "json")]
949 #[doc(hidden)]
950 pub const __FEATURE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
951 type_url: "type.googleapis.com/vector_tile.Tile.Feature",
952 to_json: ::buffa::type_registry::any_to_json::<Feature>,
953 from_json: ::buffa::type_registry::any_from_json::<Feature>,
954 is_wkt: false,
955 };
956 #[derive(Clone, PartialEq)]
958 #[cfg_attr(feature = "json", derive(::serde::Serialize, ::serde::Deserialize))]
959 #[cfg_attr(feature = "json", serde(default))]
960 #[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
961 pub struct Layer {
962 #[cfg_attr(
969 feature = "json",
970 serde(rename = "version", with = "::buffa::json_helpers::uint32")
971 )]
972 pub version: u32,
973 #[cfg_attr(
975 feature = "json",
976 serde(rename = "name", with = "::buffa::json_helpers::proto_string")
977 )]
978 pub name: ::buffa::alloc::string::String,
979 #[cfg_attr(
983 feature = "json",
984 serde(
985 rename = "features",
986 skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
987 deserialize_with = "::buffa::json_helpers::null_as_default"
988 )
989 )]
990 pub features: ::buffa::alloc::vec::Vec<super::tile::Feature>,
991 #[cfg_attr(
995 feature = "json",
996 serde(
997 rename = "keys",
998 skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
999 deserialize_with = "::buffa::json_helpers::null_as_default"
1000 )
1001 )]
1002 pub keys: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>,
1003 #[cfg_attr(
1007 feature = "json",
1008 serde(
1009 rename = "values",
1010 skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
1011 deserialize_with = "::buffa::json_helpers::null_as_default"
1012 )
1013 )]
1014 pub values: ::buffa::alloc::vec::Vec<super::tile::Value>,
1015 #[cfg_attr(
1020 feature = "json",
1021 serde(
1022 rename = "extent",
1023 with = "::buffa::json_helpers::opt_uint32",
1024 skip_serializing_if = "::core::option::Option::is_none"
1025 )
1026 )]
1027 pub extent: ::core::option::Option<u32>,
1028 }
1029 impl ::core::fmt::Debug for Layer {
1030 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1031 f.debug_struct("Layer")
1032 .field("version", &self.version)
1033 .field("name", &self.name)
1034 .field("features", &self.features)
1035 .field("keys", &self.keys)
1036 .field("values", &self.values)
1037 .field("extent", &self.extent)
1038 .finish()
1039 }
1040 }
1041 impl ::core::default::Default for Layer {
1042 fn default() -> Self {
1043 Self {
1044 version: 1u32,
1045 name: ::core::default::Default::default(),
1046 features: ::core::default::Default::default(),
1047 keys: ::core::default::Default::default(),
1048 values: ::core::default::Default::default(),
1049 extent: ::core::default::Default::default(),
1050 }
1051 }
1052 }
1053 impl Layer {
1054 pub const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Layer";
1059 }
1060 impl Layer {
1061 #[must_use = "with_* setters return `self` by value; assign or chain the result"]
1062 #[inline]
1063 pub fn with_extent(mut self, value: u32) -> Self {
1065 self.extent = Some(value);
1066 self
1067 }
1068 }
1069 ::buffa::impl_default_instance!(Layer);
1070 impl ::buffa::MessageName for Layer {
1071 const PACKAGE: &'static str = "vector_tile";
1072 const NAME: &'static str = "Tile.Layer";
1073 const FULL_NAME: &'static str = "vector_tile.Tile.Layer";
1074 const TYPE_URL: &'static str = "type.googleapis.com/vector_tile.Tile.Layer";
1075 }
1076 impl ::buffa::Message for Layer {
1077 #[allow(clippy::let_and_return)]
1085 fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
1086 #[allow(unused_imports)]
1087 use ::buffa::Enumeration as _;
1088 let mut size = 0u64;
1089 size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
1090 for v in &self.features {
1091 let __slot = __cache.reserve();
1092 let inner_size = v.compute_size(__cache);
1093 __cache.set(__slot, inner_size);
1094 size
1095 += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
1096 + inner_size as u64;
1097 }
1098 for v in &self.keys {
1099 size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
1100 }
1101 for v in &self.values {
1102 let __slot = __cache.reserve();
1103 let inner_size = v.compute_size(__cache);
1104 __cache.set(__slot, inner_size);
1105 size
1106 += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
1107 + inner_size as u64;
1108 }
1109 if let Some(v) = self.extent {
1110 size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64;
1111 }
1112 size += 1u64 + ::buffa::types::uint32_encoded_len(self.version) as u64;
1113 ::buffa::saturate_size(size)
1114 }
1115 fn write_to(
1116 &self,
1117 __cache: &mut ::buffa::SizeCache,
1118 buf: &mut impl ::buffa::EncodeSink,
1119 ) {
1120 #[allow(unused_imports)]
1121 use ::buffa::Enumeration as _;
1122 ::buffa::types::put_string_field(1u32, &self.name, buf);
1123 for v in &self.features {
1124 ::buffa::types::put_len_delimited_header(
1125 2u32,
1126 u64::from(__cache.consume_next()),
1127 buf,
1128 );
1129 v.write_to(__cache, buf);
1130 }
1131 for v in &self.keys {
1132 ::buffa::types::put_string_field(3u32, v, buf);
1133 }
1134 for v in &self.values {
1135 ::buffa::types::put_len_delimited_header(
1136 4u32,
1137 u64::from(__cache.consume_next()),
1138 buf,
1139 );
1140 v.write_to(__cache, buf);
1141 }
1142 if let Some(v) = self.extent {
1143 ::buffa::types::put_uint32_field(5u32, v, buf);
1144 }
1145 ::buffa::types::put_uint32_field(15u32, self.version, buf);
1146 }
1147 fn merge_field(
1148 &mut self,
1149 tag: ::buffa::encoding::Tag,
1150 buf: &mut impl ::buffa::bytes::Buf,
1151 ctx: ::buffa::DecodeContext<'_>,
1152 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1153 #[allow(unused_imports)]
1154 use ::buffa::bytes::Buf as _;
1155 #[allow(unused_imports)]
1156 use ::buffa::Enumeration as _;
1157 match tag.field_number() {
1158 1u32 => {
1159 ::buffa::encoding::check_wire_type(
1160 tag,
1161 ::buffa::encoding::WireType::LengthDelimited,
1162 )?;
1163 ::buffa::types::merge_string(&mut self.name, buf)?;
1164 }
1165 2u32 => {
1166 ::buffa::encoding::check_wire_type(
1167 tag,
1168 ::buffa::encoding::WireType::LengthDelimited,
1169 )?;
1170 let mut elem = ::core::default::Default::default();
1171 ctx.register_element_memory(
1172 ::buffa::__private::element_footprint(&elem),
1173 )?;
1174 ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?;
1175 self.features.push(elem);
1176 }
1177 3u32 => {
1178 ::buffa::encoding::check_wire_type(
1179 tag,
1180 ::buffa::encoding::WireType::LengthDelimited,
1181 )?;
1182 let __elem = ::buffa::types::decode_string(buf)?;
1183 ctx.register_element_memory(
1184 ::buffa::__private::element_footprint(&__elem),
1185 )?;
1186 self.keys.push(__elem);
1187 }
1188 4u32 => {
1189 ::buffa::encoding::check_wire_type(
1190 tag,
1191 ::buffa::encoding::WireType::LengthDelimited,
1192 )?;
1193 let mut elem = ::core::default::Default::default();
1194 ctx.register_element_memory(
1195 ::buffa::__private::element_footprint(&elem),
1196 )?;
1197 ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?;
1198 self.values.push(elem);
1199 }
1200 5u32 => {
1201 ::buffa::encoding::check_wire_type(
1202 tag,
1203 ::buffa::encoding::WireType::Varint,
1204 )?;
1205 self.extent = ::core::option::Option::Some(
1206 ::buffa::types::decode_uint32(buf)?,
1207 );
1208 }
1209 15u32 => {
1210 ::buffa::encoding::check_wire_type(
1211 tag,
1212 ::buffa::encoding::WireType::Varint,
1213 )?;
1214 self.version = ::buffa::types::decode_uint32(buf)?;
1215 }
1216 _ => {
1217 ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
1218 }
1219 }
1220 ::core::result::Result::Ok(())
1221 }
1222 fn clear(&mut self) {
1223 self.name.clear();
1224 self.features.clear();
1225 self.keys.clear();
1226 self.values.clear();
1227 self.extent = ::core::option::Option::None;
1228 self.version = 1u32;
1229 }
1230 }
1231 #[cfg(feature = "json")]
1232 impl ::buffa::json_helpers::ProtoElemJson for Layer {
1233 fn serialize_proto_json<S: ::serde::Serializer>(
1234 v: &Self,
1235 s: S,
1236 ) -> ::core::result::Result<S::Ok, S::Error> {
1237 ::serde::Serialize::serialize(v, s)
1238 }
1239 fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
1240 d: D,
1241 ) -> ::core::result::Result<Self, D::Error> {
1242 <Self as ::serde::Deserialize>::deserialize(d)
1243 }
1244 }
1245 #[cfg(feature = "json")]
1246 #[doc(hidden)]
1247 pub const __LAYER_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
1248 type_url: "type.googleapis.com/vector_tile.Tile.Layer",
1249 to_json: ::buffa::type_registry::any_to_json::<Layer>,
1250 from_json: ::buffa::type_registry::any_from_json::<Layer>,
1251 is_wkt: false,
1252 };
1253 #[cfg(feature = "reader")]
1254 #[doc(inline)]
1255 pub use super::__buffa::view::tile::ValueView;
1256 #[cfg(feature = "reader")]
1257 #[doc(inline)]
1258 pub use super::__buffa::view::tile::ValueOwnedView;
1259 #[cfg(feature = "reader")]
1260 #[doc(inline)]
1261 pub use super::__buffa::view::tile::FeatureView;
1262 #[cfg(feature = "reader")]
1263 #[doc(inline)]
1264 pub use super::__buffa::view::tile::FeatureOwnedView;
1265 #[cfg(feature = "reader")]
1266 #[doc(inline)]
1267 pub use super::__buffa::view::tile::LayerView;
1268 #[cfg(feature = "reader")]
1269 #[doc(inline)]
1270 pub use super::__buffa::view::tile::LayerOwnedView;
1271}