#[derive(Clone, Debug, Default)]
pub struct HeaderBlockView<'a> {
pub bbox: ::buffa::MessageFieldView<super::super::__buffa::view::HeaderBBoxView<'a>>,
pub required_features: ::buffa::RepeatedView<'a, &'a str>,
pub optional_features: ::buffa::RepeatedView<'a, &'a str>,
pub writingprogram: ::core::option::Option<&'a str>,
pub source: ::core::option::Option<&'a str>,
pub osmosis_replication_timestamp: ::core::option::Option<i64>,
pub osmosis_replication_sequence_number: ::core::option::Option<i64>,
pub osmosis_replication_base_url: ::core::option::Option<&'a str>,
}
impl<'a> ::buffa::MessageView<'a> for HeaderBlockView<'a> {
type Owned = super::super::HeaderBlock;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.bbox.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.bbox = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::HeaderBBoxView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
16u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.writingprogram = Some(::buffa::types::borrow_str(&mut cur)?);
}
17u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.source = Some(::buffa::types::borrow_str(&mut cur)?);
}
32u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.osmosis_replication_timestamp = Some(
::buffa::types::decode_int64(&mut cur)?,
);
}
33u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.osmosis_replication_sequence_number = Some(
::buffa::types::decode_int64(&mut cur)?,
);
}
34u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.osmosis_replication_base_url = Some(
::buffa::types::borrow_str(&mut cur)?,
);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __elem = ::buffa::types::borrow_str(&mut cur)?;
ctx.register_element_memory(
::buffa::__private::element_footprint(&__elem),
)?;
view.required_features.push(__elem);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __elem = ::buffa::types::borrow_str(&mut cur)?;
ctx.register_element_memory(
::buffa::__private::element_footprint(&__elem),
)?;
view.optional_features.push(__elem);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::HeaderBlock, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::HeaderBlock, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::HeaderBlock {
bbox: match self.bbox.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::HeaderBBox,
::buffa::Inline<super::super::HeaderBBox>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
required_features: self
.required_features
.iter()
.map(|s| s.to_string())
.collect(),
optional_features: self
.optional_features
.iter()
.map(|s| s.to_string())
.collect(),
writingprogram: self.writingprogram.map(|s| s.to_string()),
source: self.source.map(|s| s.to_string()),
osmosis_replication_timestamp: self.osmosis_replication_timestamp,
osmosis_replication_sequence_number: self
.osmosis_replication_sequence_number,
osmosis_replication_base_url: self
.osmosis_replication_base_url
.map(|s| s.to_string()),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for HeaderBlockView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if self.bbox.is_set() {
let __slot = __cache.reserve();
let inner_size = self.bbox.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.required_features {
size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
}
for v in &self.optional_features {
size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
}
if let Some(ref v) = self.writingprogram {
size += 2u64 + ::buffa::types::string_encoded_len(v) as u64;
}
if let Some(ref v) = self.source {
size += 2u64 + ::buffa::types::string_encoded_len(v) as u64;
}
if let Some(v) = self.osmosis_replication_timestamp {
size += 2u64 + ::buffa::types::int64_encoded_len(v) as u64;
}
if let Some(v) = self.osmosis_replication_sequence_number {
size += 2u64 + ::buffa::types::int64_encoded_len(v) as u64;
}
if let Some(ref v) = self.osmosis_replication_base_url {
size += 2u64 + ::buffa::types::string_encoded_len(v) as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if self.bbox.is_set() {
::buffa::types::put_len_delimited_header(
1u32,
u64::from(__cache.consume_next()),
buf,
);
self.bbox.write_to(__cache, buf);
}
for v in &self.required_features {
::buffa::types::put_string_field(4u32, v, buf);
}
for v in &self.optional_features {
::buffa::types::put_string_field(5u32, v, buf);
}
if let Some(ref v) = self.writingprogram {
::buffa::types::put_string_field(16u32, v, buf);
}
if let Some(ref v) = self.source {
::buffa::types::put_string_field(17u32, v, buf);
}
if let Some(v) = self.osmosis_replication_timestamp {
::buffa::types::put_int64_field(32u32, v, buf);
}
if let Some(v) = self.osmosis_replication_sequence_number {
::buffa::types::put_int64_field(33u32, v, buf);
}
if let Some(ref v) = self.osmosis_replication_base_url {
::buffa::types::put_string_field(34u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for HeaderBlockView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "HeaderBlock";
const FULL_NAME: &'static str = "OSMPBF.HeaderBlock";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.HeaderBlock";
}
::buffa::impl_default_view_instance!(HeaderBlockView);
::buffa::impl_view_reborrow!(HeaderBlockView);
#[derive(Clone, Debug)]
pub struct HeaderBlockOwnedView(::buffa::OwnedView<HeaderBlockView<'static>>);
impl HeaderBlockOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
HeaderBlockOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
HeaderBlockOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::HeaderBlock,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
HeaderBlockOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &HeaderBlockView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::HeaderBlock {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn bbox(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::HeaderBBoxView<'_>> {
&self.0.reborrow().bbox
}
#[must_use]
pub fn required_features(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().required_features
}
#[must_use]
pub fn optional_features(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().optional_features
}
#[must_use]
pub fn writingprogram(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().writingprogram
}
#[must_use]
pub fn source(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().source
}
#[must_use]
pub fn osmosis_replication_timestamp(&self) -> ::core::option::Option<i64> {
self.0.reborrow().osmosis_replication_timestamp
}
#[must_use]
pub fn osmosis_replication_sequence_number(&self) -> ::core::option::Option<i64> {
self.0.reborrow().osmosis_replication_sequence_number
}
#[must_use]
pub fn osmosis_replication_base_url(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().osmosis_replication_base_url
}
}
impl ::core::convert::From<::buffa::OwnedView<HeaderBlockView<'static>>>
for HeaderBlockOwnedView {
fn from(inner: ::buffa::OwnedView<HeaderBlockView<'static>>) -> Self {
HeaderBlockOwnedView(inner)
}
}
impl ::core::convert::From<HeaderBlockOwnedView>
for ::buffa::OwnedView<HeaderBlockView<'static>> {
fn from(wrapper: HeaderBlockOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<HeaderBlockView<'static>>>
for HeaderBlockOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<HeaderBlockView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::HeaderBlock {
type View<'a> = HeaderBlockView<'a>;
type ViewHandle = HeaderBlockOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct HeaderBBoxView<'a> {
pub left: i64,
pub right: i64,
pub top: i64,
pub bottom: i64,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
#[doc(hidden)]
pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> HeaderBBoxView<'a> {
#[must_use]
#[inline]
pub const fn has_left(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
#[must_use]
#[inline]
pub const fn has_right(&self) -> bool {
self.__buffa_required_seen_0 & 2u64 != 0
}
#[must_use]
#[inline]
pub const fn has_top(&self) -> bool {
self.__buffa_required_seen_0 & 4u64 != 0
}
#[must_use]
#[inline]
pub const fn has_bottom(&self) -> bool {
self.__buffa_required_seen_0 & 8u64 != 0
}
}
impl<'a> ::buffa::MessageView<'a> for HeaderBBoxView<'a> {
type Owned = super::super::HeaderBBox;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.left = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.right = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 2u64;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.top = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 4u64;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.bottom = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 8u64;
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::HeaderBBox, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::HeaderBBox, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::HeaderBBox {
left: self.left,
right: self.right,
top: self.top,
bottom: self.bottom,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for HeaderBBoxView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
size += 1u64 + ::buffa::types::sint64_encoded_len(self.left) as u64;
size += 1u64 + ::buffa::types::sint64_encoded_len(self.right) as u64;
size += 1u64 + ::buffa::types::sint64_encoded_len(self.top) as u64;
size += 1u64 + ::buffa::types::sint64_encoded_len(self.bottom) as u64;
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::types::put_sint64_field(1u32, self.left, buf);
::buffa::types::put_sint64_field(2u32, self.right, buf);
::buffa::types::put_sint64_field(3u32, self.top, buf);
::buffa::types::put_sint64_field(4u32, self.bottom, buf);
}
}
impl<'a> ::buffa::MessageName for HeaderBBoxView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "HeaderBBox";
const FULL_NAME: &'static str = "OSMPBF.HeaderBBox";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.HeaderBBox";
}
::buffa::impl_default_view_instance!(HeaderBBoxView);
::buffa::impl_view_reborrow!(HeaderBBoxView);
#[derive(Clone, Debug)]
pub struct HeaderBBoxOwnedView(::buffa::OwnedView<HeaderBBoxView<'static>>);
impl HeaderBBoxOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
HeaderBBoxOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
HeaderBBoxOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::HeaderBBox,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
HeaderBBoxOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &HeaderBBoxView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::HeaderBBox {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn left(&self) -> i64 {
self.0.reborrow().left
}
#[must_use]
pub fn right(&self) -> i64 {
self.0.reborrow().right
}
#[must_use]
pub fn top(&self) -> i64 {
self.0.reborrow().top
}
#[must_use]
pub fn bottom(&self) -> i64 {
self.0.reborrow().bottom
}
}
impl ::core::convert::From<::buffa::OwnedView<HeaderBBoxView<'static>>>
for HeaderBBoxOwnedView {
fn from(inner: ::buffa::OwnedView<HeaderBBoxView<'static>>) -> Self {
HeaderBBoxOwnedView(inner)
}
}
impl ::core::convert::From<HeaderBBoxOwnedView>
for ::buffa::OwnedView<HeaderBBoxView<'static>> {
fn from(wrapper: HeaderBBoxOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<HeaderBBoxView<'static>>>
for HeaderBBoxOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<HeaderBBoxView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::HeaderBBox {
type View<'a> = HeaderBBoxView<'a>;
type ViewHandle = HeaderBBoxOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct PrimitiveBlockView<'a> {
pub stringtable: ::buffa::MessageFieldView<
super::super::__buffa::view::StringTableView<'a>,
>,
pub primitivegroup: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::PrimitiveGroupView<'a>,
>,
pub granularity: ::core::option::Option<i32>,
pub lat_offset: ::core::option::Option<i64>,
pub lon_offset: ::core::option::Option<i64>,
pub date_granularity: ::core::option::Option<i32>,
}
impl<'a> PrimitiveBlockView<'a> {
#[must_use]
#[inline]
pub const fn has_stringtable(&self) -> bool {
self.stringtable.is_set()
}
}
impl<'a> ::buffa::MessageView<'a> for PrimitiveBlockView<'a> {
type Owned = super::super::PrimitiveBlock;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.stringtable.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.stringtable = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::StringTableView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
17u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.granularity = Some(::buffa::types::decode_int32(&mut cur)?);
}
19u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.lat_offset = Some(::buffa::types::decode_int64(&mut cur)?);
}
20u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.lon_offset = Some(::buffa::types::decode_int64(&mut cur)?);
}
18u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.date_granularity = Some(::buffa::types::decode_int32(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<
super::super::__buffa::view::PrimitiveGroupView,
>(),
)?;
view.primitivegroup
.push(
<super::super::__buffa::view::PrimitiveGroupView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::PrimitiveBlock, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::PrimitiveBlock, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::PrimitiveBlock {
stringtable: match self.stringtable.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::StringTable,
::buffa::Inline<super::super::StringTable>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
primitivegroup: self
.primitivegroup
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
granularity: self.granularity,
lat_offset: self.lat_offset,
lon_offset: self.lon_offset,
date_granularity: self.date_granularity,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for PrimitiveBlockView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if self.stringtable.is_set() {
let __slot = __cache.reserve();
let inner_size = self.stringtable.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.primitivegroup {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
if let Some(v) = self.granularity {
size += 2u64 + ::buffa::types::int32_encoded_len(v) as u64;
}
if let Some(v) = self.date_granularity {
size += 2u64 + ::buffa::types::int32_encoded_len(v) as u64;
}
if let Some(v) = self.lat_offset {
size += 2u64 + ::buffa::types::int64_encoded_len(v) as u64;
}
if let Some(v) = self.lon_offset {
size += 2u64 + ::buffa::types::int64_encoded_len(v) as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if self.stringtable.is_set() {
::buffa::types::put_len_delimited_header(
1u32,
u64::from(__cache.consume_next()),
buf,
);
self.stringtable.write_to(__cache, buf);
}
for v in &self.primitivegroup {
::buffa::types::put_len_delimited_header(
2u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
if let Some(v) = self.granularity {
::buffa::types::put_int32_field(17u32, v, buf);
}
if let Some(v) = self.date_granularity {
::buffa::types::put_int32_field(18u32, v, buf);
}
if let Some(v) = self.lat_offset {
::buffa::types::put_int64_field(19u32, v, buf);
}
if let Some(v) = self.lon_offset {
::buffa::types::put_int64_field(20u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for PrimitiveBlockView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "PrimitiveBlock";
const FULL_NAME: &'static str = "OSMPBF.PrimitiveBlock";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.PrimitiveBlock";
}
::buffa::impl_default_view_instance!(PrimitiveBlockView);
::buffa::impl_view_reborrow!(PrimitiveBlockView);
#[derive(Clone, Debug)]
pub struct PrimitiveBlockOwnedView(::buffa::OwnedView<PrimitiveBlockView<'static>>);
impl PrimitiveBlockOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
PrimitiveBlockOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
PrimitiveBlockOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::PrimitiveBlock,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
PrimitiveBlockOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &PrimitiveBlockView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::PrimitiveBlock {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn stringtable(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::StringTableView<'_>> {
&self.0.reborrow().stringtable
}
#[must_use]
pub fn primitivegroup(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::PrimitiveGroupView<'_>,
> {
&self.0.reborrow().primitivegroup
}
#[must_use]
pub fn granularity(&self) -> ::core::option::Option<i32> {
self.0.reborrow().granularity
}
#[must_use]
pub fn lat_offset(&self) -> ::core::option::Option<i64> {
self.0.reborrow().lat_offset
}
#[must_use]
pub fn lon_offset(&self) -> ::core::option::Option<i64> {
self.0.reborrow().lon_offset
}
#[must_use]
pub fn date_granularity(&self) -> ::core::option::Option<i32> {
self.0.reborrow().date_granularity
}
}
impl ::core::convert::From<::buffa::OwnedView<PrimitiveBlockView<'static>>>
for PrimitiveBlockOwnedView {
fn from(inner: ::buffa::OwnedView<PrimitiveBlockView<'static>>) -> Self {
PrimitiveBlockOwnedView(inner)
}
}
impl ::core::convert::From<PrimitiveBlockOwnedView>
for ::buffa::OwnedView<PrimitiveBlockView<'static>> {
fn from(wrapper: PrimitiveBlockOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<PrimitiveBlockView<'static>>>
for PrimitiveBlockOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<PrimitiveBlockView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::PrimitiveBlock {
type View<'a> = PrimitiveBlockView<'a>;
type ViewHandle = PrimitiveBlockOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct PrimitiveGroupView<'a> {
pub nodes: ::buffa::RepeatedView<'a, super::super::__buffa::view::NodeView<'a>>,
pub dense: ::buffa::MessageFieldView<
super::super::__buffa::view::DenseNodesView<'a>,
>,
pub ways: ::buffa::RepeatedView<'a, super::super::__buffa::view::WayView<'a>>,
pub relations: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::RelationView<'a>,
>,
pub changesets: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::ChangeSetView<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for PrimitiveGroupView<'a> {
type Owned = super::super::PrimitiveGroup;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.dense.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.dense = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::DenseNodesView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::NodeView>(),
)?;
view.nodes
.push(
<super::super::__buffa::view::NodeView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::WayView>(),
)?;
view.ways
.push(
<super::super::__buffa::view::WayView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::RelationView>(),
)?;
view.relations
.push(
<super::super::__buffa::view::RelationView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::ChangeSetView>(),
)?;
view.changesets
.push(
<super::super::__buffa::view::ChangeSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::PrimitiveGroup, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::PrimitiveGroup, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::PrimitiveGroup {
nodes: self
.nodes
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
dense: match self.dense.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::DenseNodes,
::buffa::Inline<super::super::DenseNodes>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
ways: self
.ways
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
relations: self
.relations
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
changesets: self
.changesets
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for PrimitiveGroupView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
for v in &self.nodes {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
if self.dense.is_set() {
let __slot = __cache.reserve();
let inner_size = self.dense.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.ways {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.relations {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.changesets {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.nodes {
::buffa::types::put_len_delimited_header(
1u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
if self.dense.is_set() {
::buffa::types::put_len_delimited_header(
2u32,
u64::from(__cache.consume_next()),
buf,
);
self.dense.write_to(__cache, buf);
}
for v in &self.ways {
::buffa::types::put_len_delimited_header(
3u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
for v in &self.relations {
::buffa::types::put_len_delimited_header(
4u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
for v in &self.changesets {
::buffa::types::put_len_delimited_header(
5u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
}
}
impl<'a> ::buffa::MessageName for PrimitiveGroupView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "PrimitiveGroup";
const FULL_NAME: &'static str = "OSMPBF.PrimitiveGroup";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.PrimitiveGroup";
}
::buffa::impl_default_view_instance!(PrimitiveGroupView);
::buffa::impl_view_reborrow!(PrimitiveGroupView);
#[derive(Clone, Debug)]
pub struct PrimitiveGroupOwnedView(::buffa::OwnedView<PrimitiveGroupView<'static>>);
impl PrimitiveGroupOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
PrimitiveGroupOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
PrimitiveGroupOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::PrimitiveGroup,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
PrimitiveGroupOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &PrimitiveGroupView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::PrimitiveGroup {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn nodes(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::NodeView<'_>> {
&self.0.reborrow().nodes
}
#[must_use]
pub fn dense(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::DenseNodesView<'_>> {
&self.0.reborrow().dense
}
#[must_use]
pub fn ways(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::WayView<'_>> {
&self.0.reborrow().ways
}
#[must_use]
pub fn relations(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::RelationView<'_>> {
&self.0.reborrow().relations
}
#[must_use]
pub fn changesets(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::ChangeSetView<'_>> {
&self.0.reborrow().changesets
}
}
impl ::core::convert::From<::buffa::OwnedView<PrimitiveGroupView<'static>>>
for PrimitiveGroupOwnedView {
fn from(inner: ::buffa::OwnedView<PrimitiveGroupView<'static>>) -> Self {
PrimitiveGroupOwnedView(inner)
}
}
impl ::core::convert::From<PrimitiveGroupOwnedView>
for ::buffa::OwnedView<PrimitiveGroupView<'static>> {
fn from(wrapper: PrimitiveGroupOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<PrimitiveGroupView<'static>>>
for PrimitiveGroupOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<PrimitiveGroupView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::PrimitiveGroup {
type View<'a> = PrimitiveGroupView<'a>;
type ViewHandle = PrimitiveGroupOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct StringTableView<'a> {
pub s: ::buffa::RepeatedView<'a, &'a [u8]>,
}
impl<'a> ::buffa::MessageView<'a> for StringTableView<'a> {
type Owned = super::super::StringTable;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __elem = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::buffa::__private::element_footprint(&__elem),
)?;
view.s.push(__elem);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::StringTable, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::StringTable, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::StringTable {
s: self.s.iter().map(|b| (b).to_vec()).collect(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for StringTableView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
for v in &self.s {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.s {
::buffa::types::put_shared_bytes_field(1u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for StringTableView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "StringTable";
const FULL_NAME: &'static str = "OSMPBF.StringTable";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.StringTable";
}
::buffa::impl_default_view_instance!(StringTableView);
::buffa::impl_view_reborrow!(StringTableView);
#[derive(Clone, Debug)]
pub struct StringTableOwnedView(::buffa::OwnedView<StringTableView<'static>>);
impl StringTableOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StringTableOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StringTableOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::StringTable,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StringTableOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &StringTableView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::StringTable {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn s(&self) -> &::buffa::RepeatedView<'_, &'_ [u8]> {
&self.0.reborrow().s
}
}
impl ::core::convert::From<::buffa::OwnedView<StringTableView<'static>>>
for StringTableOwnedView {
fn from(inner: ::buffa::OwnedView<StringTableView<'static>>) -> Self {
StringTableOwnedView(inner)
}
}
impl ::core::convert::From<StringTableOwnedView>
for ::buffa::OwnedView<StringTableView<'static>> {
fn from(wrapper: StringTableOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<StringTableView<'static>>>
for StringTableOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<StringTableView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::StringTable {
type View<'a> = StringTableView<'a>;
type ViewHandle = StringTableOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct InfoView<'a> {
pub version: ::core::option::Option<i32>,
pub timestamp: ::core::option::Option<i64>,
pub changeset: ::core::option::Option<i64>,
pub uid: ::core::option::Option<i32>,
pub user_sid: ::core::option::Option<u32>,
pub visible: ::core::option::Option<bool>,
#[doc(hidden)]
pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> ::buffa::MessageView<'a> for InfoView<'a> {
type Owned = super::super::Info;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.version = Some(::buffa::types::decode_int32(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.timestamp = Some(::buffa::types::decode_int64(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.changeset = Some(::buffa::types::decode_int64(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.uid = Some(::buffa::types::decode_int32(&mut cur)?);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.user_sid = Some(::buffa::types::decode_uint32(&mut cur)?);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.visible = Some(::buffa::types::decode_bool(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Info, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::Info, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Info {
version: self.version,
timestamp: self.timestamp,
changeset: self.changeset,
uid: self.uid,
user_sid: self.user_sid,
visible: self.visible,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for InfoView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if let Some(v) = self.version {
size += 1u64 + ::buffa::types::int32_encoded_len(v) as u64;
}
if let Some(v) = self.timestamp {
size += 1u64 + ::buffa::types::int64_encoded_len(v) as u64;
}
if let Some(v) = self.changeset {
size += 1u64 + ::buffa::types::int64_encoded_len(v) as u64;
}
if let Some(v) = self.uid {
size += 1u64 + ::buffa::types::int32_encoded_len(v) as u64;
}
if let Some(v) = self.user_sid {
size += 1u64 + ::buffa::types::uint32_encoded_len(v) as u64;
}
if self.visible.is_some() {
size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.version {
::buffa::types::put_int32_field(1u32, v, buf);
}
if let Some(v) = self.timestamp {
::buffa::types::put_int64_field(2u32, v, buf);
}
if let Some(v) = self.changeset {
::buffa::types::put_int64_field(3u32, v, buf);
}
if let Some(v) = self.uid {
::buffa::types::put_int32_field(4u32, v, buf);
}
if let Some(v) = self.user_sid {
::buffa::types::put_uint32_field(5u32, v, buf);
}
if let Some(v) = self.visible {
::buffa::types::put_bool_field(6u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for InfoView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "Info";
const FULL_NAME: &'static str = "OSMPBF.Info";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.Info";
}
::buffa::impl_default_view_instance!(InfoView);
::buffa::impl_view_reborrow!(InfoView);
#[derive(Clone, Debug)]
pub struct InfoOwnedView(::buffa::OwnedView<InfoView<'static>>);
impl InfoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(InfoOwnedView(::buffa::OwnedView::decode(bytes)?))
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
InfoOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Info,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(InfoOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &InfoView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Info {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn version(&self) -> ::core::option::Option<i32> {
self.0.reborrow().version
}
#[must_use]
pub fn timestamp(&self) -> ::core::option::Option<i64> {
self.0.reborrow().timestamp
}
#[must_use]
pub fn changeset(&self) -> ::core::option::Option<i64> {
self.0.reborrow().changeset
}
#[must_use]
pub fn uid(&self) -> ::core::option::Option<i32> {
self.0.reborrow().uid
}
#[must_use]
pub fn user_sid(&self) -> ::core::option::Option<u32> {
self.0.reborrow().user_sid
}
#[must_use]
pub fn visible(&self) -> ::core::option::Option<bool> {
self.0.reborrow().visible
}
}
impl ::core::convert::From<::buffa::OwnedView<InfoView<'static>>> for InfoOwnedView {
fn from(inner: ::buffa::OwnedView<InfoView<'static>>) -> Self {
InfoOwnedView(inner)
}
}
impl ::core::convert::From<InfoOwnedView> for ::buffa::OwnedView<InfoView<'static>> {
fn from(wrapper: InfoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<InfoView<'static>>> for InfoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<InfoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Info {
type View<'a> = InfoView<'a>;
type ViewHandle = InfoOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct DenseInfoView<'a> {
pub version: ::buffa::RepeatedView<'a, i32>,
pub timestamp: ::buffa::RepeatedView<'a, i64>,
pub changeset: ::buffa::RepeatedView<'a, i64>,
pub uid: ::buffa::RepeatedView<'a, i32>,
pub user_sid: ::buffa::RepeatedView<'a, i32>,
pub visible: ::buffa::RepeatedView<'a, bool>,
}
impl<'a> ::buffa::MessageView<'a> for DenseInfoView<'a> {
type Owned = super::super::DenseInfo;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_int32(
payload,
view.version.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.version.push(::buffa::types::decode_int32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
2u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.timestamp.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.timestamp.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
3u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.changeset.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.changeset.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
4u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint32(
payload,
view.uid.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.uid.push(::buffa::types::decode_sint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
5u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint32(
payload,
view.user_sid.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.user_sid.push(::buffa::types::decode_sint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
6u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_bool(
payload,
view.visible.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.visible.push(::buffa::types::decode_bool(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::DenseInfo, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::DenseInfo, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::DenseInfo {
version: self.version.to_vec(),
timestamp: self.timestamp.to_vec(),
changeset: self.changeset.to_vec(),
uid: self.uid.to_vec(),
user_sid: self.user_sid.to_vec(),
visible: self.visible.to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for DenseInfoView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if !self.version.is_empty() {
let payload: u64 = self
.version
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.timestamp.is_empty() {
let payload: u64 = self
.timestamp
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.changeset.is_empty() {
let payload: u64 = self
.changeset
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.uid.is_empty() {
let payload: u64 = self
.uid
.iter()
.map(|&v| ::buffa::types::sint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.user_sid.is_empty() {
let payload: u64 = self
.user_sid
.iter()
.map(|&v| ::buffa::types::sint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.visible.is_empty() {
let payload: u64 = self.visible.len() as u64
* ::buffa::types::BOOL_ENCODED_LEN as u64;
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.version.is_empty() {
let payload: u64 = self
.version
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(1u32, payload, buf);
for &v in &self.version {
::buffa::types::encode_int32(v, buf);
}
}
if !self.timestamp.is_empty() {
let payload: u64 = self
.timestamp
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(2u32, payload, buf);
for &v in &self.timestamp {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.changeset.is_empty() {
let payload: u64 = self
.changeset
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(3u32, payload, buf);
for &v in &self.changeset {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.uid.is_empty() {
let payload: u64 = self
.uid
.iter()
.map(|&v| ::buffa::types::sint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(4u32, payload, buf);
for &v in &self.uid {
::buffa::types::encode_sint32(v, buf);
}
}
if !self.user_sid.is_empty() {
let payload: u64 = self
.user_sid
.iter()
.map(|&v| ::buffa::types::sint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(5u32, payload, buf);
for &v in &self.user_sid {
::buffa::types::encode_sint32(v, buf);
}
}
if !self.visible.is_empty() {
let payload: u64 = self.visible.len() as u64
* ::buffa::types::BOOL_ENCODED_LEN as u64;
::buffa::types::put_len_delimited_header(6u32, payload, buf);
for &v in &self.visible {
::buffa::types::encode_bool(v, buf);
}
}
}
}
impl<'a> ::buffa::MessageName for DenseInfoView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "DenseInfo";
const FULL_NAME: &'static str = "OSMPBF.DenseInfo";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.DenseInfo";
}
::buffa::impl_default_view_instance!(DenseInfoView);
::buffa::impl_view_reborrow!(DenseInfoView);
#[derive(Clone, Debug)]
pub struct DenseInfoOwnedView(::buffa::OwnedView<DenseInfoView<'static>>);
impl DenseInfoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseInfoOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseInfoOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::DenseInfo,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseInfoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &DenseInfoView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::DenseInfo {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn version(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().version
}
#[must_use]
pub fn timestamp(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().timestamp
}
#[must_use]
pub fn changeset(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().changeset
}
#[must_use]
pub fn uid(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().uid
}
#[must_use]
pub fn user_sid(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().user_sid
}
#[must_use]
pub fn visible(&self) -> &::buffa::RepeatedView<'_, bool> {
&self.0.reborrow().visible
}
}
impl ::core::convert::From<::buffa::OwnedView<DenseInfoView<'static>>>
for DenseInfoOwnedView {
fn from(inner: ::buffa::OwnedView<DenseInfoView<'static>>) -> Self {
DenseInfoOwnedView(inner)
}
}
impl ::core::convert::From<DenseInfoOwnedView>
for ::buffa::OwnedView<DenseInfoView<'static>> {
fn from(wrapper: DenseInfoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<DenseInfoView<'static>>>
for DenseInfoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<DenseInfoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::DenseInfo {
type View<'a> = DenseInfoView<'a>;
type ViewHandle = DenseInfoOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct ChangeSetView<'a> {
pub id: i64,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
#[doc(hidden)]
pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> ChangeSetView<'a> {
#[must_use]
#[inline]
pub const fn has_id(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
}
impl<'a> ::buffa::MessageView<'a> for ChangeSetView<'a> {
type Owned = super::super::ChangeSet;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.id = ::buffa::types::decode_int64(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::ChangeSet, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::ChangeSet, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::ChangeSet {
id: self.id,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ChangeSetView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
size += 1u64 + ::buffa::types::int64_encoded_len(self.id) as u64;
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::types::put_int64_field(1u32, self.id, buf);
}
}
impl<'a> ::buffa::MessageName for ChangeSetView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "ChangeSet";
const FULL_NAME: &'static str = "OSMPBF.ChangeSet";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.ChangeSet";
}
::buffa::impl_default_view_instance!(ChangeSetView);
::buffa::impl_view_reborrow!(ChangeSetView);
#[derive(Clone, Debug)]
pub struct ChangeSetOwnedView(::buffa::OwnedView<ChangeSetView<'static>>);
impl ChangeSetOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ChangeSetOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ChangeSetOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::ChangeSet,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ChangeSetOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &ChangeSetView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::ChangeSet {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn id(&self) -> i64 {
self.0.reborrow().id
}
}
impl ::core::convert::From<::buffa::OwnedView<ChangeSetView<'static>>>
for ChangeSetOwnedView {
fn from(inner: ::buffa::OwnedView<ChangeSetView<'static>>) -> Self {
ChangeSetOwnedView(inner)
}
}
impl ::core::convert::From<ChangeSetOwnedView>
for ::buffa::OwnedView<ChangeSetView<'static>> {
fn from(wrapper: ChangeSetOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ChangeSetView<'static>>>
for ChangeSetOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ChangeSetView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::ChangeSet {
type View<'a> = ChangeSetView<'a>;
type ViewHandle = ChangeSetOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct NodeView<'a> {
pub id: i64,
pub keys: ::buffa::RepeatedView<'a, u32>,
pub vals: ::buffa::RepeatedView<'a, u32>,
pub info: ::buffa::MessageFieldView<super::super::__buffa::view::InfoView<'a>>,
pub lat: i64,
pub lon: i64,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
}
impl<'a> NodeView<'a> {
#[must_use]
#[inline]
pub const fn has_id(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
#[must_use]
#[inline]
pub const fn has_lat(&self) -> bool {
self.__buffa_required_seen_0 & 2u64 != 0
}
#[must_use]
#[inline]
pub const fn has_lon(&self) -> bool {
self.__buffa_required_seen_0 & 4u64 != 0
}
}
impl<'a> ::buffa::MessageView<'a> for NodeView<'a> {
type Owned = super::super::Node;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.id = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.info.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.info = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::InfoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.lat = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 2u64;
}
9u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.lon = ::buffa::types::decode_sint64(&mut cur)?;
view.__buffa_required_seen_0 |= 4u64;
}
2u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_uint32(
payload,
view.keys.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.keys.push(::buffa::types::decode_uint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
3u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_uint32(
payload,
view.vals.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.vals.push(::buffa::types::decode_uint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Node, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::Node, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Node {
id: self.id,
keys: self.keys.to_vec(),
vals: self.vals.to_vec(),
info: match self.info.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::Info,
::buffa::Inline<super::super::Info>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
lat: self.lat,
lon: self.lon,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for NodeView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
size += 1u64 + ::buffa::types::sint64_encoded_len(self.id) as u64;
if !self.keys.is_empty() {
let payload: u64 = self
.keys
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.vals.is_empty() {
let payload: u64 = self
.vals
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if self.info.is_set() {
let __slot = __cache.reserve();
let inner_size = self.info.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
size += 1u64 + ::buffa::types::sint64_encoded_len(self.lat) as u64;
size += 1u64 + ::buffa::types::sint64_encoded_len(self.lon) as u64;
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::types::put_sint64_field(1u32, self.id, buf);
if !self.keys.is_empty() {
let payload: u64 = self
.keys
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(2u32, payload, buf);
for &v in &self.keys {
::buffa::types::encode_uint32(v, buf);
}
}
if !self.vals.is_empty() {
let payload: u64 = self
.vals
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(3u32, payload, buf);
for &v in &self.vals {
::buffa::types::encode_uint32(v, buf);
}
}
if self.info.is_set() {
::buffa::types::put_len_delimited_header(
4u32,
u64::from(__cache.consume_next()),
buf,
);
self.info.write_to(__cache, buf);
}
::buffa::types::put_sint64_field(8u32, self.lat, buf);
::buffa::types::put_sint64_field(9u32, self.lon, buf);
}
}
impl<'a> ::buffa::MessageName for NodeView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "Node";
const FULL_NAME: &'static str = "OSMPBF.Node";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.Node";
}
::buffa::impl_default_view_instance!(NodeView);
::buffa::impl_view_reborrow!(NodeView);
#[derive(Clone, Debug)]
pub struct NodeOwnedView(::buffa::OwnedView<NodeView<'static>>);
impl NodeOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(NodeOwnedView(::buffa::OwnedView::decode(bytes)?))
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
NodeOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Node,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(NodeOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &NodeView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Node {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn id(&self) -> i64 {
self.0.reborrow().id
}
#[must_use]
pub fn keys(&self) -> &::buffa::RepeatedView<'_, u32> {
&self.0.reborrow().keys
}
#[must_use]
pub fn vals(&self) -> &::buffa::RepeatedView<'_, u32> {
&self.0.reborrow().vals
}
#[must_use]
pub fn info(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::InfoView<'_>> {
&self.0.reborrow().info
}
#[must_use]
pub fn lat(&self) -> i64 {
self.0.reborrow().lat
}
#[must_use]
pub fn lon(&self) -> i64 {
self.0.reborrow().lon
}
}
impl ::core::convert::From<::buffa::OwnedView<NodeView<'static>>> for NodeOwnedView {
fn from(inner: ::buffa::OwnedView<NodeView<'static>>) -> Self {
NodeOwnedView(inner)
}
}
impl ::core::convert::From<NodeOwnedView> for ::buffa::OwnedView<NodeView<'static>> {
fn from(wrapper: NodeOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<NodeView<'static>>> for NodeOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<NodeView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Node {
type View<'a> = NodeView<'a>;
type ViewHandle = NodeOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct DenseNodesView<'a> {
pub id: ::buffa::RepeatedView<'a, i64>,
pub denseinfo: ::buffa::MessageFieldView<
super::super::__buffa::view::DenseInfoView<'a>,
>,
pub lat: ::buffa::RepeatedView<'a, i64>,
pub lon: ::buffa::RepeatedView<'a, i64>,
pub keys_vals: ::buffa::RepeatedView<'a, i32>,
}
impl<'a> ::buffa::MessageView<'a> for DenseNodesView<'a> {
type Owned = super::super::DenseNodes;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.denseinfo.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.denseinfo = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::DenseInfoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
1u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.id.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.id.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
8u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.lat.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.lat.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
9u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.lon.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.lon.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
10u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_int32(
payload,
view.keys_vals.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.keys_vals.push(::buffa::types::decode_int32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::DenseNodes, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::DenseNodes, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::DenseNodes {
id: self.id.to_vec(),
denseinfo: match self.denseinfo.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::DenseInfo,
::buffa::Inline<super::super::DenseInfo>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
lat: self.lat.to_vec(),
lon: self.lon.to_vec(),
keys_vals: self.keys_vals.to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for DenseNodesView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if !self.id.is_empty() {
let payload: u64 = self
.id
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if self.denseinfo.is_set() {
let __slot = __cache.reserve();
let inner_size = self.denseinfo.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
if !self.lat.is_empty() {
let payload: u64 = self
.lat
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.lon.is_empty() {
let payload: u64 = self
.lon
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.keys_vals.is_empty() {
let payload: u64 = self
.keys_vals
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.id.is_empty() {
let payload: u64 = self
.id
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(1u32, payload, buf);
for &v in &self.id {
::buffa::types::encode_sint64(v, buf);
}
}
if self.denseinfo.is_set() {
::buffa::types::put_len_delimited_header(
5u32,
u64::from(__cache.consume_next()),
buf,
);
self.denseinfo.write_to(__cache, buf);
}
if !self.lat.is_empty() {
let payload: u64 = self
.lat
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(8u32, payload, buf);
for &v in &self.lat {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.lon.is_empty() {
let payload: u64 = self
.lon
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(9u32, payload, buf);
for &v in &self.lon {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.keys_vals.is_empty() {
let payload: u64 = self
.keys_vals
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(10u32, payload, buf);
for &v in &self.keys_vals {
::buffa::types::encode_int32(v, buf);
}
}
}
}
impl<'a> ::buffa::MessageName for DenseNodesView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "DenseNodes";
const FULL_NAME: &'static str = "OSMPBF.DenseNodes";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.DenseNodes";
}
::buffa::impl_default_view_instance!(DenseNodesView);
::buffa::impl_view_reborrow!(DenseNodesView);
#[derive(Clone, Debug)]
pub struct DenseNodesOwnedView(::buffa::OwnedView<DenseNodesView<'static>>);
impl DenseNodesOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseNodesOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseNodesOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::DenseNodes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseNodesOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &DenseNodesView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::DenseNodes {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn id(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().id
}
#[must_use]
pub fn denseinfo(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::DenseInfoView<'_>> {
&self.0.reborrow().denseinfo
}
#[must_use]
pub fn lat(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().lat
}
#[must_use]
pub fn lon(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().lon
}
#[must_use]
pub fn keys_vals(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().keys_vals
}
}
impl ::core::convert::From<::buffa::OwnedView<DenseNodesView<'static>>>
for DenseNodesOwnedView {
fn from(inner: ::buffa::OwnedView<DenseNodesView<'static>>) -> Self {
DenseNodesOwnedView(inner)
}
}
impl ::core::convert::From<DenseNodesOwnedView>
for ::buffa::OwnedView<DenseNodesView<'static>> {
fn from(wrapper: DenseNodesOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<DenseNodesView<'static>>>
for DenseNodesOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<DenseNodesView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::DenseNodes {
type View<'a> = DenseNodesView<'a>;
type ViewHandle = DenseNodesOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct WayView<'a> {
pub id: i64,
pub keys: ::buffa::RepeatedView<'a, u32>,
pub vals: ::buffa::RepeatedView<'a, u32>,
pub info: ::buffa::MessageFieldView<super::super::__buffa::view::InfoView<'a>>,
pub refs: ::buffa::RepeatedView<'a, i64>,
pub lat: ::buffa::RepeatedView<'a, i64>,
pub lon: ::buffa::RepeatedView<'a, i64>,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
}
impl<'a> WayView<'a> {
#[must_use]
#[inline]
pub const fn has_id(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
}
impl<'a> ::buffa::MessageView<'a> for WayView<'a> {
type Owned = super::super::Way;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.id = ::buffa::types::decode_int64(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.info.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.info = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::InfoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
2u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_uint32(
payload,
view.keys.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.keys.push(::buffa::types::decode_uint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
3u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_uint32(
payload,
view.vals.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.vals.push(::buffa::types::decode_uint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
8u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.refs.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.refs.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
9u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.lat.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.lat.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
10u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.lon.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.lon.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Way, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::Way, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Way {
id: self.id,
keys: self.keys.to_vec(),
vals: self.vals.to_vec(),
info: match self.info.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::Info,
::buffa::Inline<super::super::Info>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
refs: self.refs.to_vec(),
lat: self.lat.to_vec(),
lon: self.lon.to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for WayView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
size += 1u64 + ::buffa::types::int64_encoded_len(self.id) as u64;
if !self.keys.is_empty() {
let payload: u64 = self
.keys
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.vals.is_empty() {
let payload: u64 = self
.vals
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if self.info.is_set() {
let __slot = __cache.reserve();
let inner_size = self.info.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
if !self.refs.is_empty() {
let payload: u64 = self
.refs
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.lat.is_empty() {
let payload: u64 = self
.lat
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.lon.is_empty() {
let payload: u64 = self
.lon
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::types::put_int64_field(1u32, self.id, buf);
if !self.keys.is_empty() {
let payload: u64 = self
.keys
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(2u32, payload, buf);
for &v in &self.keys {
::buffa::types::encode_uint32(v, buf);
}
}
if !self.vals.is_empty() {
let payload: u64 = self
.vals
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(3u32, payload, buf);
for &v in &self.vals {
::buffa::types::encode_uint32(v, buf);
}
}
if self.info.is_set() {
::buffa::types::put_len_delimited_header(
4u32,
u64::from(__cache.consume_next()),
buf,
);
self.info.write_to(__cache, buf);
}
if !self.refs.is_empty() {
let payload: u64 = self
.refs
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(8u32, payload, buf);
for &v in &self.refs {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.lat.is_empty() {
let payload: u64 = self
.lat
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(9u32, payload, buf);
for &v in &self.lat {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.lon.is_empty() {
let payload: u64 = self
.lon
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(10u32, payload, buf);
for &v in &self.lon {
::buffa::types::encode_sint64(v, buf);
}
}
}
}
impl<'a> ::buffa::MessageName for WayView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "Way";
const FULL_NAME: &'static str = "OSMPBF.Way";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.Way";
}
::buffa::impl_default_view_instance!(WayView);
::buffa::impl_view_reborrow!(WayView);
#[derive(Clone, Debug)]
pub struct WayOwnedView(::buffa::OwnedView<WayView<'static>>);
impl WayOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(WayOwnedView(::buffa::OwnedView::decode(bytes)?))
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
WayOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Way,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(WayOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &WayView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Way {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn id(&self) -> i64 {
self.0.reborrow().id
}
#[must_use]
pub fn keys(&self) -> &::buffa::RepeatedView<'_, u32> {
&self.0.reborrow().keys
}
#[must_use]
pub fn vals(&self) -> &::buffa::RepeatedView<'_, u32> {
&self.0.reborrow().vals
}
#[must_use]
pub fn info(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::InfoView<'_>> {
&self.0.reborrow().info
}
#[must_use]
pub fn refs(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().refs
}
#[must_use]
pub fn lat(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().lat
}
#[must_use]
pub fn lon(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().lon
}
}
impl ::core::convert::From<::buffa::OwnedView<WayView<'static>>> for WayOwnedView {
fn from(inner: ::buffa::OwnedView<WayView<'static>>) -> Self {
WayOwnedView(inner)
}
}
impl ::core::convert::From<WayOwnedView> for ::buffa::OwnedView<WayView<'static>> {
fn from(wrapper: WayOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<WayView<'static>>> for WayOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<WayView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Way {
type View<'a> = WayView<'a>;
type ViewHandle = WayOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct RelationView<'a> {
pub id: i64,
pub keys: ::buffa::RepeatedView<'a, u32>,
pub vals: ::buffa::RepeatedView<'a, u32>,
pub info: ::buffa::MessageFieldView<super::super::__buffa::view::InfoView<'a>>,
pub roles_sid: ::buffa::RepeatedView<'a, i32>,
pub memids: ::buffa::RepeatedView<'a, i64>,
pub types: ::buffa::RepeatedView<'a, super::super::relation::MemberType>,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
}
impl<'a> RelationView<'a> {
#[must_use]
#[inline]
pub const fn has_id(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
}
impl<'a> ::buffa::MessageView<'a> for RelationView<'a> {
type Owned = super::super::Relation;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.id = ::buffa::types::decode_int64(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
match view.info.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.info = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::InfoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
2u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_uint32(
payload,
view.keys.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.keys.push(::buffa::types::decode_uint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
3u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_uint32(
payload,
view.vals.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.vals.push(::buffa::types::decode_uint32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
8u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_int32(
payload,
view.roles_sid.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.roles_sid.push(::buffa::types::decode_int32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
9u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
::buffa::types::extend_packed_sint64(
payload,
view.memids.as_mut_vec(),
::buffa::encoding::count_varints(payload),
)?;
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.memids.push(::buffa::types::decode_sint64(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
10u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
view.types.reserve(::buffa::encoding::count_varints(payload));
let mut pcur: &[u8] = payload;
while !pcur.is_empty() {
let __raw = ::buffa::types::decode_int32(&mut pcur)?;
if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
__raw,
) {
view.types.push(__v);
}
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
let __raw = ::buffa::types::decode_int32(&mut cur)?;
if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
__raw,
) {
view.types.push(__v);
}
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Relation, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::Relation, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Relation {
id: self.id,
keys: self.keys.to_vec(),
vals: self.vals.to_vec(),
info: match self.info.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::Info,
::buffa::Inline<super::super::Info>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
roles_sid: self.roles_sid.to_vec(),
memids: self.memids.to_vec(),
types: self.types.to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for RelationView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
size += 1u64 + ::buffa::types::int64_encoded_len(self.id) as u64;
if !self.keys.is_empty() {
let payload: u64 = self
.keys
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.vals.is_empty() {
let payload: u64 = self
.vals
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if self.info.is_set() {
let __slot = __cache.reserve();
let inner_size = self.info.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
if !self.roles_sid.is_empty() {
let payload: u64 = self
.roles_sid
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.memids.is_empty() {
let payload: u64 = self
.memids
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
if !self.types.is_empty() {
let payload: u64 = self
.types
.iter()
.map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64)
.sum::<u64>();
size += 1u64 + ::buffa::encoding::varint_len(payload) as u64 + payload;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::types::put_int64_field(1u32, self.id, buf);
if !self.keys.is_empty() {
let payload: u64 = self
.keys
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(2u32, payload, buf);
for &v in &self.keys {
::buffa::types::encode_uint32(v, buf);
}
}
if !self.vals.is_empty() {
let payload: u64 = self
.vals
.iter()
.map(|&v| ::buffa::types::uint32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(3u32, payload, buf);
for &v in &self.vals {
::buffa::types::encode_uint32(v, buf);
}
}
if self.info.is_set() {
::buffa::types::put_len_delimited_header(
4u32,
u64::from(__cache.consume_next()),
buf,
);
self.info.write_to(__cache, buf);
}
if !self.roles_sid.is_empty() {
let payload: u64 = self
.roles_sid
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(8u32, payload, buf);
for &v in &self.roles_sid {
::buffa::types::encode_int32(v, buf);
}
}
if !self.memids.is_empty() {
let payload: u64 = self
.memids
.iter()
.map(|&v| ::buffa::types::sint64_encoded_len(v) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(9u32, payload, buf);
for &v in &self.memids {
::buffa::types::encode_sint64(v, buf);
}
}
if !self.types.is_empty() {
let payload: u64 = self
.types
.iter()
.map(|v| ::buffa::types::int32_encoded_len(v.to_i32()) as u64)
.sum::<u64>();
::buffa::types::put_len_delimited_header(10u32, payload, buf);
for v in &self.types {
::buffa::types::encode_int32(v.to_i32(), buf);
}
}
}
}
impl<'a> ::buffa::MessageName for RelationView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "Relation";
const FULL_NAME: &'static str = "OSMPBF.Relation";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.Relation";
}
::buffa::impl_default_view_instance!(RelationView);
::buffa::impl_view_reborrow!(RelationView);
#[derive(Clone, Debug)]
pub struct RelationOwnedView(::buffa::OwnedView<RelationView<'static>>);
impl RelationOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(RelationOwnedView(::buffa::OwnedView::decode(bytes)?))
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RelationOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Relation,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RelationOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &RelationView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Relation {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn id(&self) -> i64 {
self.0.reborrow().id
}
#[must_use]
pub fn keys(&self) -> &::buffa::RepeatedView<'_, u32> {
&self.0.reborrow().keys
}
#[must_use]
pub fn vals(&self) -> &::buffa::RepeatedView<'_, u32> {
&self.0.reborrow().vals
}
#[must_use]
pub fn info(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::InfoView<'_>> {
&self.0.reborrow().info
}
#[must_use]
pub fn roles_sid(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().roles_sid
}
#[must_use]
pub fn memids(&self) -> &::buffa::RepeatedView<'_, i64> {
&self.0.reborrow().memids
}
#[must_use]
pub fn types(
&self,
) -> &::buffa::RepeatedView<'_, super::super::relation::MemberType> {
&self.0.reborrow().types
}
}
impl ::core::convert::From<::buffa::OwnedView<RelationView<'static>>>
for RelationOwnedView {
fn from(inner: ::buffa::OwnedView<RelationView<'static>>) -> Self {
RelationOwnedView(inner)
}
}
impl ::core::convert::From<RelationOwnedView>
for ::buffa::OwnedView<RelationView<'static>> {
fn from(wrapper: RelationOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<RelationView<'static>>>
for RelationOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<RelationView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Relation {
type View<'a> = RelationView<'a>;
type ViewHandle = RelationOwnedView;
}