#[derive(Clone, Debug, Default)]
pub struct BlobView<'a> {
pub raw_size: ::core::option::Option<i32>,
pub data: ::core::option::Option<super::super::__buffa::view::oneof::blob::Data<'a>>,
}
impl<'a> ::buffa::MessageView<'a> for BlobView<'a> {
type Owned = super::super::Blob;
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::Varint,
)?;
view.raw_size = Some(::buffa::types::decode_int32(&mut cur)?);
}
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.data = Some(
super::super::__buffa::view::oneof::blob::Data::Raw(
::buffa::types::borrow_bytes(&mut cur)?,
),
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.data = Some(
super::super::__buffa::view::oneof::blob::Data::ZlibData(
::buffa::types::borrow_bytes(&mut cur)?,
),
);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.data = Some(
super::super::__buffa::view::oneof::blob::Data::LzmaData(
::buffa::types::borrow_bytes(&mut cur)?,
),
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.data = Some(
super::super::__buffa::view::oneof::blob::Data::OBSOLETEBzip2Data(
::buffa::types::borrow_bytes(&mut cur)?,
),
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.data = Some(
super::super::__buffa::view::oneof::blob::Data::Lz4Data(
::buffa::types::borrow_bytes(&mut cur)?,
),
);
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.data = Some(
super::super::__buffa::view::oneof::blob::Data::ZstdData(
::buffa::types::borrow_bytes(&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::Blob, ::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::Blob, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Blob {
raw_size: self.raw_size,
data: self
.data
.as_ref()
.map(|v| match v {
super::super::__buffa::view::oneof::blob::Data::Raw(v) => {
super::super::__buffa::oneof::blob::Data::Raw((v).to_vec())
}
super::super::__buffa::view::oneof::blob::Data::ZlibData(v) => {
super::super::__buffa::oneof::blob::Data::ZlibData((v).to_vec())
}
super::super::__buffa::view::oneof::blob::Data::LzmaData(v) => {
super::super::__buffa::oneof::blob::Data::LzmaData((v).to_vec())
}
super::super::__buffa::view::oneof::blob::Data::OBSOLETEBzip2Data(
v,
) => {
super::super::__buffa::oneof::blob::Data::OBSOLETEBzip2Data(
(v).to_vec(),
)
}
super::super::__buffa::view::oneof::blob::Data::Lz4Data(v) => {
super::super::__buffa::oneof::blob::Data::Lz4Data((v).to_vec())
}
super::super::__buffa::view::oneof::blob::Data::ZstdData(v) => {
super::super::__buffa::oneof::blob::Data::ZstdData((v).to_vec())
}
}),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for BlobView<'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 ::core::option::Option::Some(ref v) = self.data {
match v {
super::super::__buffa::view::oneof::blob::Data::Raw(x) => {
size += 1u64 + ::buffa::types::bytes_encoded_len(x) as u64;
}
super::super::__buffa::view::oneof::blob::Data::ZlibData(x) => {
size += 1u64 + ::buffa::types::bytes_encoded_len(x) as u64;
}
super::super::__buffa::view::oneof::blob::Data::LzmaData(x) => {
size += 1u64 + ::buffa::types::bytes_encoded_len(x) as u64;
}
super::super::__buffa::view::oneof::blob::Data::OBSOLETEBzip2Data(x) => {
size += 1u64 + ::buffa::types::bytes_encoded_len(x) as u64;
}
super::super::__buffa::view::oneof::blob::Data::Lz4Data(x) => {
size += 1u64 + ::buffa::types::bytes_encoded_len(x) as u64;
}
super::super::__buffa::view::oneof::blob::Data::ZstdData(x) => {
size += 1u64 + ::buffa::types::bytes_encoded_len(x) as u64;
}
}
}
if let Some(v) = self.raw_size {
size += 1u64 + ::buffa::types::int32_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 let ::core::option::Option::Some(ref v) = self.data {
match v {
super::super::__buffa::view::oneof::blob::Data::Raw(x) => {
::buffa::types::put_shared_bytes_field(1u32, x, buf);
}
super::super::__buffa::view::oneof::blob::Data::ZlibData(x) => {
::buffa::types::put_shared_bytes_field(3u32, x, buf);
}
super::super::__buffa::view::oneof::blob::Data::LzmaData(x) => {
::buffa::types::put_shared_bytes_field(4u32, x, buf);
}
super::super::__buffa::view::oneof::blob::Data::OBSOLETEBzip2Data(x) => {
::buffa::types::put_shared_bytes_field(5u32, x, buf);
}
super::super::__buffa::view::oneof::blob::Data::Lz4Data(x) => {
::buffa::types::put_shared_bytes_field(6u32, x, buf);
}
super::super::__buffa::view::oneof::blob::Data::ZstdData(x) => {
::buffa::types::put_shared_bytes_field(7u32, x, buf);
}
}
}
if let Some(v) = self.raw_size {
::buffa::types::put_int32_field(2u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for BlobView<'a> {
const PACKAGE: &'static str = "osmflow_raw";
const NAME: &'static str = "Blob";
const FULL_NAME: &'static str = "osmflow_raw.Blob";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.Blob";
}
::buffa::impl_default_view_instance!(BlobView);
::buffa::impl_view_reborrow!(BlobView);
#[derive(Clone, Debug)]
pub struct BlobOwnedView(::buffa::OwnedView<BlobView<'static>>);
impl BlobOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(BlobOwnedView(::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(
BlobOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Blob,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(BlobOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &BlobView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Blob {
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 raw_size(&self) -> ::core::option::Option<i32> {
self.0.reborrow().raw_size
}
#[must_use]
pub fn data(
&self,
) -> ::core::option::Option<&super::super::__buffa::view::oneof::blob::Data<'_>> {
self.0.reborrow().data.as_ref()
}
}
impl ::core::convert::From<::buffa::OwnedView<BlobView<'static>>> for BlobOwnedView {
fn from(inner: ::buffa::OwnedView<BlobView<'static>>) -> Self {
BlobOwnedView(inner)
}
}
impl ::core::convert::From<BlobOwnedView> for ::buffa::OwnedView<BlobView<'static>> {
fn from(wrapper: BlobOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<BlobView<'static>>> for BlobOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<BlobView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Blob {
type View<'a> = BlobView<'a>;
type ViewHandle = BlobOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct BlobHeaderView<'a> {
pub r#type: ::core::option::Option<&'a [u8]>,
pub datasize: ::core::option::Option<i32>,
}
impl<'a> ::buffa::MessageView<'a> for BlobHeaderView<'a> {
type Owned = super::super::BlobHeader;
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,
)?;
view.r#type = Some(::buffa::types::borrow_bytes(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.datasize = Some(::buffa::types::decode_int32(&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::BlobHeader, ::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::BlobHeader, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::BlobHeader {
r#type: self.r#type.map(|b| (b).to_vec()),
datasize: self.datasize,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for BlobHeaderView<'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(ref v) = self.r#type {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64;
}
if let Some(v) = self.datasize {
size += 1u64 + ::buffa::types::int32_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 let Some(ref v) = self.r#type {
::buffa::types::put_shared_bytes_field(1u32, v, buf);
}
if let Some(v) = self.datasize {
::buffa::types::put_int32_field(3u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for BlobHeaderView<'a> {
const PACKAGE: &'static str = "osmflow_raw";
const NAME: &'static str = "BlobHeader";
const FULL_NAME: &'static str = "osmflow_raw.BlobHeader";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.BlobHeader";
}
::buffa::impl_default_view_instance!(BlobHeaderView);
::buffa::impl_view_reborrow!(BlobHeaderView);
#[derive(Clone, Debug)]
pub struct BlobHeaderOwnedView(::buffa::OwnedView<BlobHeaderView<'static>>);
impl BlobHeaderOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
BlobHeaderOwnedView(::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(
BlobHeaderOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::BlobHeader,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
BlobHeaderOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &BlobHeaderView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::BlobHeader {
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 r#type(&self) -> ::core::option::Option<&'_ [u8]> {
self.0.reborrow().r#type
}
#[must_use]
pub fn datasize(&self) -> ::core::option::Option<i32> {
self.0.reborrow().datasize
}
}
impl ::core::convert::From<::buffa::OwnedView<BlobHeaderView<'static>>>
for BlobHeaderOwnedView {
fn from(inner: ::buffa::OwnedView<BlobHeaderView<'static>>) -> Self {
BlobHeaderOwnedView(inner)
}
}
impl ::core::convert::From<BlobHeaderOwnedView>
for ::buffa::OwnedView<BlobHeaderView<'static>> {
fn from(wrapper: BlobHeaderOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<BlobHeaderView<'static>>>
for BlobHeaderOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<BlobHeaderView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::BlobHeader {
type View<'a> = BlobHeaderView<'a>;
type ViewHandle = BlobHeaderOwnedView;
}
#[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 date_granularity: ::core::option::Option<i32>,
pub lat_offset: ::core::option::Option<i64>,
pub lon_offset: ::core::option::Option<i64>,
}
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)?);
}
18u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.date_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)?);
}
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,
date_granularity: self.date_granularity,
lat_offset: self.lat_offset,
lon_offset: self.lon_offset,
..::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 = "osmflow_raw";
const NAME: &'static str = "PrimitiveBlock";
const FULL_NAME: &'static str = "osmflow_raw.PrimitiveBlock";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.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 date_granularity(&self) -> ::core::option::Option<i32> {
self.0.reborrow().date_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
}
}
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 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 = "osmflow_raw";
const NAME: &'static str = "StringTable";
const FULL_NAME: &'static str = "osmflow_raw.StringTable";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.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 PrimitiveGroupView<'a> {
pub nodes: ::buffa::RepeatedView<'a, &'a [u8]>,
pub dense: ::buffa::RepeatedView<'a, &'a [u8]>,
pub ways: ::buffa::RepeatedView<'a, &'a [u8]>,
pub relations: ::buffa::RepeatedView<'a, &'a [u8]>,
}
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() {
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.nodes.push(__elem);
}
2u32 => {
::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.dense.push(__elem);
}
3u32 => {
::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.ways.push(__elem);
}
4u32 => {
::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.relations.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::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(|b| (b).to_vec()).collect(),
dense: self.dense.iter().map(|b| (b).to_vec()).collect(),
ways: self.ways.iter().map(|b| (b).to_vec()).collect(),
relations: self.relations.iter().map(|b| (b).to_vec()).collect(),
..::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 {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64;
}
for v in &self.dense {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64;
}
for v in &self.ways {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64;
}
for v in &self.relations {
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.nodes {
::buffa::types::put_shared_bytes_field(1u32, v, buf);
}
for v in &self.dense {
::buffa::types::put_shared_bytes_field(2u32, v, buf);
}
for v in &self.ways {
::buffa::types::put_shared_bytes_field(3u32, v, buf);
}
for v in &self.relations {
::buffa::types::put_shared_bytes_field(4u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for PrimitiveGroupView<'a> {
const PACKAGE: &'static str = "osmflow_raw";
const NAME: &'static str = "PrimitiveGroup";
const FULL_NAME: &'static str = "osmflow_raw.PrimitiveGroup";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.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<'_, &'_ [u8]> {
&self.0.reborrow().nodes
}
#[must_use]
pub fn dense(&self) -> &::buffa::RepeatedView<'_, &'_ [u8]> {
&self.0.reborrow().dense
}
#[must_use]
pub fn ways(&self) -> &::buffa::RepeatedView<'_, &'_ [u8]> {
&self.0.reborrow().ways
}
#[must_use]
pub fn relations(&self) -> &::buffa::RepeatedView<'_, &'_ [u8]> {
&self.0.reborrow().relations
}
}
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 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 = "osmflow_raw";
const NAME: &'static str = "DenseInfo";
const FULL_NAME: &'static str = "osmflow_raw.DenseInfo";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.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 DenseNodesView<'a> {
pub id: ::buffa::RepeatedView<'a, i64>,
pub denseinfo: ::buffa::RepeatedView<'a, &'a [u8]>,
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() {
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,
),
);
}
}
5u32 => {
::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.denseinfo.push(__elem);
}
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: self.denseinfo.iter().map(|b| (b).to_vec()).collect(),
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;
}
for v in &self.denseinfo {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) 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);
}
}
for v in &self.denseinfo {
::buffa::types::put_shared_bytes_field(5u32, 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(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 = "osmflow_raw";
const NAME: &'static str = "DenseNodes";
const FULL_NAME: &'static str = "osmflow_raw.DenseNodes";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.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::RepeatedView<'_, &'_ [u8]> {
&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 DenseNodeLocationsView<'a> {
pub id: ::buffa::RepeatedView<'a, i64>,
pub lat: ::buffa::RepeatedView<'a, i64>,
pub lon: ::buffa::RepeatedView<'a, i64>,
}
impl<'a> ::buffa::MessageView<'a> for DenseNodeLocationsView<'a> {
type Owned = super::super::DenseNodeLocations;
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_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,
),
);
}
}
_ => {
::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::DenseNodeLocations, ::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::DenseNodeLocations, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::DenseNodeLocations {
id: self.id.to_vec(),
lat: self.lat.to_vec(),
lon: self.lon.to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for DenseNodeLocationsView<'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.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 _;
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.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);
}
}
}
}
impl<'a> ::buffa::MessageName for DenseNodeLocationsView<'a> {
const PACKAGE: &'static str = "osmflow_raw";
const NAME: &'static str = "DenseNodeLocations";
const FULL_NAME: &'static str = "osmflow_raw.DenseNodeLocations";
const TYPE_URL: &'static str = "type.googleapis.com/osmflow_raw.DenseNodeLocations";
}
::buffa::impl_default_view_instance!(DenseNodeLocationsView);
::buffa::impl_view_reborrow!(DenseNodeLocationsView);
#[derive(Clone, Debug)]
pub struct DenseNodeLocationsOwnedView(
::buffa::OwnedView<DenseNodeLocationsView<'static>>,
);
impl DenseNodeLocationsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseNodeLocationsOwnedView(::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(
DenseNodeLocationsOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::DenseNodeLocations,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DenseNodeLocationsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &DenseNodeLocationsView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::DenseNodeLocations {
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 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<DenseNodeLocationsView<'static>>>
for DenseNodeLocationsOwnedView {
fn from(inner: ::buffa::OwnedView<DenseNodeLocationsView<'static>>) -> Self {
DenseNodeLocationsOwnedView(inner)
}
}
impl ::core::convert::From<DenseNodeLocationsOwnedView>
for ::buffa::OwnedView<DenseNodeLocationsView<'static>> {
fn from(wrapper: DenseNodeLocationsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<DenseNodeLocationsView<'static>>>
for DenseNodeLocationsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<DenseNodeLocationsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::DenseNodeLocations {
type View<'a> = DenseNodeLocationsView<'a>;
type ViewHandle = DenseNodeLocationsOwnedView;
}