#[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 = "OSMPBF";
const NAME: &'static str = "Blob";
const FULL_NAME: &'static str = "OSMPBF.Blob";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.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: &'a str,
pub indexdata: ::core::option::Option<&'a [u8]>,
pub datasize: i32,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
}
impl<'a> BlobHeaderView<'a> {
#[must_use]
#[inline]
pub const fn has_type(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
#[must_use]
#[inline]
pub const fn has_datasize(&self) -> bool {
self.__buffa_required_seen_0 & 2u64 != 0
}
}
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 = ::buffa::types::borrow_str(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.indexdata = Some(::buffa::types::borrow_bytes(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.datasize = ::buffa::types::decode_int32(&mut cur)?;
view.__buffa_required_seen_0 |= 2u64;
}
_ => {
::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.to_string(),
indexdata: self.indexdata.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;
size += 1u64 + ::buffa::types::string_encoded_len(&self.r#type) as u64;
if let Some(ref v) = self.indexdata {
size += 1u64 + ::buffa::types::bytes_encoded_len(v) as u64;
}
size += 1u64 + ::buffa::types::int32_encoded_len(self.datasize) 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_string_field(1u32, &self.r#type, buf);
if let Some(ref v) = self.indexdata {
::buffa::types::put_shared_bytes_field(2u32, v, buf);
}
::buffa::types::put_int32_field(3u32, self.datasize, buf);
}
}
impl<'a> ::buffa::MessageName for BlobHeaderView<'a> {
const PACKAGE: &'static str = "OSMPBF";
const NAME: &'static str = "BlobHeader";
const FULL_NAME: &'static str = "OSMPBF.BlobHeader";
const TYPE_URL: &'static str = "type.googleapis.com/OSMPBF.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) -> &'_ str {
self.0.reborrow().r#type
}
#[must_use]
pub fn indexdata(&self) -> ::core::option::Option<&'_ [u8]> {
self.0.reborrow().indexdata
}
#[must_use]
pub fn datasize(&self) -> 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;
}