#[derive(Clone, Debug, Default)]
pub struct FileDescriptorSetView<'a> {
pub file: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::FileDescriptorProtoView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FileDescriptorSetView<'a> {
type Owned = super::super::FileDescriptorSet;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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)?;
view.file
.push(
<super::super::__buffa::view::FileDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FileDescriptorSet, ::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::FileDescriptorSet, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FileDescriptorSet {
file: self
.file
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FileDescriptorSetView<'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 = 0u32;
for v in &self.file {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.file {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FileDescriptorSetView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.file.is_empty() {
__map.serialize_entry("file", &*self.file)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FileDescriptorSetView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FileDescriptorSet";
const FULL_NAME: &'static str = "google.protobuf.FileDescriptorSet";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FileDescriptorSet";
}
::buffa::impl_default_view_instance!(FileDescriptorSetView);
::buffa::impl_view_reborrow!(FileDescriptorSetView);
#[derive(Clone, Debug)]
pub struct FileDescriptorSetOwnedView(
::buffa::OwnedView<FileDescriptorSetView<'static>>,
);
impl FileDescriptorSetOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FileDescriptorSetOwnedView(::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(
FileDescriptorSetOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::FileDescriptorSet,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FileDescriptorSetOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FileDescriptorSetView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FileDescriptorSet, ::buffa::DecodeError> {
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 file(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::FileDescriptorProtoView<'_>,
> {
&self.0.reborrow().file
}
}
impl ::core::convert::From<::buffa::OwnedView<FileDescriptorSetView<'static>>>
for FileDescriptorSetOwnedView {
fn from(inner: ::buffa::OwnedView<FileDescriptorSetView<'static>>) -> Self {
FileDescriptorSetOwnedView(inner)
}
}
impl ::core::convert::From<FileDescriptorSetOwnedView>
for ::buffa::OwnedView<FileDescriptorSetView<'static>> {
fn from(wrapper: FileDescriptorSetOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FileDescriptorSetView<'static>>>
for FileDescriptorSetOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FileDescriptorSetView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FileDescriptorSet {
type View<'a> = FileDescriptorSetView<'a>;
type ViewHandle = FileDescriptorSetOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FileDescriptorSetOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct FileDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub package: ::core::option::Option<&'a str>,
pub dependency: ::buffa::RepeatedView<'a, &'a str>,
pub public_dependency: ::buffa::RepeatedView<'a, i32>,
pub weak_dependency: ::buffa::RepeatedView<'a, i32>,
pub option_dependency: ::buffa::RepeatedView<'a, &'a str>,
pub message_type: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::DescriptorProtoView<'a>,
>,
pub enum_type: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::EnumDescriptorProtoView<'a>,
>,
pub service: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::ServiceDescriptorProtoView<'a>,
>,
pub extension: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::FieldDescriptorProtoView<'a>,
>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::FileOptionsView<'a>,
>,
pub source_code_info: ::buffa::MessageFieldView<
super::super::__buffa::view::SourceCodeInfoView<'a>,
>,
pub syntax: ::core::option::Option<&'a str>,
pub edition: ::core::option::Option<super::super::Edition>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FileDescriptorProtoView<'a> {
type Owned = super::super::FileDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.package = Some(::buffa::types::borrow_str(&mut cur)?);
}
8u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FileOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
9u32 => {
::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.source_code_info.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.source_code_info = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::SourceCodeInfoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
12u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.syntax = Some(::buffa::types::borrow_str(&mut cur)?);
}
14u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.edition = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.dependency.push(::buffa::types::borrow_str(&mut cur)?);
}
10u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
view.public_dependency
.reserve(::buffa::encoding::count_varints(payload));
let mut pcur: &[u8] = payload;
while !pcur.is_empty() {
view.public_dependency
.push(::buffa::types::decode_int32(&mut pcur)?);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.public_dependency.push(::buffa::types::decode_int32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
11u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
view.weak_dependency
.reserve(::buffa::encoding::count_varints(payload));
let mut pcur: &[u8] = payload;
while !pcur.is_empty() {
view.weak_dependency
.push(::buffa::types::decode_int32(&mut pcur)?);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.weak_dependency.push(::buffa::types::decode_int32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
15u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.option_dependency.push(::buffa::types::borrow_str(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.message_type
.push(
<super::super::__buffa::view::DescriptorProtoView 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)?;
view.enum_type
.push(
<super::super::__buffa::view::EnumDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.service
.push(
<super::super::__buffa::view::ServiceDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.extension
.push(
<super::super::__buffa::view::FieldDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::FileDescriptorProto,
::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::FileDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FileDescriptorProto {
name: self.name.map(|s| s.to_string()),
package: self.package.map(|s| s.to_string()),
dependency: self.dependency.iter().map(|s| s.to_string()).collect(),
public_dependency: self.public_dependency.to_vec(),
weak_dependency: self.weak_dependency.to_vec(),
option_dependency: self
.option_dependency
.iter()
.map(|s| s.to_string())
.collect(),
message_type: self
.message_type
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
enum_type: self
.enum_type
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
service: self
.service
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
extension: self
.extension
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FileOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
source_code_info: match self.source_code_info.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::SourceCodeInfo,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
syntax: self.syntax.map(|s| s.to_string()),
edition: self.edition,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FileDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.package {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.dependency {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.message_type {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.enum_type {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.service {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.extension {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.source_code_info.is_set() {
let __slot = __cache.reserve();
let inner_size = self.source_code_info.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.public_dependency {
size += 1u32 + ::buffa::types::int32_encoded_len(*v) as u32;
}
for v in &self.weak_dependency {
size += 1u32 + ::buffa::types::int32_encoded_len(*v) as u32;
}
if let Some(ref v) = self.syntax {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.edition {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
for v in &self.option_dependency {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
if let Some(ref v) = self.package {
::buffa::types::put_string_field(2u32, v, buf);
}
for v in &self.dependency {
::buffa::types::put_string_field(3u32, v, buf);
}
for v in &self.message_type {
::buffa::types::put_len_delimited_header(4u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.enum_type {
::buffa::types::put_len_delimited_header(5u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.service {
::buffa::types::put_len_delimited_header(6u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.extension {
::buffa::types::put_len_delimited_header(7u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(8u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
if self.source_code_info.is_set() {
::buffa::types::put_len_delimited_header(9u32, __cache.consume_next(), buf);
self.source_code_info.write_to(__cache, buf);
}
for v in &self.public_dependency {
::buffa::types::put_int32_field(10u32, *v, buf);
}
for v in &self.weak_dependency {
::buffa::types::put_int32_field(11u32, *v, buf);
}
if let Some(ref v) = self.syntax {
::buffa::types::put_string_field(12u32, v, buf);
}
if let Some(ref v) = self.edition {
::buffa::types::put_int32_field(14u32, v.to_i32(), buf);
}
for v in &self.option_dependency {
::buffa::types::put_string_field(15u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FileDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if let ::core::option::Option::Some(__v) = self.package {
__map.serialize_entry("package", __v)?;
}
if !self.dependency.is_empty() {
__map.serialize_entry("dependency", &*self.dependency)?;
}
if !self.public_dependency.is_empty() {
__map
.serialize_entry(
"publicDependency",
&::buffa::json_helpers::RepeatedJson(&self.public_dependency),
)?;
}
if !self.weak_dependency.is_empty() {
__map
.serialize_entry(
"weakDependency",
&::buffa::json_helpers::RepeatedJson(&self.weak_dependency),
)?;
}
if !self.option_dependency.is_empty() {
__map.serialize_entry("optionDependency", &*self.option_dependency)?;
}
if !self.message_type.is_empty() {
__map.serialize_entry("messageType", &*self.message_type)?;
}
if !self.enum_type.is_empty() {
__map.serialize_entry("enumType", &*self.enum_type)?;
}
if !self.service.is_empty() {
__map.serialize_entry("service", &*self.service)?;
}
if !self.extension.is_empty() {
__map.serialize_entry("extension", &*self.extension)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
{
if let ::core::option::Option::Some(__v) = self.source_code_info.as_option()
{
__map.serialize_entry("sourceCodeInfo", __v)?;
}
}
if let ::core::option::Option::Some(__v) = self.syntax {
__map.serialize_entry("syntax", __v)?;
}
if let ::core::option::Option::Some(__v) = self.edition {
__map
.serialize_entry(
"edition",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FileDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FileDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.FileDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FileDescriptorProto";
}
::buffa::impl_default_view_instance!(FileDescriptorProtoView);
::buffa::impl_view_reborrow!(FileDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct FileDescriptorProtoOwnedView(
::buffa::OwnedView<FileDescriptorProtoView<'static>>,
);
impl FileDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FileDescriptorProtoOwnedView(::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(
FileDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::FileDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FileDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FileDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::FileDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn package(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().package
}
#[must_use]
pub fn dependency(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().dependency
}
#[must_use]
pub fn public_dependency(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().public_dependency
}
#[must_use]
pub fn weak_dependency(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().weak_dependency
}
#[must_use]
pub fn option_dependency(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().option_dependency
}
#[must_use]
pub fn message_type(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::DescriptorProtoView<'_>,
> {
&self.0.reborrow().message_type
}
#[must_use]
pub fn enum_type(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::EnumDescriptorProtoView<'_>,
> {
&self.0.reborrow().enum_type
}
#[must_use]
pub fn service(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::ServiceDescriptorProtoView<'_>,
> {
&self.0.reborrow().service
}
#[must_use]
pub fn extension(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::FieldDescriptorProtoView<'_>,
> {
&self.0.reborrow().extension
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FileOptionsView<'_>> {
&self.0.reborrow().options
}
#[must_use]
pub fn source_code_info(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::SourceCodeInfoView<'_>,
> {
&self.0.reborrow().source_code_info
}
#[must_use]
pub fn syntax(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().syntax
}
#[must_use]
pub fn edition(&self) -> ::core::option::Option<super::super::Edition> {
self.0.reborrow().edition
}
}
impl ::core::convert::From<::buffa::OwnedView<FileDescriptorProtoView<'static>>>
for FileDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<FileDescriptorProtoView<'static>>) -> Self {
FileDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<FileDescriptorProtoOwnedView>
for ::buffa::OwnedView<FileDescriptorProtoView<'static>> {
fn from(wrapper: FileDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FileDescriptorProtoView<'static>>>
for FileDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FileDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FileDescriptorProto {
type View<'a> = FileDescriptorProtoView<'a>;
type ViewHandle = FileDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FileDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct DescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub field: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::FieldDescriptorProtoView<'a>,
>,
pub extension: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::FieldDescriptorProtoView<'a>,
>,
pub nested_type: ::buffa::RepeatedView<'a, Self>,
pub enum_type: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::EnumDescriptorProtoView<'a>,
>,
pub extension_range: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::descriptor_proto::ExtensionRangeView<'a>,
>,
pub oneof_decl: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::OneofDescriptorProtoView<'a>,
>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::MessageOptionsView<'a>,
>,
pub reserved_range: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::descriptor_proto::ReservedRangeView<'a>,
>,
pub reserved_name: ::buffa::RepeatedView<'a, &'a str>,
pub visibility: ::core::option::Option<super::super::SymbolVisibility>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for DescriptorProtoView<'a> {
type Owned = super::super::DescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
7u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::MessageOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
11u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.visibility = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.field
.push(
<super::super::__buffa::view::FieldDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.extension
.push(
<super::super::__buffa::view::FieldDescriptorProtoView 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)?;
view.nested_type
.push(
<super::super::__buffa::view::DescriptorProtoView 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)?;
view.enum_type
.push(
<super::super::__buffa::view::EnumDescriptorProtoView 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)?;
view.extension_range
.push(
<super::super::__buffa::view::descriptor_proto::ExtensionRangeView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.oneof_decl
.push(
<super::super::__buffa::view::OneofDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
9u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.reserved_range
.push(
<super::super::__buffa::view::descriptor_proto::ReservedRangeView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
10u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.reserved_name.push(::buffa::types::borrow_str(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::DescriptorProto, ::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::DescriptorProto, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::DescriptorProto {
name: self.name.map(|s| s.to_string()),
field: self
.field
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
extension: self
.extension
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
nested_type: self
.nested_type
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
enum_type: self
.enum_type
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
extension_range: self
.extension_range
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
oneof_decl: self
.oneof_decl
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::MessageOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
reserved_range: self
.reserved_range
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
reserved_name: self.reserved_name.iter().map(|s| s.to_string()).collect(),
visibility: self.visibility,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for DescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.field {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.nested_type {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.enum_type {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.extension_range {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.extension {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.oneof_decl {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.reserved_range {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.reserved_name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.visibility {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
for v in &self.field {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.nested_type {
::buffa::types::put_len_delimited_header(3u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.enum_type {
::buffa::types::put_len_delimited_header(4u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.extension_range {
::buffa::types::put_len_delimited_header(5u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.extension {
::buffa::types::put_len_delimited_header(6u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(7u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
for v in &self.oneof_decl {
::buffa::types::put_len_delimited_header(8u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.reserved_range {
::buffa::types::put_len_delimited_header(9u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.reserved_name {
::buffa::types::put_string_field(10u32, v, buf);
}
if let Some(ref v) = self.visibility {
::buffa::types::put_int32_field(11u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for DescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if !self.field.is_empty() {
__map.serialize_entry("field", &*self.field)?;
}
if !self.extension.is_empty() {
__map.serialize_entry("extension", &*self.extension)?;
}
if !self.nested_type.is_empty() {
__map.serialize_entry("nestedType", &*self.nested_type)?;
}
if !self.enum_type.is_empty() {
__map.serialize_entry("enumType", &*self.enum_type)?;
}
if !self.extension_range.is_empty() {
__map.serialize_entry("extensionRange", &*self.extension_range)?;
}
if !self.oneof_decl.is_empty() {
__map.serialize_entry("oneofDecl", &*self.oneof_decl)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
if !self.reserved_range.is_empty() {
__map.serialize_entry("reservedRange", &*self.reserved_range)?;
}
if !self.reserved_name.is_empty() {
__map.serialize_entry("reservedName", &*self.reserved_name)?;
}
if let ::core::option::Option::Some(__v) = self.visibility {
__map
.serialize_entry(
"visibility",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for DescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "DescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.DescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.DescriptorProto";
}
::buffa::impl_default_view_instance!(DescriptorProtoView);
::buffa::impl_view_reborrow!(DescriptorProtoView);
#[derive(Clone, Debug)]
pub struct DescriptorProtoOwnedView(::buffa::OwnedView<DescriptorProtoView<'static>>);
impl DescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DescriptorProtoOwnedView(::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(
DescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::DescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &DescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::DescriptorProto, ::buffa::DecodeError> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn field(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::FieldDescriptorProtoView<'_>,
> {
&self.0.reborrow().field
}
#[must_use]
pub fn extension(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::FieldDescriptorProtoView<'_>,
> {
&self.0.reborrow().extension
}
#[must_use]
pub fn nested_type(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::DescriptorProtoView<'_>,
> {
&self.0.reborrow().nested_type
}
#[must_use]
pub fn enum_type(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::EnumDescriptorProtoView<'_>,
> {
&self.0.reborrow().enum_type
}
#[must_use]
pub fn extension_range(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::descriptor_proto::ExtensionRangeView<'_>,
> {
&self.0.reborrow().extension_range
}
#[must_use]
pub fn oneof_decl(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::OneofDescriptorProtoView<'_>,
> {
&self.0.reborrow().oneof_decl
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::MessageOptionsView<'_>,
> {
&self.0.reborrow().options
}
#[must_use]
pub fn reserved_range(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::descriptor_proto::ReservedRangeView<'_>,
> {
&self.0.reborrow().reserved_range
}
#[must_use]
pub fn reserved_name(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().reserved_name
}
#[must_use]
pub fn visibility(&self) -> ::core::option::Option<super::super::SymbolVisibility> {
self.0.reborrow().visibility
}
}
impl ::core::convert::From<::buffa::OwnedView<DescriptorProtoView<'static>>>
for DescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<DescriptorProtoView<'static>>) -> Self {
DescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<DescriptorProtoOwnedView>
for ::buffa::OwnedView<DescriptorProtoView<'static>> {
fn from(wrapper: DescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<DescriptorProtoView<'static>>>
for DescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<DescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::DescriptorProto {
type View<'a> = DescriptorProtoView<'a>;
type ViewHandle = DescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for DescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod descriptor_proto {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct ExtensionRangeView<'a> {
pub start: ::core::option::Option<i32>,
pub end: ::core::option::Option<i32>,
pub options: ::buffa::MessageFieldView<
super::super::super::__buffa::view::ExtensionRangeOptionsView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for ExtensionRangeView<'a> {
type Owned = super::super::super::descriptor_proto::ExtensionRange;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.start = Some(::buffa::types::decode_int32(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.end = Some(::buffa::types::decode_int32(&mut cur)?);
}
3u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(
existing,
sub,
__sub_ctx,
)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::super::__buffa::view::ExtensionRangeOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::descriptor_proto::ExtensionRange,
::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::super::descriptor_proto::ExtensionRange,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::descriptor_proto::ExtensionRange {
start: self.start,
end: self.end,
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::super::ExtensionRangeOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ExtensionRangeView<'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 = 0u32;
if let Some(v) = self.start {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(v) = self.end {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.start {
::buffa::types::put_int32_field(1u32, v, buf);
}
if let Some(v) = self.end {
::buffa::types::put_int32_field(2u32, v, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(
3u32,
__cache.consume_next(),
buf,
);
self.options.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for ExtensionRangeView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.start {
__map.serialize_entry("start", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.end {
__map.serialize_entry("end", &::buffa::json_helpers::ProtoJson(&__v))?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for ExtensionRangeView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "DescriptorProto.ExtensionRange";
const FULL_NAME: &'static str = "google.protobuf.DescriptorProto.ExtensionRange";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.DescriptorProto.ExtensionRange";
}
::buffa::impl_default_view_instance!(ExtensionRangeView);
::buffa::impl_view_reborrow!(ExtensionRangeView);
#[derive(Clone, Debug)]
pub struct ExtensionRangeOwnedView(::buffa::OwnedView<ExtensionRangeView<'static>>);
impl ExtensionRangeOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ExtensionRangeOwnedView(::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(
ExtensionRangeOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::descriptor_proto::ExtensionRange,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ExtensionRangeOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &ExtensionRangeView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::descriptor_proto::ExtensionRange,
::buffa::DecodeError,
> {
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 start(&self) -> ::core::option::Option<i32> {
self.0.reborrow().start
}
#[must_use]
pub fn end(&self) -> ::core::option::Option<i32> {
self.0.reborrow().end
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<
super::super::super::__buffa::view::ExtensionRangeOptionsView<'_>,
> {
&self.0.reborrow().options
}
}
impl ::core::convert::From<::buffa::OwnedView<ExtensionRangeView<'static>>>
for ExtensionRangeOwnedView {
fn from(inner: ::buffa::OwnedView<ExtensionRangeView<'static>>) -> Self {
ExtensionRangeOwnedView(inner)
}
}
impl ::core::convert::From<ExtensionRangeOwnedView>
for ::buffa::OwnedView<ExtensionRangeView<'static>> {
fn from(wrapper: ExtensionRangeOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ExtensionRangeView<'static>>>
for ExtensionRangeOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ExtensionRangeView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::descriptor_proto::ExtensionRange {
type View<'a> = ExtensionRangeView<'a>;
type ViewHandle = ExtensionRangeOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for ExtensionRangeOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct ReservedRangeView<'a> {
pub start: ::core::option::Option<i32>,
pub end: ::core::option::Option<i32>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for ReservedRangeView<'a> {
type Owned = super::super::super::descriptor_proto::ReservedRange;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.start = Some(::buffa::types::decode_int32(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.end = Some(::buffa::types::decode_int32(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::descriptor_proto::ReservedRange,
::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::super::descriptor_proto::ReservedRange,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::descriptor_proto::ReservedRange {
start: self.start,
end: self.end,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ReservedRangeView<'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 = 0u32;
if let Some(v) = self.start {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(v) = self.end {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.start {
::buffa::types::put_int32_field(1u32, v, buf);
}
if let Some(v) = self.end {
::buffa::types::put_int32_field(2u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for ReservedRangeView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.start {
__map.serialize_entry("start", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.end {
__map.serialize_entry("end", &::buffa::json_helpers::ProtoJson(&__v))?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for ReservedRangeView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "DescriptorProto.ReservedRange";
const FULL_NAME: &'static str = "google.protobuf.DescriptorProto.ReservedRange";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.DescriptorProto.ReservedRange";
}
::buffa::impl_default_view_instance!(ReservedRangeView);
::buffa::impl_view_reborrow!(ReservedRangeView);
#[derive(Clone, Debug)]
pub struct ReservedRangeOwnedView(::buffa::OwnedView<ReservedRangeView<'static>>);
impl ReservedRangeOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ReservedRangeOwnedView(::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(
ReservedRangeOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::descriptor_proto::ReservedRange,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ReservedRangeOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &ReservedRangeView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::descriptor_proto::ReservedRange,
::buffa::DecodeError,
> {
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 start(&self) -> ::core::option::Option<i32> {
self.0.reborrow().start
}
#[must_use]
pub fn end(&self) -> ::core::option::Option<i32> {
self.0.reborrow().end
}
}
impl ::core::convert::From<::buffa::OwnedView<ReservedRangeView<'static>>>
for ReservedRangeOwnedView {
fn from(inner: ::buffa::OwnedView<ReservedRangeView<'static>>) -> Self {
ReservedRangeOwnedView(inner)
}
}
impl ::core::convert::From<ReservedRangeOwnedView>
for ::buffa::OwnedView<ReservedRangeView<'static>> {
fn from(wrapper: ReservedRangeOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ReservedRangeView<'static>>>
for ReservedRangeOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ReservedRangeView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::descriptor_proto::ReservedRange {
type View<'a> = ReservedRangeView<'a>;
type ViewHandle = ReservedRangeOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for ReservedRangeOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct ExtensionRangeOptionsView<'a> {
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub declaration: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::extension_range_options::DeclarationView<'a>,
>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub verification: ::core::option::Option<
super::super::extension_range_options::VerificationState,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for ExtensionRangeOptionsView<'a> {
type Owned = super::super::ExtensionRangeOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
50u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.verification = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.declaration
.push(
<super::super::__buffa::view::extension_range_options::DeclarationView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::ExtensionRangeOptions,
::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::ExtensionRangeOptions,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::ExtensionRangeOptions {
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
declaration: self
.declaration
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
verification: self.verification,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ExtensionRangeOptionsView<'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 = 0u32;
for v in &self.declaration {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if let Some(ref v) = self.verification {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.declaration {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if let Some(ref v) = self.verification {
::buffa::types::put_int32_field(3u32, v.to_i32(), buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(50u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for ExtensionRangeOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
if !self.declaration.is_empty() {
__map.serialize_entry("declaration", &*self.declaration)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if let ::core::option::Option::Some(__v) = self.verification {
__map
.serialize_entry(
"verification",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for ExtensionRangeOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "ExtensionRangeOptions";
const FULL_NAME: &'static str = "google.protobuf.ExtensionRangeOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ExtensionRangeOptions";
}
::buffa::impl_default_view_instance!(ExtensionRangeOptionsView);
::buffa::impl_view_reborrow!(ExtensionRangeOptionsView);
#[derive(Clone, Debug)]
pub struct ExtensionRangeOptionsOwnedView(
::buffa::OwnedView<ExtensionRangeOptionsView<'static>>,
);
impl ExtensionRangeOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ExtensionRangeOptionsOwnedView(::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(
ExtensionRangeOptionsOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::ExtensionRangeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ExtensionRangeOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &ExtensionRangeOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::ExtensionRangeOptions,
::buffa::DecodeError,
> {
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 uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
#[must_use]
pub fn declaration(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::extension_range_options::DeclarationView<'_>,
> {
&self.0.reborrow().declaration
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn verification(
&self,
) -> ::core::option::Option<
super::super::extension_range_options::VerificationState,
> {
self.0.reborrow().verification
}
}
impl ::core::convert::From<::buffa::OwnedView<ExtensionRangeOptionsView<'static>>>
for ExtensionRangeOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<ExtensionRangeOptionsView<'static>>) -> Self {
ExtensionRangeOptionsOwnedView(inner)
}
}
impl ::core::convert::From<ExtensionRangeOptionsOwnedView>
for ::buffa::OwnedView<ExtensionRangeOptionsView<'static>> {
fn from(wrapper: ExtensionRangeOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ExtensionRangeOptionsView<'static>>>
for ExtensionRangeOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ExtensionRangeOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::ExtensionRangeOptions {
type View<'a> = ExtensionRangeOptionsView<'a>;
type ViewHandle = ExtensionRangeOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for ExtensionRangeOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod extension_range_options {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct DeclarationView<'a> {
pub number: ::core::option::Option<i32>,
pub full_name: ::core::option::Option<&'a str>,
pub r#type: ::core::option::Option<&'a str>,
pub reserved: ::core::option::Option<bool>,
pub repeated: ::core::option::Option<bool>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for DeclarationView<'a> {
type Owned = super::super::super::extension_range_options::Declaration;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.number = Some(::buffa::types::decode_int32(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.full_name = Some(::buffa::types::borrow_str(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.r#type = Some(::buffa::types::borrow_str(&mut cur)?);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.reserved = Some(::buffa::types::decode_bool(&mut cur)?);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.repeated = Some(::buffa::types::decode_bool(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::extension_range_options::Declaration,
::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::super::extension_range_options::Declaration,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::extension_range_options::Declaration {
number: self.number,
full_name: self.full_name.map(|s| s.to_string()),
r#type: self.r#type.map(|s| s.to_string()),
reserved: self.reserved,
repeated: self.repeated,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for DeclarationView<'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 = 0u32;
if let Some(v) = self.number {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(ref v) = self.full_name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.r#type {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.reserved.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.repeated.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.number {
::buffa::types::put_int32_field(1u32, v, buf);
}
if let Some(ref v) = self.full_name {
::buffa::types::put_string_field(2u32, v, buf);
}
if let Some(ref v) = self.r#type {
::buffa::types::put_string_field(3u32, v, buf);
}
if let Some(v) = self.reserved {
::buffa::types::put_bool_field(5u32, v, buf);
}
if let Some(v) = self.repeated {
::buffa::types::put_bool_field(6u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for DeclarationView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.number {
__map
.serialize_entry("number", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.full_name {
__map.serialize_entry("fullName", __v)?;
}
if let ::core::option::Option::Some(__v) = self.r#type {
__map.serialize_entry("type", __v)?;
}
if let ::core::option::Option::Some(__v) = self.reserved {
__map.serialize_entry("reserved", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.repeated {
__map.serialize_entry("repeated", &__v)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for DeclarationView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "ExtensionRangeOptions.Declaration";
const FULL_NAME: &'static str = "google.protobuf.ExtensionRangeOptions.Declaration";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ExtensionRangeOptions.Declaration";
}
::buffa::impl_default_view_instance!(DeclarationView);
::buffa::impl_view_reborrow!(DeclarationView);
#[derive(Clone, Debug)]
pub struct DeclarationOwnedView(::buffa::OwnedView<DeclarationView<'static>>);
impl DeclarationOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DeclarationOwnedView(::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(
DeclarationOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::extension_range_options::Declaration,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DeclarationOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &DeclarationView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::extension_range_options::Declaration,
::buffa::DecodeError,
> {
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 number(&self) -> ::core::option::Option<i32> {
self.0.reborrow().number
}
#[must_use]
pub fn full_name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().full_name
}
#[must_use]
pub fn r#type(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().r#type
}
#[must_use]
pub fn reserved(&self) -> ::core::option::Option<bool> {
self.0.reborrow().reserved
}
#[must_use]
pub fn repeated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().repeated
}
}
impl ::core::convert::From<::buffa::OwnedView<DeclarationView<'static>>>
for DeclarationOwnedView {
fn from(inner: ::buffa::OwnedView<DeclarationView<'static>>) -> Self {
DeclarationOwnedView(inner)
}
}
impl ::core::convert::From<DeclarationOwnedView>
for ::buffa::OwnedView<DeclarationView<'static>> {
fn from(wrapper: DeclarationOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<DeclarationView<'static>>>
for DeclarationOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<DeclarationView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::extension_range_options::Declaration {
type View<'a> = DeclarationView<'a>;
type ViewHandle = DeclarationOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for DeclarationOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct FieldDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub number: ::core::option::Option<i32>,
pub label: ::core::option::Option<super::super::field_descriptor_proto::Label>,
pub r#type: ::core::option::Option<super::super::field_descriptor_proto::Type>,
pub type_name: ::core::option::Option<&'a str>,
pub extendee: ::core::option::Option<&'a str>,
pub default_value: ::core::option::Option<&'a str>,
pub oneof_index: ::core::option::Option<i32>,
pub json_name: ::core::option::Option<&'a str>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::FieldOptionsView<'a>,
>,
pub proto3_optional: ::core::option::Option<bool>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FieldDescriptorProtoView<'a> {
type Owned = super::super::FieldDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.number = Some(::buffa::types::decode_int32(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.label = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.r#type = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.type_name = Some(::buffa::types::borrow_str(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.extendee = Some(::buffa::types::borrow_str(&mut cur)?);
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.default_value = Some(::buffa::types::borrow_str(&mut cur)?);
}
9u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.oneof_index = Some(::buffa::types::decode_int32(&mut cur)?);
}
10u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.json_name = Some(::buffa::types::borrow_str(&mut cur)?);
}
8u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FieldOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
17u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.proto3_optional = Some(::buffa::types::decode_bool(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::FieldDescriptorProto,
::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::FieldDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FieldDescriptorProto {
name: self.name.map(|s| s.to_string()),
number: self.number,
label: self.label,
r#type: self.r#type,
type_name: self.type_name.map(|s| s.to_string()),
extendee: self.extendee.map(|s| s.to_string()),
default_value: self.default_value.map(|s| s.to_string()),
oneof_index: self.oneof_index,
json_name: self.json_name.map(|s| s.to_string()),
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FieldOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
proto3_optional: self.proto3_optional,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FieldDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.extendee {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(v) = self.number {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(ref v) = self.label {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.r#type {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.type_name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.default_value {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if let Some(v) = self.oneof_index {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(ref v) = self.json_name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.proto3_optional.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
if let Some(ref v) = self.extendee {
::buffa::types::put_string_field(2u32, v, buf);
}
if let Some(v) = self.number {
::buffa::types::put_int32_field(3u32, v, buf);
}
if let Some(ref v) = self.label {
::buffa::types::put_int32_field(4u32, v.to_i32(), buf);
}
if let Some(ref v) = self.r#type {
::buffa::types::put_int32_field(5u32, v.to_i32(), buf);
}
if let Some(ref v) = self.type_name {
::buffa::types::put_string_field(6u32, v, buf);
}
if let Some(ref v) = self.default_value {
::buffa::types::put_string_field(7u32, v, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(8u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
if let Some(v) = self.oneof_index {
::buffa::types::put_int32_field(9u32, v, buf);
}
if let Some(ref v) = self.json_name {
::buffa::types::put_string_field(10u32, v, buf);
}
if let Some(v) = self.proto3_optional {
::buffa::types::put_bool_field(17u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FieldDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if let ::core::option::Option::Some(__v) = self.number {
__map.serialize_entry("number", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.label {
__map
.serialize_entry("label", &::buffa::json_helpers::ClosedEnumJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.r#type {
__map.serialize_entry("type", &::buffa::json_helpers::ClosedEnumJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.type_name {
__map.serialize_entry("typeName", __v)?;
}
if let ::core::option::Option::Some(__v) = self.extendee {
__map.serialize_entry("extendee", __v)?;
}
if let ::core::option::Option::Some(__v) = self.default_value {
__map.serialize_entry("defaultValue", __v)?;
}
if let ::core::option::Option::Some(__v) = self.oneof_index {
__map
.serialize_entry("oneofIndex", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.json_name {
__map.serialize_entry("jsonName", __v)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
if let ::core::option::Option::Some(__v) = self.proto3_optional {
__map.serialize_entry("proto3Optional", &__v)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FieldDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FieldDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.FieldDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldDescriptorProto";
}
::buffa::impl_default_view_instance!(FieldDescriptorProtoView);
::buffa::impl_view_reborrow!(FieldDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct FieldDescriptorProtoOwnedView(
::buffa::OwnedView<FieldDescriptorProtoView<'static>>,
);
impl FieldDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FieldDescriptorProtoOwnedView(::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(
FieldDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::FieldDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FieldDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FieldDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::FieldDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn number(&self) -> ::core::option::Option<i32> {
self.0.reborrow().number
}
#[must_use]
pub fn label(
&self,
) -> ::core::option::Option<super::super::field_descriptor_proto::Label> {
self.0.reborrow().label
}
#[must_use]
pub fn r#type(
&self,
) -> ::core::option::Option<super::super::field_descriptor_proto::Type> {
self.0.reborrow().r#type
}
#[must_use]
pub fn type_name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().type_name
}
#[must_use]
pub fn extendee(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().extendee
}
#[must_use]
pub fn default_value(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().default_value
}
#[must_use]
pub fn oneof_index(&self) -> ::core::option::Option<i32> {
self.0.reborrow().oneof_index
}
#[must_use]
pub fn json_name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().json_name
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FieldOptionsView<'_>> {
&self.0.reborrow().options
}
#[must_use]
pub fn proto3_optional(&self) -> ::core::option::Option<bool> {
self.0.reborrow().proto3_optional
}
}
impl ::core::convert::From<::buffa::OwnedView<FieldDescriptorProtoView<'static>>>
for FieldDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<FieldDescriptorProtoView<'static>>) -> Self {
FieldDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<FieldDescriptorProtoOwnedView>
for ::buffa::OwnedView<FieldDescriptorProtoView<'static>> {
fn from(wrapper: FieldDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FieldDescriptorProtoView<'static>>>
for FieldDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FieldDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FieldDescriptorProto {
type View<'a> = FieldDescriptorProtoView<'a>;
type ViewHandle = FieldDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FieldDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct OneofDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::OneofOptionsView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for OneofDescriptorProtoView<'a> {
type Owned = super::super::OneofDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&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)?;
match view.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::OneofOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::OneofDescriptorProto,
::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::OneofDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::OneofDescriptorProto {
name: self.name.map(|s| s.to_string()),
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::OneofOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for OneofDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for OneofDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for OneofDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "OneofDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.OneofDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.OneofDescriptorProto";
}
::buffa::impl_default_view_instance!(OneofDescriptorProtoView);
::buffa::impl_view_reborrow!(OneofDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct OneofDescriptorProtoOwnedView(
::buffa::OwnedView<OneofDescriptorProtoView<'static>>,
);
impl OneofDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
OneofDescriptorProtoOwnedView(::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(
OneofDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::OneofDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
OneofDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &OneofDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::OneofDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::OneofOptionsView<'_>> {
&self.0.reborrow().options
}
}
impl ::core::convert::From<::buffa::OwnedView<OneofDescriptorProtoView<'static>>>
for OneofDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<OneofDescriptorProtoView<'static>>) -> Self {
OneofDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<OneofDescriptorProtoOwnedView>
for ::buffa::OwnedView<OneofDescriptorProtoView<'static>> {
fn from(wrapper: OneofDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<OneofDescriptorProtoView<'static>>>
for OneofDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<OneofDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::OneofDescriptorProto {
type View<'a> = OneofDescriptorProtoView<'a>;
type ViewHandle = OneofDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for OneofDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct EnumDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub value: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::EnumValueDescriptorProtoView<'a>,
>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::EnumOptionsView<'a>,
>,
pub reserved_range: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::enum_descriptor_proto::EnumReservedRangeView<'a>,
>,
pub reserved_name: ::buffa::RepeatedView<'a, &'a str>,
pub visibility: ::core::option::Option<super::super::SymbolVisibility>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for EnumDescriptorProtoView<'a> {
type Owned = super::super::EnumDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
3u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::EnumOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.visibility = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.value
.push(
<super::super::__buffa::view::EnumValueDescriptorProtoView 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)?;
view.reserved_range
.push(
<super::super::__buffa::view::enum_descriptor_proto::EnumReservedRangeView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.reserved_name.push(::buffa::types::borrow_str(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::EnumDescriptorProto,
::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::EnumDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::EnumDescriptorProto {
name: self.name.map(|s| s.to_string()),
value: self
.value
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::EnumOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
reserved_range: self
.reserved_range
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
reserved_name: self.reserved_name.iter().map(|s| s.to_string()).collect(),
visibility: self.visibility,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for EnumDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.value {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.reserved_range {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.reserved_name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.visibility {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
for v in &self.value {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(3u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
for v in &self.reserved_range {
::buffa::types::put_len_delimited_header(4u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.reserved_name {
::buffa::types::put_string_field(5u32, v, buf);
}
if let Some(ref v) = self.visibility {
::buffa::types::put_int32_field(6u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for EnumDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if !self.value.is_empty() {
__map.serialize_entry("value", &*self.value)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
if !self.reserved_range.is_empty() {
__map.serialize_entry("reservedRange", &*self.reserved_range)?;
}
if !self.reserved_name.is_empty() {
__map.serialize_entry("reservedName", &*self.reserved_name)?;
}
if let ::core::option::Option::Some(__v) = self.visibility {
__map
.serialize_entry(
"visibility",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for EnumDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "EnumDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.EnumDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.EnumDescriptorProto";
}
::buffa::impl_default_view_instance!(EnumDescriptorProtoView);
::buffa::impl_view_reborrow!(EnumDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct EnumDescriptorProtoOwnedView(
::buffa::OwnedView<EnumDescriptorProtoView<'static>>,
);
impl EnumDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumDescriptorProtoOwnedView(::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(
EnumDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::EnumDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &EnumDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::EnumDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn value(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::EnumValueDescriptorProtoView<'_>,
> {
&self.0.reborrow().value
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::EnumOptionsView<'_>> {
&self.0.reborrow().options
}
#[must_use]
pub fn reserved_range(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::enum_descriptor_proto::EnumReservedRangeView<'_>,
> {
&self.0.reborrow().reserved_range
}
#[must_use]
pub fn reserved_name(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().reserved_name
}
#[must_use]
pub fn visibility(&self) -> ::core::option::Option<super::super::SymbolVisibility> {
self.0.reborrow().visibility
}
}
impl ::core::convert::From<::buffa::OwnedView<EnumDescriptorProtoView<'static>>>
for EnumDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<EnumDescriptorProtoView<'static>>) -> Self {
EnumDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<EnumDescriptorProtoOwnedView>
for ::buffa::OwnedView<EnumDescriptorProtoView<'static>> {
fn from(wrapper: EnumDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<EnumDescriptorProtoView<'static>>>
for EnumDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<EnumDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::EnumDescriptorProto {
type View<'a> = EnumDescriptorProtoView<'a>;
type ViewHandle = EnumDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for EnumDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod enum_descriptor_proto {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct EnumReservedRangeView<'a> {
pub start: ::core::option::Option<i32>,
pub end: ::core::option::Option<i32>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for EnumReservedRangeView<'a> {
type Owned = super::super::super::enum_descriptor_proto::EnumReservedRange;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.start = Some(::buffa::types::decode_int32(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.end = Some(::buffa::types::decode_int32(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::enum_descriptor_proto::EnumReservedRange,
::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::super::enum_descriptor_proto::EnumReservedRange,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::enum_descriptor_proto::EnumReservedRange {
start: self.start,
end: self.end,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for EnumReservedRangeView<'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 = 0u32;
if let Some(v) = self.start {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(v) = self.end {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.start {
::buffa::types::put_int32_field(1u32, v, buf);
}
if let Some(v) = self.end {
::buffa::types::put_int32_field(2u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for EnumReservedRangeView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.start {
__map.serialize_entry("start", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.end {
__map.serialize_entry("end", &::buffa::json_helpers::ProtoJson(&__v))?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for EnumReservedRangeView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "EnumDescriptorProto.EnumReservedRange";
const FULL_NAME: &'static str = "google.protobuf.EnumDescriptorProto.EnumReservedRange";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.EnumDescriptorProto.EnumReservedRange";
}
::buffa::impl_default_view_instance!(EnumReservedRangeView);
::buffa::impl_view_reborrow!(EnumReservedRangeView);
#[derive(Clone, Debug)]
pub struct EnumReservedRangeOwnedView(
::buffa::OwnedView<EnumReservedRangeView<'static>>,
);
impl EnumReservedRangeOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumReservedRangeOwnedView(::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(
EnumReservedRangeOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::enum_descriptor_proto::EnumReservedRange,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumReservedRangeOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &EnumReservedRangeView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::enum_descriptor_proto::EnumReservedRange,
::buffa::DecodeError,
> {
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 start(&self) -> ::core::option::Option<i32> {
self.0.reborrow().start
}
#[must_use]
pub fn end(&self) -> ::core::option::Option<i32> {
self.0.reborrow().end
}
}
impl ::core::convert::From<::buffa::OwnedView<EnumReservedRangeView<'static>>>
for EnumReservedRangeOwnedView {
fn from(inner: ::buffa::OwnedView<EnumReservedRangeView<'static>>) -> Self {
EnumReservedRangeOwnedView(inner)
}
}
impl ::core::convert::From<EnumReservedRangeOwnedView>
for ::buffa::OwnedView<EnumReservedRangeView<'static>> {
fn from(wrapper: EnumReservedRangeOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<EnumReservedRangeView<'static>>>
for EnumReservedRangeOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<EnumReservedRangeView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::enum_descriptor_proto::EnumReservedRange {
type View<'a> = EnumReservedRangeView<'a>;
type ViewHandle = EnumReservedRangeOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for EnumReservedRangeOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct EnumValueDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub number: ::core::option::Option<i32>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::EnumValueOptionsView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for EnumValueDescriptorProtoView<'a> {
type Owned = super::super::EnumValueDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.number = Some(::buffa::types::decode_int32(&mut cur)?);
}
3u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::EnumValueOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::EnumValueDescriptorProto,
::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::EnumValueDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::EnumValueDescriptorProto {
name: self.name.map(|s| s.to_string()),
number: self.number,
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::EnumValueOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for EnumValueDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(v) = self.number {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
if let Some(v) = self.number {
::buffa::types::put_int32_field(2u32, v, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(3u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for EnumValueDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if let ::core::option::Option::Some(__v) = self.number {
__map.serialize_entry("number", &::buffa::json_helpers::ProtoJson(&__v))?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for EnumValueDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "EnumValueDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.EnumValueDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.EnumValueDescriptorProto";
}
::buffa::impl_default_view_instance!(EnumValueDescriptorProtoView);
::buffa::impl_view_reborrow!(EnumValueDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct EnumValueDescriptorProtoOwnedView(
::buffa::OwnedView<EnumValueDescriptorProtoView<'static>>,
);
impl EnumValueDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumValueDescriptorProtoOwnedView(::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(
EnumValueDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::EnumValueDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumValueDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &EnumValueDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::EnumValueDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn number(&self) -> ::core::option::Option<i32> {
self.0.reborrow().number
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::EnumValueOptionsView<'_>,
> {
&self.0.reborrow().options
}
}
impl ::core::convert::From<::buffa::OwnedView<EnumValueDescriptorProtoView<'static>>>
for EnumValueDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<EnumValueDescriptorProtoView<'static>>) -> Self {
EnumValueDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<EnumValueDescriptorProtoOwnedView>
for ::buffa::OwnedView<EnumValueDescriptorProtoView<'static>> {
fn from(wrapper: EnumValueDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<EnumValueDescriptorProtoView<'static>>>
for EnumValueDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<EnumValueDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::EnumValueDescriptorProto {
type View<'a> = EnumValueDescriptorProtoView<'a>;
type ViewHandle = EnumValueDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for EnumValueDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct ServiceDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub method: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::MethodDescriptorProtoView<'a>,
>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::ServiceOptionsView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for ServiceDescriptorProtoView<'a> {
type Owned = super::super::ServiceDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
3u32 => {
::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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::ServiceOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.method
.push(
<super::super::__buffa::view::MethodDescriptorProtoView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::ServiceDescriptorProto,
::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::ServiceDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::ServiceDescriptorProto {
name: self.name.map(|s| s.to_string()),
method: self
.method
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::ServiceOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ServiceDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.method {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
for v in &self.method {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(3u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for ServiceDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if !self.method.is_empty() {
__map.serialize_entry("method", &*self.method)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for ServiceDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "ServiceDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.ServiceDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ServiceDescriptorProto";
}
::buffa::impl_default_view_instance!(ServiceDescriptorProtoView);
::buffa::impl_view_reborrow!(ServiceDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct ServiceDescriptorProtoOwnedView(
::buffa::OwnedView<ServiceDescriptorProtoView<'static>>,
);
impl ServiceDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ServiceDescriptorProtoOwnedView(::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(
ServiceDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::ServiceDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ServiceDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &ServiceDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::ServiceDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn method(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::MethodDescriptorProtoView<'_>,
> {
&self.0.reborrow().method
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::ServiceOptionsView<'_>,
> {
&self.0.reborrow().options
}
}
impl ::core::convert::From<::buffa::OwnedView<ServiceDescriptorProtoView<'static>>>
for ServiceDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<ServiceDescriptorProtoView<'static>>) -> Self {
ServiceDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<ServiceDescriptorProtoOwnedView>
for ::buffa::OwnedView<ServiceDescriptorProtoView<'static>> {
fn from(wrapper: ServiceDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ServiceDescriptorProtoView<'static>>>
for ServiceDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ServiceDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::ServiceDescriptorProto {
type View<'a> = ServiceDescriptorProtoView<'a>;
type ViewHandle = ServiceDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for ServiceDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct MethodDescriptorProtoView<'a> {
pub name: ::core::option::Option<&'a str>,
pub input_type: ::core::option::Option<&'a str>,
pub output_type: ::core::option::Option<&'a str>,
pub options: ::buffa::MessageFieldView<
super::super::__buffa::view::MethodOptionsView<'a>,
>,
pub client_streaming: ::core::option::Option<bool>,
pub server_streaming: ::core::option::Option<bool>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for MethodDescriptorProtoView<'a> {
type Owned = super::super::MethodDescriptorProto;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name = Some(::buffa::types::borrow_str(&mut cur)?);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.input_type = Some(::buffa::types::borrow_str(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.output_type = Some(::buffa::types::borrow_str(&mut cur)?);
}
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.options.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.options = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::MethodOptionsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.client_streaming = Some(::buffa::types::decode_bool(&mut cur)?);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.server_streaming = Some(::buffa::types::decode_bool(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::MethodDescriptorProto,
::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::MethodDescriptorProto,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::MethodDescriptorProto {
name: self.name.map(|s| s.to_string()),
input_type: self.input_type.map(|s| s.to_string()),
output_type: self.output_type.map(|s| s.to_string()),
options: match self.options.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::MethodOptions,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
client_streaming: self.client_streaming,
server_streaming: self.server_streaming,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for MethodDescriptorProtoView<'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 = 0u32;
if let Some(ref v) = self.name {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.input_type {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.output_type {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.options.is_set() {
let __slot = __cache.reserve();
let inner_size = self.options.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.client_streaming.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.server_streaming.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.name {
::buffa::types::put_string_field(1u32, v, buf);
}
if let Some(ref v) = self.input_type {
::buffa::types::put_string_field(2u32, v, buf);
}
if let Some(ref v) = self.output_type {
::buffa::types::put_string_field(3u32, v, buf);
}
if self.options.is_set() {
::buffa::types::put_len_delimited_header(4u32, __cache.consume_next(), buf);
self.options.write_to(__cache, buf);
}
if let Some(v) = self.client_streaming {
::buffa::types::put_bool_field(5u32, v, buf);
}
if let Some(v) = self.server_streaming {
::buffa::types::put_bool_field(6u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for MethodDescriptorProtoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.name {
__map.serialize_entry("name", __v)?;
}
if let ::core::option::Option::Some(__v) = self.input_type {
__map.serialize_entry("inputType", __v)?;
}
if let ::core::option::Option::Some(__v) = self.output_type {
__map.serialize_entry("outputType", __v)?;
}
{
if let ::core::option::Option::Some(__v) = self.options.as_option() {
__map.serialize_entry("options", __v)?;
}
}
if let ::core::option::Option::Some(__v) = self.client_streaming {
__map.serialize_entry("clientStreaming", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.server_streaming {
__map.serialize_entry("serverStreaming", &__v)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for MethodDescriptorProtoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "MethodDescriptorProto";
const FULL_NAME: &'static str = "google.protobuf.MethodDescriptorProto";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.MethodDescriptorProto";
}
::buffa::impl_default_view_instance!(MethodDescriptorProtoView);
::buffa::impl_view_reborrow!(MethodDescriptorProtoView);
#[derive(Clone, Debug)]
pub struct MethodDescriptorProtoOwnedView(
::buffa::OwnedView<MethodDescriptorProtoView<'static>>,
);
impl MethodDescriptorProtoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
MethodDescriptorProtoOwnedView(::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(
MethodDescriptorProtoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::MethodDescriptorProto,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
MethodDescriptorProtoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &MethodDescriptorProtoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::MethodDescriptorProto,
::buffa::DecodeError,
> {
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 name(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().name
}
#[must_use]
pub fn input_type(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().input_type
}
#[must_use]
pub fn output_type(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().output_type
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::MethodOptionsView<'_>> {
&self.0.reborrow().options
}
#[must_use]
pub fn client_streaming(&self) -> ::core::option::Option<bool> {
self.0.reborrow().client_streaming
}
#[must_use]
pub fn server_streaming(&self) -> ::core::option::Option<bool> {
self.0.reborrow().server_streaming
}
}
impl ::core::convert::From<::buffa::OwnedView<MethodDescriptorProtoView<'static>>>
for MethodDescriptorProtoOwnedView {
fn from(inner: ::buffa::OwnedView<MethodDescriptorProtoView<'static>>) -> Self {
MethodDescriptorProtoOwnedView(inner)
}
}
impl ::core::convert::From<MethodDescriptorProtoOwnedView>
for ::buffa::OwnedView<MethodDescriptorProtoView<'static>> {
fn from(wrapper: MethodDescriptorProtoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<MethodDescriptorProtoView<'static>>>
for MethodDescriptorProtoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<MethodDescriptorProtoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::MethodDescriptorProto {
type View<'a> = MethodDescriptorProtoView<'a>;
type ViewHandle = MethodDescriptorProtoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for MethodDescriptorProtoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct FileOptionsView<'a> {
pub java_package: ::core::option::Option<&'a str>,
pub java_outer_classname: ::core::option::Option<&'a str>,
pub java_multiple_files: ::core::option::Option<bool>,
pub java_generate_equals_and_hash: ::core::option::Option<bool>,
pub java_string_check_utf8: ::core::option::Option<bool>,
pub optimize_for: ::core::option::Option<super::super::file_options::OptimizeMode>,
pub go_package: ::core::option::Option<&'a str>,
pub cc_generic_services: ::core::option::Option<bool>,
pub java_generic_services: ::core::option::Option<bool>,
pub py_generic_services: ::core::option::Option<bool>,
pub deprecated: ::core::option::Option<bool>,
pub cc_enable_arenas: ::core::option::Option<bool>,
pub objc_class_prefix: ::core::option::Option<&'a str>,
pub csharp_namespace: ::core::option::Option<&'a str>,
pub swift_prefix: ::core::option::Option<&'a str>,
pub php_class_prefix: ::core::option::Option<&'a str>,
pub php_namespace: ::core::option::Option<&'a str>,
pub php_metadata_namespace: ::core::option::Option<&'a str>,
pub ruby_package: ::core::option::Option<&'a str>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FileOptionsView<'a> {
type Owned = super::super::FileOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.java_package = Some(::buffa::types::borrow_str(&mut cur)?);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.java_outer_classname = Some(::buffa::types::borrow_str(&mut cur)?);
}
10u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.java_multiple_files = Some(::buffa::types::decode_bool(&mut cur)?);
}
20u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.java_generate_equals_and_hash = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
27u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.java_string_check_utf8 = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
9u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.optimize_for = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
11u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.go_package = Some(::buffa::types::borrow_str(&mut cur)?);
}
16u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.cc_generic_services = Some(::buffa::types::decode_bool(&mut cur)?);
}
17u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.java_generic_services = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
18u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.py_generic_services = Some(::buffa::types::decode_bool(&mut cur)?);
}
23u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated = Some(::buffa::types::decode_bool(&mut cur)?);
}
31u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.cc_enable_arenas = Some(::buffa::types::decode_bool(&mut cur)?);
}
36u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.objc_class_prefix = Some(::buffa::types::borrow_str(&mut cur)?);
}
37u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.csharp_namespace = Some(::buffa::types::borrow_str(&mut cur)?);
}
39u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.swift_prefix = Some(::buffa::types::borrow_str(&mut cur)?);
}
40u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.php_class_prefix = Some(::buffa::types::borrow_str(&mut cur)?);
}
41u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.php_namespace = Some(::buffa::types::borrow_str(&mut cur)?);
}
44u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.php_metadata_namespace = Some(
::buffa::types::borrow_str(&mut cur)?,
);
}
45u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.ruby_package = Some(::buffa::types::borrow_str(&mut cur)?);
}
50u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FileOptions, ::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::FileOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FileOptions {
java_package: self.java_package.map(|s| s.to_string()),
java_outer_classname: self.java_outer_classname.map(|s| s.to_string()),
java_multiple_files: self.java_multiple_files,
java_generate_equals_and_hash: self.java_generate_equals_and_hash,
java_string_check_utf8: self.java_string_check_utf8,
optimize_for: self.optimize_for,
go_package: self.go_package.map(|s| s.to_string()),
cc_generic_services: self.cc_generic_services,
java_generic_services: self.java_generic_services,
py_generic_services: self.py_generic_services,
deprecated: self.deprecated,
cc_enable_arenas: self.cc_enable_arenas,
objc_class_prefix: self.objc_class_prefix.map(|s| s.to_string()),
csharp_namespace: self.csharp_namespace.map(|s| s.to_string()),
swift_prefix: self.swift_prefix.map(|s| s.to_string()),
php_class_prefix: self.php_class_prefix.map(|s| s.to_string()),
php_namespace: self.php_namespace.map(|s| s.to_string()),
php_metadata_namespace: self.php_metadata_namespace.map(|s| s.to_string()),
ruby_package: self.ruby_package.map(|s| s.to_string()),
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FileOptionsView<'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 = 0u32;
if let Some(ref v) = self.java_package {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.java_outer_classname {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.optimize_for {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if self.java_multiple_files.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if let Some(ref v) = self.go_package {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.cc_generic_services.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.java_generic_services.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.py_generic_services.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.java_generate_equals_and_hash.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.deprecated.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.java_string_check_utf8.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.cc_enable_arenas.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if let Some(ref v) = self.objc_class_prefix {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.csharp_namespace {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.swift_prefix {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.php_class_prefix {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.php_namespace {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.php_metadata_namespace {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.ruby_package {
size += 2u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.java_package {
::buffa::types::put_string_field(1u32, v, buf);
}
if let Some(ref v) = self.java_outer_classname {
::buffa::types::put_string_field(8u32, v, buf);
}
if let Some(ref v) = self.optimize_for {
::buffa::types::put_int32_field(9u32, v.to_i32(), buf);
}
if let Some(v) = self.java_multiple_files {
::buffa::types::put_bool_field(10u32, v, buf);
}
if let Some(ref v) = self.go_package {
::buffa::types::put_string_field(11u32, v, buf);
}
if let Some(v) = self.cc_generic_services {
::buffa::types::put_bool_field(16u32, v, buf);
}
if let Some(v) = self.java_generic_services {
::buffa::types::put_bool_field(17u32, v, buf);
}
if let Some(v) = self.py_generic_services {
::buffa::types::put_bool_field(18u32, v, buf);
}
if let Some(v) = self.java_generate_equals_and_hash {
::buffa::types::put_bool_field(20u32, v, buf);
}
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(23u32, v, buf);
}
if let Some(v) = self.java_string_check_utf8 {
::buffa::types::put_bool_field(27u32, v, buf);
}
if let Some(v) = self.cc_enable_arenas {
::buffa::types::put_bool_field(31u32, v, buf);
}
if let Some(ref v) = self.objc_class_prefix {
::buffa::types::put_string_field(36u32, v, buf);
}
if let Some(ref v) = self.csharp_namespace {
::buffa::types::put_string_field(37u32, v, buf);
}
if let Some(ref v) = self.swift_prefix {
::buffa::types::put_string_field(39u32, v, buf);
}
if let Some(ref v) = self.php_class_prefix {
::buffa::types::put_string_field(40u32, v, buf);
}
if let Some(ref v) = self.php_namespace {
::buffa::types::put_string_field(41u32, v, buf);
}
if let Some(ref v) = self.php_metadata_namespace {
::buffa::types::put_string_field(44u32, v, buf);
}
if let Some(ref v) = self.ruby_package {
::buffa::types::put_string_field(45u32, v, buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(50u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FileOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.java_package {
__map.serialize_entry("javaPackage", __v)?;
}
if let ::core::option::Option::Some(__v) = self.java_outer_classname {
__map.serialize_entry("javaOuterClassname", __v)?;
}
if let ::core::option::Option::Some(__v) = self.java_multiple_files {
__map.serialize_entry("javaMultipleFiles", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.java_generate_equals_and_hash {
__map.serialize_entry("javaGenerateEqualsAndHash", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.java_string_check_utf8 {
__map.serialize_entry("javaStringCheckUtf8", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.optimize_for {
__map
.serialize_entry(
"optimizeFor",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.go_package {
__map.serialize_entry("goPackage", __v)?;
}
if let ::core::option::Option::Some(__v) = self.cc_generic_services {
__map.serialize_entry("ccGenericServices", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.java_generic_services {
__map.serialize_entry("javaGenericServices", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.py_generic_services {
__map.serialize_entry("pyGenericServices", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.cc_enable_arenas {
__map.serialize_entry("ccEnableArenas", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.objc_class_prefix {
__map.serialize_entry("objcClassPrefix", __v)?;
}
if let ::core::option::Option::Some(__v) = self.csharp_namespace {
__map.serialize_entry("csharpNamespace", __v)?;
}
if let ::core::option::Option::Some(__v) = self.swift_prefix {
__map.serialize_entry("swiftPrefix", __v)?;
}
if let ::core::option::Option::Some(__v) = self.php_class_prefix {
__map.serialize_entry("phpClassPrefix", __v)?;
}
if let ::core::option::Option::Some(__v) = self.php_namespace {
__map.serialize_entry("phpNamespace", __v)?;
}
if let ::core::option::Option::Some(__v) = self.php_metadata_namespace {
__map.serialize_entry("phpMetadataNamespace", __v)?;
}
if let ::core::option::Option::Some(__v) = self.ruby_package {
__map.serialize_entry("rubyPackage", __v)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FileOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FileOptions";
const FULL_NAME: &'static str = "google.protobuf.FileOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FileOptions";
}
::buffa::impl_default_view_instance!(FileOptionsView);
::buffa::impl_view_reborrow!(FileOptionsView);
#[derive(Clone, Debug)]
pub struct FileOptionsOwnedView(::buffa::OwnedView<FileOptionsView<'static>>);
impl FileOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FileOptionsOwnedView(::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(
FileOptionsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::FileOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FileOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FileOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FileOptions, ::buffa::DecodeError> {
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 java_package(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().java_package
}
#[must_use]
pub fn java_outer_classname(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().java_outer_classname
}
#[must_use]
pub fn java_multiple_files(&self) -> ::core::option::Option<bool> {
self.0.reborrow().java_multiple_files
}
#[must_use]
pub fn java_generate_equals_and_hash(&self) -> ::core::option::Option<bool> {
self.0.reborrow().java_generate_equals_and_hash
}
#[must_use]
pub fn java_string_check_utf8(&self) -> ::core::option::Option<bool> {
self.0.reborrow().java_string_check_utf8
}
#[must_use]
pub fn optimize_for(
&self,
) -> ::core::option::Option<super::super::file_options::OptimizeMode> {
self.0.reborrow().optimize_for
}
#[must_use]
pub fn go_package(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().go_package
}
#[must_use]
pub fn cc_generic_services(&self) -> ::core::option::Option<bool> {
self.0.reborrow().cc_generic_services
}
#[must_use]
pub fn java_generic_services(&self) -> ::core::option::Option<bool> {
self.0.reborrow().java_generic_services
}
#[must_use]
pub fn py_generic_services(&self) -> ::core::option::Option<bool> {
self.0.reborrow().py_generic_services
}
#[must_use]
pub fn deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn cc_enable_arenas(&self) -> ::core::option::Option<bool> {
self.0.reborrow().cc_enable_arenas
}
#[must_use]
pub fn objc_class_prefix(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().objc_class_prefix
}
#[must_use]
pub fn csharp_namespace(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().csharp_namespace
}
#[must_use]
pub fn swift_prefix(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().swift_prefix
}
#[must_use]
pub fn php_class_prefix(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().php_class_prefix
}
#[must_use]
pub fn php_namespace(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().php_namespace
}
#[must_use]
pub fn php_metadata_namespace(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().php_metadata_namespace
}
#[must_use]
pub fn ruby_package(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().ruby_package
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<FileOptionsView<'static>>>
for FileOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<FileOptionsView<'static>>) -> Self {
FileOptionsOwnedView(inner)
}
}
impl ::core::convert::From<FileOptionsOwnedView>
for ::buffa::OwnedView<FileOptionsView<'static>> {
fn from(wrapper: FileOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FileOptionsView<'static>>>
for FileOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FileOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FileOptions {
type View<'a> = FileOptionsView<'a>;
type ViewHandle = FileOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FileOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct MessageOptionsView<'a> {
pub message_set_wire_format: ::core::option::Option<bool>,
pub no_standard_descriptor_accessor: ::core::option::Option<bool>,
pub deprecated: ::core::option::Option<bool>,
pub map_entry: ::core::option::Option<bool>,
pub deprecated_legacy_json_field_conflicts: ::core::option::Option<bool>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for MessageOptionsView<'a> {
type Owned = super::super::MessageOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.message_set_wire_format = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.no_standard_descriptor_accessor = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated = Some(::buffa::types::decode_bool(&mut cur)?);
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.map_entry = Some(::buffa::types::decode_bool(&mut cur)?);
}
11u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated_legacy_json_field_conflicts = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
12u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::MessageOptions, ::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::MessageOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::MessageOptions {
message_set_wire_format: self.message_set_wire_format,
no_standard_descriptor_accessor: self.no_standard_descriptor_accessor,
deprecated: self.deprecated,
map_entry: self.map_entry,
deprecated_legacy_json_field_conflicts: self
.deprecated_legacy_json_field_conflicts,
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for MessageOptionsView<'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 = 0u32;
if self.message_set_wire_format.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.no_standard_descriptor_accessor.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.deprecated.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.map_entry.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.deprecated_legacy_json_field_conflicts.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.message_set_wire_format {
::buffa::types::put_bool_field(1u32, v, buf);
}
if let Some(v) = self.no_standard_descriptor_accessor {
::buffa::types::put_bool_field(2u32, v, buf);
}
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(3u32, v, buf);
}
if let Some(v) = self.map_entry {
::buffa::types::put_bool_field(7u32, v, buf);
}
if let Some(v) = self.deprecated_legacy_json_field_conflicts {
::buffa::types::put_bool_field(11u32, v, buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(12u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for MessageOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.message_set_wire_format {
__map.serialize_entry("messageSetWireFormat", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.no_standard_descriptor_accessor {
__map.serialize_entry("noStandardDescriptorAccessor", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.map_entry {
__map.serialize_entry("mapEntry", &__v)?;
}
if let ::core::option::Option::Some(__v) = self
.deprecated_legacy_json_field_conflicts
{
__map.serialize_entry("deprecatedLegacyJsonFieldConflicts", &__v)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for MessageOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "MessageOptions";
const FULL_NAME: &'static str = "google.protobuf.MessageOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.MessageOptions";
}
::buffa::impl_default_view_instance!(MessageOptionsView);
::buffa::impl_view_reborrow!(MessageOptionsView);
#[derive(Clone, Debug)]
pub struct MessageOptionsOwnedView(::buffa::OwnedView<MessageOptionsView<'static>>);
impl MessageOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
MessageOptionsOwnedView(::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(
MessageOptionsOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::MessageOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
MessageOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &MessageOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::MessageOptions, ::buffa::DecodeError> {
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 message_set_wire_format(&self) -> ::core::option::Option<bool> {
self.0.reborrow().message_set_wire_format
}
#[must_use]
pub fn no_standard_descriptor_accessor(&self) -> ::core::option::Option<bool> {
self.0.reborrow().no_standard_descriptor_accessor
}
#[must_use]
pub fn deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn map_entry(&self) -> ::core::option::Option<bool> {
self.0.reborrow().map_entry
}
#[must_use]
pub fn deprecated_legacy_json_field_conflicts(
&self,
) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated_legacy_json_field_conflicts
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<MessageOptionsView<'static>>>
for MessageOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<MessageOptionsView<'static>>) -> Self {
MessageOptionsOwnedView(inner)
}
}
impl ::core::convert::From<MessageOptionsOwnedView>
for ::buffa::OwnedView<MessageOptionsView<'static>> {
fn from(wrapper: MessageOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<MessageOptionsView<'static>>>
for MessageOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<MessageOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::MessageOptions {
type View<'a> = MessageOptionsView<'a>;
type ViewHandle = MessageOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for MessageOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct FieldOptionsView<'a> {
pub ctype: ::core::option::Option<super::super::field_options::CType>,
pub packed: ::core::option::Option<bool>,
pub jstype: ::core::option::Option<super::super::field_options::JSType>,
pub lazy: ::core::option::Option<bool>,
pub unverified_lazy: ::core::option::Option<bool>,
pub deprecated: ::core::option::Option<bool>,
pub weak: ::core::option::Option<bool>,
pub debug_redact: ::core::option::Option<bool>,
pub retention: ::core::option::Option<super::super::field_options::OptionRetention>,
pub targets: ::buffa::RepeatedView<
'a,
super::super::field_options::OptionTargetType,
>,
pub edition_defaults: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::field_options::EditionDefaultView<'a>,
>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub feature_support: ::buffa::MessageFieldView<
super::super::__buffa::view::field_options::FeatureSupportView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FieldOptionsView<'a> {
type Owned = super::super::FieldOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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,
)?;
let __raw = ::buffa::types::decode_int32(&mut cur)?;
if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
__raw,
) {
view.ctype = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.packed = Some(::buffa::types::decode_bool(&mut cur)?);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.jstype = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.lazy = Some(::buffa::types::decode_bool(&mut cur)?);
}
15u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.unverified_lazy = Some(::buffa::types::decode_bool(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated = Some(::buffa::types::decode_bool(&mut cur)?);
}
10u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.weak = Some(::buffa::types::decode_bool(&mut cur)?);
}
16u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.debug_redact = Some(::buffa::types::decode_bool(&mut cur)?);
}
17u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.retention = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
21u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
22u32 => {
::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.feature_support.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.feature_support = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::field_options::FeatureSupportView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
19u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
view.targets.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.targets.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.targets.push(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
20u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.edition_defaults
.push(
<super::super::__buffa::view::field_options::EditionDefaultView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FieldOptions, ::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::FieldOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FieldOptions {
ctype: self.ctype,
packed: self.packed,
jstype: self.jstype,
lazy: self.lazy,
unverified_lazy: self.unverified_lazy,
deprecated: self.deprecated,
weak: self.weak,
debug_redact: self.debug_redact,
retention: self.retention,
targets: self.targets.to_vec(),
edition_defaults: self
.edition_defaults
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
feature_support: match self.feature_support.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::field_options::FeatureSupport,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FieldOptionsView<'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 = 0u32;
if let Some(ref v) = self.ctype {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if self.packed.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.deprecated.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.lazy.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if let Some(ref v) = self.jstype {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if self.weak.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.unverified_lazy.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.debug_redact.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if let Some(ref v) = self.retention {
size += 2u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
for v in &self.targets {
size += 2u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
for v in &self.edition_defaults {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.feature_support.is_set() {
let __slot = __cache.reserve();
let inner_size = self.feature_support.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.ctype {
::buffa::types::put_int32_field(1u32, v.to_i32(), buf);
}
if let Some(v) = self.packed {
::buffa::types::put_bool_field(2u32, v, buf);
}
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(3u32, v, buf);
}
if let Some(v) = self.lazy {
::buffa::types::put_bool_field(5u32, v, buf);
}
if let Some(ref v) = self.jstype {
::buffa::types::put_int32_field(6u32, v.to_i32(), buf);
}
if let Some(v) = self.weak {
::buffa::types::put_bool_field(10u32, v, buf);
}
if let Some(v) = self.unverified_lazy {
::buffa::types::put_bool_field(15u32, v, buf);
}
if let Some(v) = self.debug_redact {
::buffa::types::put_bool_field(16u32, v, buf);
}
if let Some(ref v) = self.retention {
::buffa::types::put_int32_field(17u32, v.to_i32(), buf);
}
for v in &self.targets {
::buffa::types::put_int32_field(19u32, v.to_i32(), buf);
}
for v in &self.edition_defaults {
::buffa::types::put_len_delimited_header(20u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(21u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
if self.feature_support.is_set() {
::buffa::types::put_len_delimited_header(22u32, __cache.consume_next(), buf);
self.feature_support.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FieldOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.ctype {
__map
.serialize_entry("ctype", &::buffa::json_helpers::ClosedEnumJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.packed {
__map.serialize_entry("packed", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.jstype {
__map
.serialize_entry(
"jstype",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.lazy {
__map.serialize_entry("lazy", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.unverified_lazy {
__map.serialize_entry("unverifiedLazy", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.weak {
__map.serialize_entry("weak", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.debug_redact {
__map.serialize_entry("debugRedact", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.retention {
__map
.serialize_entry(
"retention",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if !self.targets.is_empty() {
__map
.serialize_entry(
"targets",
&::buffa::json_helpers::ClosedEnumSeqJson(&self.targets),
)?;
}
if !self.edition_defaults.is_empty() {
__map.serialize_entry("editionDefaults", &*self.edition_defaults)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
{
if let ::core::option::Option::Some(__v) = self.feature_support.as_option() {
__map.serialize_entry("featureSupport", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FieldOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FieldOptions";
const FULL_NAME: &'static str = "google.protobuf.FieldOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldOptions";
}
::buffa::impl_default_view_instance!(FieldOptionsView);
::buffa::impl_view_reborrow!(FieldOptionsView);
#[derive(Clone, Debug)]
pub struct FieldOptionsOwnedView(::buffa::OwnedView<FieldOptionsView<'static>>);
impl FieldOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FieldOptionsOwnedView(::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(
FieldOptionsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::FieldOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FieldOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FieldOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FieldOptions, ::buffa::DecodeError> {
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 ctype(&self) -> ::core::option::Option<super::super::field_options::CType> {
self.0.reborrow().ctype
}
#[must_use]
pub fn packed(&self) -> ::core::option::Option<bool> {
self.0.reborrow().packed
}
#[must_use]
pub fn jstype(&self) -> ::core::option::Option<super::super::field_options::JSType> {
self.0.reborrow().jstype
}
#[must_use]
pub fn lazy(&self) -> ::core::option::Option<bool> {
self.0.reborrow().lazy
}
#[must_use]
pub fn unverified_lazy(&self) -> ::core::option::Option<bool> {
self.0.reborrow().unverified_lazy
}
#[must_use]
pub fn deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn weak(&self) -> ::core::option::Option<bool> {
self.0.reborrow().weak
}
#[must_use]
pub fn debug_redact(&self) -> ::core::option::Option<bool> {
self.0.reborrow().debug_redact
}
#[must_use]
pub fn retention(
&self,
) -> ::core::option::Option<super::super::field_options::OptionRetention> {
self.0.reborrow().retention
}
#[must_use]
pub fn targets(
&self,
) -> &::buffa::RepeatedView<'_, super::super::field_options::OptionTargetType> {
&self.0.reborrow().targets
}
#[must_use]
pub fn edition_defaults(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::field_options::EditionDefaultView<'_>,
> {
&self.0.reborrow().edition_defaults
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn feature_support(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::field_options::FeatureSupportView<'_>,
> {
&self.0.reborrow().feature_support
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<FieldOptionsView<'static>>>
for FieldOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<FieldOptionsView<'static>>) -> Self {
FieldOptionsOwnedView(inner)
}
}
impl ::core::convert::From<FieldOptionsOwnedView>
for ::buffa::OwnedView<FieldOptionsView<'static>> {
fn from(wrapper: FieldOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FieldOptionsView<'static>>>
for FieldOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FieldOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FieldOptions {
type View<'a> = FieldOptionsView<'a>;
type ViewHandle = FieldOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FieldOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod field_options {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct EditionDefaultView<'a> {
pub edition: ::core::option::Option<super::super::super::Edition>,
pub value: ::core::option::Option<&'a str>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for EditionDefaultView<'a> {
type Owned = super::super::super::field_options::EditionDefault;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.edition = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.value = Some(::buffa::types::borrow_str(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::field_options::EditionDefault,
::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::super::field_options::EditionDefault,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::field_options::EditionDefault {
edition: self.edition,
value: self.value.map(|s| s.to_string()),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for EditionDefaultView<'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 = 0u32;
if let Some(ref v) = self.value {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.edition {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.value {
::buffa::types::put_string_field(2u32, v, buf);
}
if let Some(ref v) = self.edition {
::buffa::types::put_int32_field(3u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for EditionDefaultView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.edition {
__map
.serialize_entry(
"edition",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.value {
__map.serialize_entry("value", __v)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for EditionDefaultView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FieldOptions.EditionDefault";
const FULL_NAME: &'static str = "google.protobuf.FieldOptions.EditionDefault";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldOptions.EditionDefault";
}
::buffa::impl_default_view_instance!(EditionDefaultView);
::buffa::impl_view_reborrow!(EditionDefaultView);
#[derive(Clone, Debug)]
pub struct EditionDefaultOwnedView(::buffa::OwnedView<EditionDefaultView<'static>>);
impl EditionDefaultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EditionDefaultOwnedView(::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(
EditionDefaultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::field_options::EditionDefault,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EditionDefaultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &EditionDefaultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::field_options::EditionDefault,
::buffa::DecodeError,
> {
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 edition(&self) -> ::core::option::Option<super::super::super::Edition> {
self.0.reborrow().edition
}
#[must_use]
pub fn value(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().value
}
}
impl ::core::convert::From<::buffa::OwnedView<EditionDefaultView<'static>>>
for EditionDefaultOwnedView {
fn from(inner: ::buffa::OwnedView<EditionDefaultView<'static>>) -> Self {
EditionDefaultOwnedView(inner)
}
}
impl ::core::convert::From<EditionDefaultOwnedView>
for ::buffa::OwnedView<EditionDefaultView<'static>> {
fn from(wrapper: EditionDefaultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<EditionDefaultView<'static>>>
for EditionDefaultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<EditionDefaultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::super::field_options::EditionDefault {
type View<'a> = EditionDefaultView<'a>;
type ViewHandle = EditionDefaultOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for EditionDefaultOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct FeatureSupportView<'a> {
pub edition_introduced: ::core::option::Option<super::super::super::Edition>,
pub edition_deprecated: ::core::option::Option<super::super::super::Edition>,
pub deprecation_warning: ::core::option::Option<&'a str>,
pub edition_removed: ::core::option::Option<super::super::super::Edition>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FeatureSupportView<'a> {
type Owned = super::super::super::field_options::FeatureSupport;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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,
)?;
let __raw = ::buffa::types::decode_int32(&mut cur)?;
if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
__raw,
) {
view.edition_introduced = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.edition_deprecated = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.deprecation_warning = Some(
::buffa::types::borrow_str(&mut cur)?,
);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.edition_removed = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::field_options::FeatureSupport,
::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::super::field_options::FeatureSupport,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::field_options::FeatureSupport {
edition_introduced: self.edition_introduced,
edition_deprecated: self.edition_deprecated,
deprecation_warning: self.deprecation_warning.map(|s| s.to_string()),
edition_removed: self.edition_removed,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FeatureSupportView<'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 = 0u32;
if let Some(ref v) = self.edition_introduced {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.edition_deprecated {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.deprecation_warning {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.edition_removed {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.edition_introduced {
::buffa::types::put_int32_field(1u32, v.to_i32(), buf);
}
if let Some(ref v) = self.edition_deprecated {
::buffa::types::put_int32_field(2u32, v.to_i32(), buf);
}
if let Some(ref v) = self.deprecation_warning {
::buffa::types::put_string_field(3u32, v, buf);
}
if let Some(ref v) = self.edition_removed {
::buffa::types::put_int32_field(4u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FeatureSupportView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.edition_introduced {
__map
.serialize_entry(
"editionIntroduced",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.edition_deprecated {
__map
.serialize_entry(
"editionDeprecated",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.deprecation_warning {
__map.serialize_entry("deprecationWarning", __v)?;
}
if let ::core::option::Option::Some(__v) = self.edition_removed {
__map
.serialize_entry(
"editionRemoved",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FeatureSupportView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FieldOptions.FeatureSupport";
const FULL_NAME: &'static str = "google.protobuf.FieldOptions.FeatureSupport";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldOptions.FeatureSupport";
}
::buffa::impl_default_view_instance!(FeatureSupportView);
::buffa::impl_view_reborrow!(FeatureSupportView);
#[derive(Clone, Debug)]
pub struct FeatureSupportOwnedView(::buffa::OwnedView<FeatureSupportView<'static>>);
impl FeatureSupportOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSupportOwnedView(::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(
FeatureSupportOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::field_options::FeatureSupport,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSupportOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FeatureSupportView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::field_options::FeatureSupport,
::buffa::DecodeError,
> {
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 edition_introduced(
&self,
) -> ::core::option::Option<super::super::super::Edition> {
self.0.reborrow().edition_introduced
}
#[must_use]
pub fn edition_deprecated(
&self,
) -> ::core::option::Option<super::super::super::Edition> {
self.0.reborrow().edition_deprecated
}
#[must_use]
pub fn deprecation_warning(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().deprecation_warning
}
#[must_use]
pub fn edition_removed(
&self,
) -> ::core::option::Option<super::super::super::Edition> {
self.0.reborrow().edition_removed
}
}
impl ::core::convert::From<::buffa::OwnedView<FeatureSupportView<'static>>>
for FeatureSupportOwnedView {
fn from(inner: ::buffa::OwnedView<FeatureSupportView<'static>>) -> Self {
FeatureSupportOwnedView(inner)
}
}
impl ::core::convert::From<FeatureSupportOwnedView>
for ::buffa::OwnedView<FeatureSupportView<'static>> {
fn from(wrapper: FeatureSupportOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FeatureSupportView<'static>>>
for FeatureSupportOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FeatureSupportView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::super::field_options::FeatureSupport {
type View<'a> = FeatureSupportView<'a>;
type ViewHandle = FeatureSupportOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FeatureSupportOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct OneofOptionsView<'a> {
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for OneofOptionsView<'a> {
type Owned = super::super::OneofOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::OneofOptions, ::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::OneofOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::OneofOptions {
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for OneofOptionsView<'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 = 0u32;
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if self.features.is_set() {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for OneofOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for OneofOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "OneofOptions";
const FULL_NAME: &'static str = "google.protobuf.OneofOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.OneofOptions";
}
::buffa::impl_default_view_instance!(OneofOptionsView);
::buffa::impl_view_reborrow!(OneofOptionsView);
#[derive(Clone, Debug)]
pub struct OneofOptionsOwnedView(::buffa::OwnedView<OneofOptionsView<'static>>);
impl OneofOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
OneofOptionsOwnedView(::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(
OneofOptionsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::OneofOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
OneofOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &OneofOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::OneofOptions, ::buffa::DecodeError> {
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 features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<OneofOptionsView<'static>>>
for OneofOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<OneofOptionsView<'static>>) -> Self {
OneofOptionsOwnedView(inner)
}
}
impl ::core::convert::From<OneofOptionsOwnedView>
for ::buffa::OwnedView<OneofOptionsView<'static>> {
fn from(wrapper: OneofOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<OneofOptionsView<'static>>>
for OneofOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<OneofOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::OneofOptions {
type View<'a> = OneofOptionsView<'a>;
type ViewHandle = OneofOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for OneofOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct EnumOptionsView<'a> {
pub allow_alias: ::core::option::Option<bool>,
pub deprecated: ::core::option::Option<bool>,
pub deprecated_legacy_json_field_conflicts: ::core::option::Option<bool>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for EnumOptionsView<'a> {
type Owned = super::super::EnumOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.allow_alias = Some(::buffa::types::decode_bool(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated = Some(::buffa::types::decode_bool(&mut cur)?);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated_legacy_json_field_conflicts = Some(
::buffa::types::decode_bool(&mut cur)?,
);
}
7u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::EnumOptions, ::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::EnumOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::EnumOptions {
allow_alias: self.allow_alias,
deprecated: self.deprecated,
deprecated_legacy_json_field_conflicts: self
.deprecated_legacy_json_field_conflicts,
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for EnumOptionsView<'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 = 0u32;
if self.allow_alias.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.deprecated.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.deprecated_legacy_json_field_conflicts.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.allow_alias {
::buffa::types::put_bool_field(2u32, v, buf);
}
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(3u32, v, buf);
}
if let Some(v) = self.deprecated_legacy_json_field_conflicts {
::buffa::types::put_bool_field(6u32, v, buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(7u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for EnumOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.allow_alias {
__map.serialize_entry("allowAlias", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
if let ::core::option::Option::Some(__v) = self
.deprecated_legacy_json_field_conflicts
{
__map.serialize_entry("deprecatedLegacyJsonFieldConflicts", &__v)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for EnumOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "EnumOptions";
const FULL_NAME: &'static str = "google.protobuf.EnumOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.EnumOptions";
}
::buffa::impl_default_view_instance!(EnumOptionsView);
::buffa::impl_view_reborrow!(EnumOptionsView);
#[derive(Clone, Debug)]
pub struct EnumOptionsOwnedView(::buffa::OwnedView<EnumOptionsView<'static>>);
impl EnumOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumOptionsOwnedView(::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(
EnumOptionsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::EnumOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &EnumOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::EnumOptions, ::buffa::DecodeError> {
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 allow_alias(&self) -> ::core::option::Option<bool> {
self.0.reborrow().allow_alias
}
#[must_use]
pub fn deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn deprecated_legacy_json_field_conflicts(
&self,
) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated_legacy_json_field_conflicts
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<EnumOptionsView<'static>>>
for EnumOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<EnumOptionsView<'static>>) -> Self {
EnumOptionsOwnedView(inner)
}
}
impl ::core::convert::From<EnumOptionsOwnedView>
for ::buffa::OwnedView<EnumOptionsView<'static>> {
fn from(wrapper: EnumOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<EnumOptionsView<'static>>>
for EnumOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<EnumOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::EnumOptions {
type View<'a> = EnumOptionsView<'a>;
type ViewHandle = EnumOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for EnumOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct EnumValueOptionsView<'a> {
pub deprecated: ::core::option::Option<bool>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub debug_redact: ::core::option::Option<bool>,
pub feature_support: ::buffa::MessageFieldView<
super::super::__buffa::view::field_options::FeatureSupportView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for EnumValueOptionsView<'a> {
type Owned = super::super::EnumValueOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.deprecated = Some(::buffa::types::decode_bool(&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)?;
match view.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.debug_redact = Some(::buffa::types::decode_bool(&mut cur)?);
}
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.feature_support.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.feature_support = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::field_options::FeatureSupportView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::EnumValueOptions, ::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::EnumValueOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::EnumValueOptions {
deprecated: self.deprecated,
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
debug_redact: self.debug_redact,
feature_support: match self.feature_support.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::field_options::FeatureSupport,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for EnumValueOptionsView<'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 = 0u32;
if self.deprecated.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.debug_redact.is_some() {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.feature_support.is_set() {
let __slot = __cache.reserve();
let inner_size = self.feature_support.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(1u32, v, buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
if let Some(v) = self.debug_redact {
::buffa::types::put_bool_field(3u32, v, buf);
}
if self.feature_support.is_set() {
::buffa::types::put_len_delimited_header(4u32, __cache.consume_next(), buf);
self.feature_support.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for EnumValueOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if let ::core::option::Option::Some(__v) = self.debug_redact {
__map.serialize_entry("debugRedact", &__v)?;
}
{
if let ::core::option::Option::Some(__v) = self.feature_support.as_option() {
__map.serialize_entry("featureSupport", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for EnumValueOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "EnumValueOptions";
const FULL_NAME: &'static str = "google.protobuf.EnumValueOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.EnumValueOptions";
}
::buffa::impl_default_view_instance!(EnumValueOptionsView);
::buffa::impl_view_reborrow!(EnumValueOptionsView);
#[derive(Clone, Debug)]
pub struct EnumValueOptionsOwnedView(::buffa::OwnedView<EnumValueOptionsView<'static>>);
impl EnumValueOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumValueOptionsOwnedView(::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(
EnumValueOptionsOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::EnumValueOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
EnumValueOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &EnumValueOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::EnumValueOptions, ::buffa::DecodeError> {
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 deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn debug_redact(&self) -> ::core::option::Option<bool> {
self.0.reborrow().debug_redact
}
#[must_use]
pub fn feature_support(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::field_options::FeatureSupportView<'_>,
> {
&self.0.reborrow().feature_support
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<EnumValueOptionsView<'static>>>
for EnumValueOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<EnumValueOptionsView<'static>>) -> Self {
EnumValueOptionsOwnedView(inner)
}
}
impl ::core::convert::From<EnumValueOptionsOwnedView>
for ::buffa::OwnedView<EnumValueOptionsView<'static>> {
fn from(wrapper: EnumValueOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<EnumValueOptionsView<'static>>>
for EnumValueOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<EnumValueOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::EnumValueOptions {
type View<'a> = EnumValueOptionsView<'a>;
type ViewHandle = EnumValueOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for EnumValueOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct ServiceOptionsView<'a> {
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub deprecated: ::core::option::Option<bool>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for ServiceOptionsView<'a> {
type Owned = super::super::ServiceOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
34u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
33u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated = Some(::buffa::types::decode_bool(&mut cur)?);
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::ServiceOptions, ::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::ServiceOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::ServiceOptions {
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
deprecated: self.deprecated,
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ServiceOptionsView<'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 = 0u32;
if self.deprecated.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(33u32, v, buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(34u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for ServiceOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for ServiceOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "ServiceOptions";
const FULL_NAME: &'static str = "google.protobuf.ServiceOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ServiceOptions";
}
::buffa::impl_default_view_instance!(ServiceOptionsView);
::buffa::impl_view_reborrow!(ServiceOptionsView);
#[derive(Clone, Debug)]
pub struct ServiceOptionsOwnedView(::buffa::OwnedView<ServiceOptionsView<'static>>);
impl ServiceOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ServiceOptionsOwnedView(::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(
ServiceOptionsOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::ServiceOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
ServiceOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &ServiceOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::ServiceOptions, ::buffa::DecodeError> {
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 features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<ServiceOptionsView<'static>>>
for ServiceOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<ServiceOptionsView<'static>>) -> Self {
ServiceOptionsOwnedView(inner)
}
}
impl ::core::convert::From<ServiceOptionsOwnedView>
for ::buffa::OwnedView<ServiceOptionsView<'static>> {
fn from(wrapper: ServiceOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ServiceOptionsView<'static>>>
for ServiceOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ServiceOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::ServiceOptions {
type View<'a> = ServiceOptionsView<'a>;
type ViewHandle = ServiceOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for ServiceOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct MethodOptionsView<'a> {
pub deprecated: ::core::option::Option<bool>,
pub idempotency_level: ::core::option::Option<
super::super::method_options::IdempotencyLevel,
>,
pub features: ::buffa::MessageFieldView<
super::super::__buffa::view::FeatureSetView<'a>,
>,
pub uninterpreted_option: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::UninterpretedOptionView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for MethodOptionsView<'a> {
type Owned = super::super::MethodOptions;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
33u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.deprecated = Some(::buffa::types::decode_bool(&mut cur)?);
}
34u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.idempotency_level = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
35u32 => {
::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.features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.features = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
999u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.uninterpreted_option
.push(
<super::super::__buffa::view::UninterpretedOptionView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::MethodOptions, ::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::MethodOptions, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::MethodOptions {
deprecated: self.deprecated,
idempotency_level: self.idempotency_level,
features: match self.features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
uninterpreted_option: self
.uninterpreted_option
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for MethodOptionsView<'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 = 0u32;
if self.deprecated.is_some() {
size += 2u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if let Some(ref v) = self.idempotency_level {
size += 2u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if self.features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.uninterpreted_option {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 2u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(v) = self.deprecated {
::buffa::types::put_bool_field(33u32, v, buf);
}
if let Some(ref v) = self.idempotency_level {
::buffa::types::put_int32_field(34u32, v.to_i32(), buf);
}
if self.features.is_set() {
::buffa::types::put_len_delimited_header(35u32, __cache.consume_next(), buf);
self.features.write_to(__cache, buf);
}
for v in &self.uninterpreted_option {
::buffa::types::put_len_delimited_header(
999u32,
__cache.consume_next(),
buf,
);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for MethodOptionsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.deprecated {
__map.serialize_entry("deprecated", &__v)?;
}
if let ::core::option::Option::Some(__v) = self.idempotency_level {
__map
.serialize_entry(
"idempotencyLevel",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
{
if let ::core::option::Option::Some(__v) = self.features.as_option() {
__map.serialize_entry("features", __v)?;
}
}
if !self.uninterpreted_option.is_empty() {
__map.serialize_entry("uninterpretedOption", &*self.uninterpreted_option)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for MethodOptionsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "MethodOptions";
const FULL_NAME: &'static str = "google.protobuf.MethodOptions";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.MethodOptions";
}
::buffa::impl_default_view_instance!(MethodOptionsView);
::buffa::impl_view_reborrow!(MethodOptionsView);
#[derive(Clone, Debug)]
pub struct MethodOptionsOwnedView(::buffa::OwnedView<MethodOptionsView<'static>>);
impl MethodOptionsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
MethodOptionsOwnedView(::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(
MethodOptionsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::MethodOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
MethodOptionsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &MethodOptionsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::MethodOptions, ::buffa::DecodeError> {
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 deprecated(&self) -> ::core::option::Option<bool> {
self.0.reborrow().deprecated
}
#[must_use]
pub fn idempotency_level(
&self,
) -> ::core::option::Option<super::super::method_options::IdempotencyLevel> {
self.0.reborrow().idempotency_level
}
#[must_use]
pub fn features(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::FeatureSetView<'_>> {
&self.0.reborrow().features
}
#[must_use]
pub fn uninterpreted_option(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::UninterpretedOptionView<'_>,
> {
&self.0.reborrow().uninterpreted_option
}
}
impl ::core::convert::From<::buffa::OwnedView<MethodOptionsView<'static>>>
for MethodOptionsOwnedView {
fn from(inner: ::buffa::OwnedView<MethodOptionsView<'static>>) -> Self {
MethodOptionsOwnedView(inner)
}
}
impl ::core::convert::From<MethodOptionsOwnedView>
for ::buffa::OwnedView<MethodOptionsView<'static>> {
fn from(wrapper: MethodOptionsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<MethodOptionsView<'static>>>
for MethodOptionsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<MethodOptionsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::MethodOptions {
type View<'a> = MethodOptionsView<'a>;
type ViewHandle = MethodOptionsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for MethodOptionsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct UninterpretedOptionView<'a> {
pub name: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::uninterpreted_option::NamePartView<'a>,
>,
pub identifier_value: ::core::option::Option<&'a str>,
pub positive_int_value: ::core::option::Option<u64>,
pub negative_int_value: ::core::option::Option<i64>,
pub double_value: ::core::option::Option<f64>,
pub string_value: ::core::option::Option<&'a [u8]>,
pub aggregate_value: ::core::option::Option<&'a str>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for UninterpretedOptionView<'a> {
type Owned = super::super::UninterpretedOption;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.identifier_value = Some(::buffa::types::borrow_str(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.positive_int_value = Some(::buffa::types::decode_uint64(&mut cur)?);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.negative_int_value = Some(::buffa::types::decode_int64(&mut cur)?);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Fixed64,
)?;
view.double_value = Some(::buffa::types::decode_double(&mut cur)?);
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.string_value = Some(::buffa::types::borrow_bytes(&mut cur)?);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.aggregate_value = Some(::buffa::types::borrow_str(&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)?;
view.name
.push(
<super::super::__buffa::view::uninterpreted_option::NamePartView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::UninterpretedOption,
::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::UninterpretedOption,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::UninterpretedOption {
name: self
.name
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
identifier_value: self.identifier_value.map(|s| s.to_string()),
positive_int_value: self.positive_int_value,
negative_int_value: self.negative_int_value,
double_value: self.double_value,
string_value: self.string_value.map(|b| (b).to_vec()),
aggregate_value: self.aggregate_value.map(|s| s.to_string()),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for UninterpretedOptionView<'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 = 0u32;
for v in &self.name {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if let Some(ref v) = self.identifier_value {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(v) = self.positive_int_value {
size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
}
if let Some(v) = self.negative_int_value {
size += 1u32 + ::buffa::types::int64_encoded_len(v) as u32;
}
if self.double_value.is_some() {
size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
}
if let Some(ref v) = self.string_value {
size += 1u32 + ::buffa::types::bytes_encoded_len(v) as u32;
}
if let Some(ref v) = self.aggregate_value {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.name {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if let Some(ref v) = self.identifier_value {
::buffa::types::put_string_field(3u32, v, buf);
}
if let Some(v) = self.positive_int_value {
::buffa::types::put_uint64_field(4u32, v, buf);
}
if let Some(v) = self.negative_int_value {
::buffa::types::put_int64_field(5u32, v, buf);
}
if let Some(v) = self.double_value {
::buffa::types::put_double_field(6u32, v, buf);
}
if let Some(ref v) = self.string_value {
::buffa::types::put_bytes_field(7u32, v, buf);
}
if let Some(ref v) = self.aggregate_value {
::buffa::types::put_string_field(8u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for UninterpretedOptionView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.name.is_empty() {
__map.serialize_entry("name", &*self.name)?;
}
if let ::core::option::Option::Some(__v) = self.identifier_value {
__map.serialize_entry("identifierValue", __v)?;
}
if let ::core::option::Option::Some(__v) = self.positive_int_value {
__map
.serialize_entry(
"positiveIntValue",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.negative_int_value {
__map
.serialize_entry(
"negativeIntValue",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.double_value {
__map
.serialize_entry(
"doubleValue",
&::buffa::json_helpers::ProtoJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.string_value {
__map
.serialize_entry("stringValue", &::buffa::json_helpers::BytesJson(__v))?;
}
if let ::core::option::Option::Some(__v) = self.aggregate_value {
__map.serialize_entry("aggregateValue", __v)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for UninterpretedOptionView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "UninterpretedOption";
const FULL_NAME: &'static str = "google.protobuf.UninterpretedOption";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.UninterpretedOption";
}
::buffa::impl_default_view_instance!(UninterpretedOptionView);
::buffa::impl_view_reborrow!(UninterpretedOptionView);
#[derive(Clone, Debug)]
pub struct UninterpretedOptionOwnedView(
::buffa::OwnedView<UninterpretedOptionView<'static>>,
);
impl UninterpretedOptionOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
UninterpretedOptionOwnedView(::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(
UninterpretedOptionOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::UninterpretedOption,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
UninterpretedOptionOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &UninterpretedOptionView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::UninterpretedOption,
::buffa::DecodeError,
> {
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 name(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::uninterpreted_option::NamePartView<'_>,
> {
&self.0.reborrow().name
}
#[must_use]
pub fn identifier_value(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().identifier_value
}
#[must_use]
pub fn positive_int_value(&self) -> ::core::option::Option<u64> {
self.0.reborrow().positive_int_value
}
#[must_use]
pub fn negative_int_value(&self) -> ::core::option::Option<i64> {
self.0.reborrow().negative_int_value
}
#[must_use]
pub fn double_value(&self) -> ::core::option::Option<f64> {
self.0.reborrow().double_value
}
#[must_use]
pub fn string_value(&self) -> ::core::option::Option<&'_ [u8]> {
self.0.reborrow().string_value
}
#[must_use]
pub fn aggregate_value(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().aggregate_value
}
}
impl ::core::convert::From<::buffa::OwnedView<UninterpretedOptionView<'static>>>
for UninterpretedOptionOwnedView {
fn from(inner: ::buffa::OwnedView<UninterpretedOptionView<'static>>) -> Self {
UninterpretedOptionOwnedView(inner)
}
}
impl ::core::convert::From<UninterpretedOptionOwnedView>
for ::buffa::OwnedView<UninterpretedOptionView<'static>> {
fn from(wrapper: UninterpretedOptionOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<UninterpretedOptionView<'static>>>
for UninterpretedOptionOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<UninterpretedOptionView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::UninterpretedOption {
type View<'a> = UninterpretedOptionView<'a>;
type ViewHandle = UninterpretedOptionOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for UninterpretedOptionOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod uninterpreted_option {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct NamePartView<'a> {
pub name_part: &'a str,
pub is_extension: bool,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
#[doc(hidden)]
pub __buffa_required_seen_0: u64,
}
impl<'a> NamePartView<'a> {
#[must_use]
#[inline]
pub const fn has_name_part(&self) -> bool {
self.__buffa_required_seen_0 & 1u64 != 0
}
#[must_use]
#[inline]
pub const fn has_is_extension(&self) -> bool {
self.__buffa_required_seen_0 & 2u64 != 0
}
}
impl<'a> ::buffa::MessageView<'a> for NamePartView<'a> {
type Owned = super::super::super::uninterpreted_option::NamePart;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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.name_part = ::buffa::types::borrow_str(&mut cur)?;
view.__buffa_required_seen_0 |= 1u64;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.is_extension = ::buffa::types::decode_bool(&mut cur)?;
view.__buffa_required_seen_0 |= 2u64;
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::uninterpreted_option::NamePart,
::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::super::uninterpreted_option::NamePart,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::uninterpreted_option::NamePart {
name_part: self.name_part.to_string(),
is_extension: self.is_extension,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for NamePartView<'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 = 0u32;
size += 1u32 + ::buffa::types::string_encoded_len(&self.name_part) as u32;
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
::buffa::types::put_string_field(1u32, &self.name_part, buf);
::buffa::types::put_bool_field(2u32, self.is_extension, buf);
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for NamePartView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
{
__map.serialize_entry("namePart", self.name_part)?;
}
{
__map.serialize_entry("isExtension", &self.is_extension)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for NamePartView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "UninterpretedOption.NamePart";
const FULL_NAME: &'static str = "google.protobuf.UninterpretedOption.NamePart";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.UninterpretedOption.NamePart";
}
::buffa::impl_default_view_instance!(NamePartView);
::buffa::impl_view_reborrow!(NamePartView);
#[derive(Clone, Debug)]
pub struct NamePartOwnedView(::buffa::OwnedView<NamePartView<'static>>);
impl NamePartOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
NamePartOwnedView(::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(
NamePartOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::super::uninterpreted_option::NamePart,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
NamePartOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &NamePartView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::uninterpreted_option::NamePart,
::buffa::DecodeError,
> {
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 name_part(&self) -> &'_ str {
self.0.reborrow().name_part
}
#[must_use]
pub fn is_extension(&self) -> bool {
self.0.reborrow().is_extension
}
}
impl ::core::convert::From<::buffa::OwnedView<NamePartView<'static>>>
for NamePartOwnedView {
fn from(inner: ::buffa::OwnedView<NamePartView<'static>>) -> Self {
NamePartOwnedView(inner)
}
}
impl ::core::convert::From<NamePartOwnedView>
for ::buffa::OwnedView<NamePartView<'static>> {
fn from(wrapper: NamePartOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<NamePartView<'static>>>
for NamePartOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<NamePartView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::uninterpreted_option::NamePart {
type View<'a> = NamePartView<'a>;
type ViewHandle = NamePartOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for NamePartOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct FeatureSetView<'a> {
pub field_presence: ::core::option::Option<super::super::feature_set::FieldPresence>,
pub enum_type: ::core::option::Option<super::super::feature_set::EnumType>,
pub repeated_field_encoding: ::core::option::Option<
super::super::feature_set::RepeatedFieldEncoding,
>,
pub utf8_validation: ::core::option::Option<
super::super::feature_set::Utf8Validation,
>,
pub message_encoding: ::core::option::Option<
super::super::feature_set::MessageEncoding,
>,
pub json_format: ::core::option::Option<super::super::feature_set::JsonFormat>,
pub enforce_naming_style: ::core::option::Option<
super::super::feature_set::EnforceNamingStyle,
>,
pub default_symbol_visibility: ::core::option::Option<
super::super::feature_set::visibility_feature::DefaultSymbolVisibility,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FeatureSetView<'a> {
type Owned = super::super::FeatureSet;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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,
)?;
let __raw = ::buffa::types::decode_int32(&mut cur)?;
if let ::core::option::Option::Some(__v) = ::buffa::Enumeration::from_i32(
__raw,
) {
view.field_presence = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.enum_type = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.repeated_field_encoding = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.utf8_validation = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.message_encoding = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.json_format = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.enforce_naming_style = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.default_symbol_visibility = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FeatureSet, ::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::FeatureSet, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FeatureSet {
field_presence: self.field_presence,
enum_type: self.enum_type,
repeated_field_encoding: self.repeated_field_encoding,
utf8_validation: self.utf8_validation,
message_encoding: self.message_encoding,
json_format: self.json_format,
enforce_naming_style: self.enforce_naming_style,
default_symbol_visibility: self.default_symbol_visibility,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FeatureSetView<'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 = 0u32;
if let Some(ref v) = self.field_presence {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.enum_type {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.repeated_field_encoding {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.utf8_validation {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.message_encoding {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.json_format {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.enforce_naming_style {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.default_symbol_visibility {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.field_presence {
::buffa::types::put_int32_field(1u32, v.to_i32(), buf);
}
if let Some(ref v) = self.enum_type {
::buffa::types::put_int32_field(2u32, v.to_i32(), buf);
}
if let Some(ref v) = self.repeated_field_encoding {
::buffa::types::put_int32_field(3u32, v.to_i32(), buf);
}
if let Some(ref v) = self.utf8_validation {
::buffa::types::put_int32_field(4u32, v.to_i32(), buf);
}
if let Some(ref v) = self.message_encoding {
::buffa::types::put_int32_field(5u32, v.to_i32(), buf);
}
if let Some(ref v) = self.json_format {
::buffa::types::put_int32_field(6u32, v.to_i32(), buf);
}
if let Some(ref v) = self.enforce_naming_style {
::buffa::types::put_int32_field(7u32, v.to_i32(), buf);
}
if let Some(ref v) = self.default_symbol_visibility {
::buffa::types::put_int32_field(8u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FeatureSetView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.field_presence {
__map
.serialize_entry(
"fieldPresence",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.enum_type {
__map
.serialize_entry(
"enumType",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.repeated_field_encoding {
__map
.serialize_entry(
"repeatedFieldEncoding",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.utf8_validation {
__map
.serialize_entry(
"utf8Validation",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.message_encoding {
__map
.serialize_entry(
"messageEncoding",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.json_format {
__map
.serialize_entry(
"jsonFormat",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.enforce_naming_style {
__map
.serialize_entry(
"enforceNamingStyle",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.default_symbol_visibility {
__map
.serialize_entry(
"defaultSymbolVisibility",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FeatureSetView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FeatureSet";
const FULL_NAME: &'static str = "google.protobuf.FeatureSet";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FeatureSet";
}
::buffa::impl_default_view_instance!(FeatureSetView);
::buffa::impl_view_reborrow!(FeatureSetView);
#[derive(Clone, Debug)]
pub struct FeatureSetOwnedView(::buffa::OwnedView<FeatureSetView<'static>>);
impl FeatureSetOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSetOwnedView(::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(
FeatureSetOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::FeatureSet,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSetOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FeatureSetView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FeatureSet, ::buffa::DecodeError> {
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 field_presence(
&self,
) -> ::core::option::Option<super::super::feature_set::FieldPresence> {
self.0.reborrow().field_presence
}
#[must_use]
pub fn enum_type(
&self,
) -> ::core::option::Option<super::super::feature_set::EnumType> {
self.0.reborrow().enum_type
}
#[must_use]
pub fn repeated_field_encoding(
&self,
) -> ::core::option::Option<super::super::feature_set::RepeatedFieldEncoding> {
self.0.reborrow().repeated_field_encoding
}
#[must_use]
pub fn utf8_validation(
&self,
) -> ::core::option::Option<super::super::feature_set::Utf8Validation> {
self.0.reborrow().utf8_validation
}
#[must_use]
pub fn message_encoding(
&self,
) -> ::core::option::Option<super::super::feature_set::MessageEncoding> {
self.0.reborrow().message_encoding
}
#[must_use]
pub fn json_format(
&self,
) -> ::core::option::Option<super::super::feature_set::JsonFormat> {
self.0.reborrow().json_format
}
#[must_use]
pub fn enforce_naming_style(
&self,
) -> ::core::option::Option<super::super::feature_set::EnforceNamingStyle> {
self.0.reborrow().enforce_naming_style
}
#[must_use]
pub fn default_symbol_visibility(
&self,
) -> ::core::option::Option<
super::super::feature_set::visibility_feature::DefaultSymbolVisibility,
> {
self.0.reborrow().default_symbol_visibility
}
}
impl ::core::convert::From<::buffa::OwnedView<FeatureSetView<'static>>>
for FeatureSetOwnedView {
fn from(inner: ::buffa::OwnedView<FeatureSetView<'static>>) -> Self {
FeatureSetOwnedView(inner)
}
}
impl ::core::convert::From<FeatureSetOwnedView>
for ::buffa::OwnedView<FeatureSetView<'static>> {
fn from(wrapper: FeatureSetOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FeatureSetView<'static>>>
for FeatureSetOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FeatureSetView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FeatureSet {
type View<'a> = FeatureSetView<'a>;
type ViewHandle = FeatureSetOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FeatureSetOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod feature_set {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct VisibilityFeatureView<'a> {
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for VisibilityFeatureView<'a> {
type Owned = super::super::super::feature_set::VisibilityFeature;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::feature_set::VisibilityFeature,
::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::super::feature_set::VisibilityFeature,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::feature_set::VisibilityFeature {
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for VisibilityFeatureView<'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 = 0u32;
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for VisibilityFeatureView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
__map.end()
}
}
impl<'a> ::buffa::MessageName for VisibilityFeatureView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FeatureSet.VisibilityFeature";
const FULL_NAME: &'static str = "google.protobuf.FeatureSet.VisibilityFeature";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FeatureSet.VisibilityFeature";
}
::buffa::impl_default_view_instance!(VisibilityFeatureView);
::buffa::impl_view_reborrow!(VisibilityFeatureView);
#[derive(Clone, Debug)]
pub struct VisibilityFeatureOwnedView(
::buffa::OwnedView<VisibilityFeatureView<'static>>,
);
impl VisibilityFeatureOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
VisibilityFeatureOwnedView(::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(
VisibilityFeatureOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::feature_set::VisibilityFeature,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
VisibilityFeatureOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &VisibilityFeatureView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::feature_set::VisibilityFeature,
::buffa::DecodeError,
> {
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()
}
}
impl ::core::convert::From<::buffa::OwnedView<VisibilityFeatureView<'static>>>
for VisibilityFeatureOwnedView {
fn from(inner: ::buffa::OwnedView<VisibilityFeatureView<'static>>) -> Self {
VisibilityFeatureOwnedView(inner)
}
}
impl ::core::convert::From<VisibilityFeatureOwnedView>
for ::buffa::OwnedView<VisibilityFeatureView<'static>> {
fn from(wrapper: VisibilityFeatureOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<VisibilityFeatureView<'static>>>
for VisibilityFeatureOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<VisibilityFeatureView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::feature_set::VisibilityFeature {
type View<'a> = VisibilityFeatureView<'a>;
type ViewHandle = VisibilityFeatureOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for VisibilityFeatureOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct FeatureSetDefaultsView<'a> {
pub defaults: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::feature_set_defaults::FeatureSetEditionDefaultView<
'a,
>,
>,
pub minimum_edition: ::core::option::Option<super::super::Edition>,
pub maximum_edition: ::core::option::Option<super::super::Edition>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FeatureSetDefaultsView<'a> {
type Owned = super::super::FeatureSetDefaults;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.minimum_edition = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.maximum_edition = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, 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)?;
view.defaults
.push(
<super::super::__buffa::view::feature_set_defaults::FeatureSetEditionDefaultView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FeatureSetDefaults, ::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::FeatureSetDefaults, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::FeatureSetDefaults {
defaults: self
.defaults
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
minimum_edition: self.minimum_edition,
maximum_edition: self.maximum_edition,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FeatureSetDefaultsView<'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 = 0u32;
for v in &self.defaults {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if let Some(ref v) = self.minimum_edition {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if let Some(ref v) = self.maximum_edition {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.defaults {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
if let Some(ref v) = self.minimum_edition {
::buffa::types::put_int32_field(4u32, v.to_i32(), buf);
}
if let Some(ref v) = self.maximum_edition {
::buffa::types::put_int32_field(5u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FeatureSetDefaultsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.defaults.is_empty() {
__map.serialize_entry("defaults", &*self.defaults)?;
}
if let ::core::option::Option::Some(__v) = self.minimum_edition {
__map
.serialize_entry(
"minimumEdition",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
if let ::core::option::Option::Some(__v) = self.maximum_edition {
__map
.serialize_entry(
"maximumEdition",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FeatureSetDefaultsView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FeatureSetDefaults";
const FULL_NAME: &'static str = "google.protobuf.FeatureSetDefaults";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FeatureSetDefaults";
}
::buffa::impl_default_view_instance!(FeatureSetDefaultsView);
::buffa::impl_view_reborrow!(FeatureSetDefaultsView);
#[derive(Clone, Debug)]
pub struct FeatureSetDefaultsOwnedView(
::buffa::OwnedView<FeatureSetDefaultsView<'static>>,
);
impl FeatureSetDefaultsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSetDefaultsOwnedView(::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(
FeatureSetDefaultsOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::FeatureSetDefaults,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSetDefaultsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FeatureSetDefaultsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::FeatureSetDefaults, ::buffa::DecodeError> {
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 defaults(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::feature_set_defaults::FeatureSetEditionDefaultView<
'_,
>,
> {
&self.0.reborrow().defaults
}
#[must_use]
pub fn minimum_edition(&self) -> ::core::option::Option<super::super::Edition> {
self.0.reborrow().minimum_edition
}
#[must_use]
pub fn maximum_edition(&self) -> ::core::option::Option<super::super::Edition> {
self.0.reborrow().maximum_edition
}
}
impl ::core::convert::From<::buffa::OwnedView<FeatureSetDefaultsView<'static>>>
for FeatureSetDefaultsOwnedView {
fn from(inner: ::buffa::OwnedView<FeatureSetDefaultsView<'static>>) -> Self {
FeatureSetDefaultsOwnedView(inner)
}
}
impl ::core::convert::From<FeatureSetDefaultsOwnedView>
for ::buffa::OwnedView<FeatureSetDefaultsView<'static>> {
fn from(wrapper: FeatureSetDefaultsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FeatureSetDefaultsView<'static>>>
for FeatureSetDefaultsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FeatureSetDefaultsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::FeatureSetDefaults {
type View<'a> = FeatureSetDefaultsView<'a>;
type ViewHandle = FeatureSetDefaultsOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FeatureSetDefaultsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod feature_set_defaults {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct FeatureSetEditionDefaultView<'a> {
pub edition: ::core::option::Option<super::super::super::Edition>,
pub overridable_features: ::buffa::MessageFieldView<
super::super::super::__buffa::view::FeatureSetView<'a>,
>,
pub fixed_features: ::buffa::MessageFieldView<
super::super::super::__buffa::view::FeatureSetView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for FeatureSetEditionDefaultView<'a> {
type Owned = super::super::super::feature_set_defaults::FeatureSetEditionDefault;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.edition = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, 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)?;
match view.overridable_features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(
existing,
sub,
__sub_ctx,
)?
}
None => {
view.overridable_features = ::buffa::MessageFieldView::set(
<super::super::super::__buffa::view::FeatureSetView 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)?;
match view.fixed_features.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(
existing,
sub,
__sub_ctx,
)?
}
None => {
view.fixed_features = ::buffa::MessageFieldView::set(
<super::super::super::__buffa::view::FeatureSetView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::feature_set_defaults::FeatureSetEditionDefault,
::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::super::feature_set_defaults::FeatureSetEditionDefault,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::feature_set_defaults::FeatureSetEditionDefault {
edition: self.edition,
overridable_features: match self.overridable_features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
fixed_features: match self.fixed_features.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::super::FeatureSet,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for FeatureSetEditionDefaultView<'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 = 0u32;
if let Some(ref v) = self.edition {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
if self.overridable_features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.overridable_features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
if self.fixed_features.is_set() {
let __slot = __cache.reserve();
let inner_size = self.fixed_features.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if let Some(ref v) = self.edition {
::buffa::types::put_int32_field(3u32, v.to_i32(), buf);
}
if self.overridable_features.is_set() {
::buffa::types::put_len_delimited_header(
4u32,
__cache.consume_next(),
buf,
);
self.overridable_features.write_to(__cache, buf);
}
if self.fixed_features.is_set() {
::buffa::types::put_len_delimited_header(
5u32,
__cache.consume_next(),
buf,
);
self.fixed_features.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for FeatureSetEditionDefaultView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if let ::core::option::Option::Some(__v) = self.edition {
__map
.serialize_entry(
"edition",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
{
if let ::core::option::Option::Some(__v) = self
.overridable_features
.as_option()
{
__map.serialize_entry("overridableFeatures", __v)?;
}
}
{
if let ::core::option::Option::Some(__v) = self
.fixed_features
.as_option()
{
__map.serialize_entry("fixedFeatures", __v)?;
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for FeatureSetEditionDefaultView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "FeatureSetDefaults.FeatureSetEditionDefault";
const FULL_NAME: &'static str = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault";
}
::buffa::impl_default_view_instance!(FeatureSetEditionDefaultView);
::buffa::impl_view_reborrow!(FeatureSetEditionDefaultView);
#[derive(Clone, Debug)]
pub struct FeatureSetEditionDefaultOwnedView(
::buffa::OwnedView<FeatureSetEditionDefaultView<'static>>,
);
impl FeatureSetEditionDefaultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSetEditionDefaultOwnedView(::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(
FeatureSetEditionDefaultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::feature_set_defaults::FeatureSetEditionDefault,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
FeatureSetEditionDefaultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &FeatureSetEditionDefaultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::feature_set_defaults::FeatureSetEditionDefault,
::buffa::DecodeError,
> {
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 edition(&self) -> ::core::option::Option<super::super::super::Edition> {
self.0.reborrow().edition
}
#[must_use]
pub fn overridable_features(
&self,
) -> &::buffa::MessageFieldView<
super::super::super::__buffa::view::FeatureSetView<'_>,
> {
&self.0.reborrow().overridable_features
}
#[must_use]
pub fn fixed_features(
&self,
) -> &::buffa::MessageFieldView<
super::super::super::__buffa::view::FeatureSetView<'_>,
> {
&self.0.reborrow().fixed_features
}
}
impl ::core::convert::From<::buffa::OwnedView<FeatureSetEditionDefaultView<'static>>>
for FeatureSetEditionDefaultOwnedView {
fn from(
inner: ::buffa::OwnedView<FeatureSetEditionDefaultView<'static>>,
) -> Self {
FeatureSetEditionDefaultOwnedView(inner)
}
}
impl ::core::convert::From<FeatureSetEditionDefaultOwnedView>
for ::buffa::OwnedView<FeatureSetEditionDefaultView<'static>> {
fn from(wrapper: FeatureSetEditionDefaultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<
::buffa::OwnedView<FeatureSetEditionDefaultView<'static>>,
> for FeatureSetEditionDefaultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FeatureSetEditionDefaultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::feature_set_defaults::FeatureSetEditionDefault {
type View<'a> = FeatureSetEditionDefaultView<'a>;
type ViewHandle = FeatureSetEditionDefaultOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for FeatureSetEditionDefaultOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct SourceCodeInfoView<'a> {
pub location: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::source_code_info::LocationView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for SourceCodeInfoView<'a> {
type Owned = super::super::SourceCodeInfo;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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)?;
view.location
.push(
<super::super::__buffa::view::source_code_info::LocationView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::SourceCodeInfo, ::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::SourceCodeInfo, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::SourceCodeInfo {
location: self
.location
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for SourceCodeInfoView<'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 = 0u32;
for v in &self.location {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.location {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for SourceCodeInfoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.location.is_empty() {
__map.serialize_entry("location", &*self.location)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for SourceCodeInfoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "SourceCodeInfo";
const FULL_NAME: &'static str = "google.protobuf.SourceCodeInfo";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.SourceCodeInfo";
}
::buffa::impl_default_view_instance!(SourceCodeInfoView);
::buffa::impl_view_reborrow!(SourceCodeInfoView);
#[derive(Clone, Debug)]
pub struct SourceCodeInfoOwnedView(::buffa::OwnedView<SourceCodeInfoView<'static>>);
impl SourceCodeInfoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
SourceCodeInfoOwnedView(::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(
SourceCodeInfoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::SourceCodeInfo,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
SourceCodeInfoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &SourceCodeInfoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::SourceCodeInfo, ::buffa::DecodeError> {
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 location(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::source_code_info::LocationView<'_>,
> {
&self.0.reborrow().location
}
}
impl ::core::convert::From<::buffa::OwnedView<SourceCodeInfoView<'static>>>
for SourceCodeInfoOwnedView {
fn from(inner: ::buffa::OwnedView<SourceCodeInfoView<'static>>) -> Self {
SourceCodeInfoOwnedView(inner)
}
}
impl ::core::convert::From<SourceCodeInfoOwnedView>
for ::buffa::OwnedView<SourceCodeInfoView<'static>> {
fn from(wrapper: SourceCodeInfoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<SourceCodeInfoView<'static>>>
for SourceCodeInfoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<SourceCodeInfoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::SourceCodeInfo {
type View<'a> = SourceCodeInfoView<'a>;
type ViewHandle = SourceCodeInfoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for SourceCodeInfoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod source_code_info {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct LocationView<'a> {
pub path: ::buffa::RepeatedView<'a, i32>,
pub span: ::buffa::RepeatedView<'a, i32>,
pub leading_comments: ::core::option::Option<&'a str>,
pub trailing_comments: ::core::option::Option<&'a str>,
pub leading_detached_comments: ::buffa::RepeatedView<'a, &'a str>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for LocationView<'a> {
type Owned = super::super::super::source_code_info::Location;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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() {
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.leading_comments = Some(::buffa::types::borrow_str(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.trailing_comments = Some(::buffa::types::borrow_str(&mut cur)?);
}
1u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
view.path.reserve(::buffa::encoding::count_varints(payload));
let mut pcur: &[u8] = payload;
while !pcur.is_empty() {
view.path.push(::buffa::types::decode_int32(&mut pcur)?);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.path.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)?;
view.span.reserve(::buffa::encoding::count_varints(payload));
let mut pcur: &[u8] = payload;
while !pcur.is_empty() {
view.span.push(::buffa::types::decode_int32(&mut pcur)?);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.span.push(::buffa::types::decode_int32(&mut cur)?);
} else {
return Err(
::buffa::encoding::wire_type_mismatch(
tag,
::buffa::encoding::WireType::LengthDelimited,
),
);
}
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.leading_detached_comments
.push(::buffa::types::borrow_str(&mut cur)?);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::source_code_info::Location,
::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::super::source_code_info::Location,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::source_code_info::Location {
path: self.path.to_vec(),
span: self.span.to_vec(),
leading_comments: self.leading_comments.map(|s| s.to_string()),
trailing_comments: self.trailing_comments.map(|s| s.to_string()),
leading_detached_comments: self
.leading_detached_comments
.iter()
.map(|s| s.to_string())
.collect(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for LocationView<'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 = 0u32;
if !self.path.is_empty() {
let payload: u32 = self
.path
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u32)
.sum::<u32>();
size
+= 1u32 + ::buffa::encoding::varint_len(payload as u64) as u32
+ payload;
}
if !self.span.is_empty() {
let payload: u32 = self
.span
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u32)
.sum::<u32>();
size
+= 1u32 + ::buffa::encoding::varint_len(payload as u64) as u32
+ payload;
}
if let Some(ref v) = self.leading_comments {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.trailing_comments {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
for v in &self.leading_detached_comments {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.path.is_empty() {
let payload: u32 = self
.path
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u32)
.sum::<u32>();
::buffa::types::put_len_delimited_header(1u32, payload, buf);
for &v in &self.path {
::buffa::types::encode_int32(v, buf);
}
}
if !self.span.is_empty() {
let payload: u32 = self
.span
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u32)
.sum::<u32>();
::buffa::types::put_len_delimited_header(2u32, payload, buf);
for &v in &self.span {
::buffa::types::encode_int32(v, buf);
}
}
if let Some(ref v) = self.leading_comments {
::buffa::types::put_string_field(3u32, v, buf);
}
if let Some(ref v) = self.trailing_comments {
::buffa::types::put_string_field(4u32, v, buf);
}
for v in &self.leading_detached_comments {
::buffa::types::put_string_field(6u32, v, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for LocationView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.path.is_empty() {
__map
.serialize_entry(
"path",
&::buffa::json_helpers::RepeatedJson(&self.path),
)?;
}
if !self.span.is_empty() {
__map
.serialize_entry(
"span",
&::buffa::json_helpers::RepeatedJson(&self.span),
)?;
}
if let ::core::option::Option::Some(__v) = self.leading_comments {
__map.serialize_entry("leadingComments", __v)?;
}
if let ::core::option::Option::Some(__v) = self.trailing_comments {
__map.serialize_entry("trailingComments", __v)?;
}
if !self.leading_detached_comments.is_empty() {
__map
.serialize_entry(
"leadingDetachedComments",
&*self.leading_detached_comments,
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for LocationView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "SourceCodeInfo.Location";
const FULL_NAME: &'static str = "google.protobuf.SourceCodeInfo.Location";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.SourceCodeInfo.Location";
}
::buffa::impl_default_view_instance!(LocationView);
::buffa::impl_view_reborrow!(LocationView);
#[derive(Clone, Debug)]
pub struct LocationOwnedView(::buffa::OwnedView<LocationView<'static>>);
impl LocationOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
LocationOwnedView(::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(
LocationOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::super::source_code_info::Location,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
LocationOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &LocationView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::source_code_info::Location,
::buffa::DecodeError,
> {
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 path(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().path
}
#[must_use]
pub fn span(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().span
}
#[must_use]
pub fn leading_comments(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().leading_comments
}
#[must_use]
pub fn trailing_comments(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().trailing_comments
}
#[must_use]
pub fn leading_detached_comments(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().leading_detached_comments
}
}
impl ::core::convert::From<::buffa::OwnedView<LocationView<'static>>>
for LocationOwnedView {
fn from(inner: ::buffa::OwnedView<LocationView<'static>>) -> Self {
LocationOwnedView(inner)
}
}
impl ::core::convert::From<LocationOwnedView>
for ::buffa::OwnedView<LocationView<'static>> {
fn from(wrapper: LocationOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<LocationView<'static>>>
for LocationOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<LocationView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::super::source_code_info::Location {
type View<'a> = LocationView<'a>;
type ViewHandle = LocationOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for LocationOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}
#[derive(Clone, Debug, Default)]
pub struct GeneratedCodeInfoView<'a> {
pub annotation: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::generated_code_info::AnnotationView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for GeneratedCodeInfoView<'a> {
type Owned = super::super::GeneratedCodeInfo;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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)?;
view.annotation
.push(
<super::super::__buffa::view::generated_code_info::AnnotationView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::GeneratedCodeInfo, ::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::GeneratedCodeInfo, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::GeneratedCodeInfo {
annotation: self
.annotation
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for GeneratedCodeInfoView<'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 = 0u32;
for v in &self.annotation {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.annotation {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for GeneratedCodeInfoView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.annotation.is_empty() {
__map.serialize_entry("annotation", &*self.annotation)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for GeneratedCodeInfoView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "GeneratedCodeInfo";
const FULL_NAME: &'static str = "google.protobuf.GeneratedCodeInfo";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.GeneratedCodeInfo";
}
::buffa::impl_default_view_instance!(GeneratedCodeInfoView);
::buffa::impl_view_reborrow!(GeneratedCodeInfoView);
#[derive(Clone, Debug)]
pub struct GeneratedCodeInfoOwnedView(
::buffa::OwnedView<GeneratedCodeInfoView<'static>>,
);
impl GeneratedCodeInfoOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
GeneratedCodeInfoOwnedView(::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(
GeneratedCodeInfoOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::GeneratedCodeInfo,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
GeneratedCodeInfoOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &GeneratedCodeInfoView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::GeneratedCodeInfo, ::buffa::DecodeError> {
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 annotation(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::generated_code_info::AnnotationView<'_>,
> {
&self.0.reborrow().annotation
}
}
impl ::core::convert::From<::buffa::OwnedView<GeneratedCodeInfoView<'static>>>
for GeneratedCodeInfoOwnedView {
fn from(inner: ::buffa::OwnedView<GeneratedCodeInfoView<'static>>) -> Self {
GeneratedCodeInfoOwnedView(inner)
}
}
impl ::core::convert::From<GeneratedCodeInfoOwnedView>
for ::buffa::OwnedView<GeneratedCodeInfoView<'static>> {
fn from(wrapper: GeneratedCodeInfoOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<GeneratedCodeInfoView<'static>>>
for GeneratedCodeInfoOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<GeneratedCodeInfoView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::GeneratedCodeInfo {
type View<'a> = GeneratedCodeInfoView<'a>;
type ViewHandle = GeneratedCodeInfoOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for GeneratedCodeInfoOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
pub mod generated_code_info {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, Default)]
pub struct AnnotationView<'a> {
pub path: ::buffa::RepeatedView<'a, i32>,
pub source_file: ::core::option::Option<&'a str>,
pub begin: ::core::option::Option<i32>,
pub end: ::core::option::Option<i32>,
pub semantic: ::core::option::Option<
super::super::super::generated_code_info::annotation::Semantic,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for AnnotationView<'a> {
type Owned = super::super::super::generated_code_info::Annotation;
fn decode_view(
buf: &'a [u8],
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
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)
}
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,
)?;
view.source_file = Some(::buffa::types::borrow_str(&mut cur)?);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.begin = Some(::buffa::types::decode_int32(&mut cur)?);
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.end = Some(::buffa::types::decode_int32(&mut cur)?);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::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.semantic = Some(__v);
} else {
let __span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields
.push_record(before_tag, __span_len, ctx)?;
}
}
1u32 => {
if tag.wire_type() == ::buffa::encoding::WireType::LengthDelimited {
let payload = ::buffa::types::borrow_bytes(&mut cur)?;
view.path.reserve(::buffa::encoding::count_varints(payload));
let mut pcur: &[u8] = payload;
while !pcur.is_empty() {
view.path.push(::buffa::types::decode_int32(&mut pcur)?);
}
} else if tag.wire_type() == ::buffa::encoding::WireType::Varint {
view.path.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())?;
let span_len = before_tag.len() - cur.len();
view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::generated_code_info::Annotation,
::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::super::generated_code_info::Annotation,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::super::generated_code_info::Annotation {
path: self.path.to_vec(),
source_file: self.source_file.map(|s| s.to_string()),
begin: self.begin,
end: self.end,
semantic: self.semantic,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for AnnotationView<'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 = 0u32;
if !self.path.is_empty() {
let payload: u32 = self
.path
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u32)
.sum::<u32>();
size
+= 1u32 + ::buffa::encoding::varint_len(payload as u64) as u32
+ payload;
}
if let Some(ref v) = self.source_file {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(v) = self.begin {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(v) = self.end {
size += 1u32 + ::buffa::types::int32_encoded_len(v) as u32;
}
if let Some(ref v) = self.semantic {
size += 1u32 + ::buffa::types::int32_encoded_len(v.to_i32()) as u32;
}
size += self.__buffa_unknown_fields.encoded_len() as u32;
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.path.is_empty() {
let payload: u32 = self
.path
.iter()
.map(|&v| ::buffa::types::int32_encoded_len(v) as u32)
.sum::<u32>();
::buffa::types::put_len_delimited_header(1u32, payload, buf);
for &v in &self.path {
::buffa::types::encode_int32(v, buf);
}
}
if let Some(ref v) = self.source_file {
::buffa::types::put_string_field(2u32, v, buf);
}
if let Some(v) = self.begin {
::buffa::types::put_int32_field(3u32, v, buf);
}
if let Some(v) = self.end {
::buffa::types::put_int32_field(4u32, v, buf);
}
if let Some(ref v) = self.semantic {
::buffa::types::put_int32_field(5u32, v.to_i32(), buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
#[cfg(feature = "json")]
impl<'__a> ::serde::Serialize for AnnotationView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.path.is_empty() {
__map
.serialize_entry(
"path",
&::buffa::json_helpers::RepeatedJson(&self.path),
)?;
}
if let ::core::option::Option::Some(__v) = self.source_file {
__map.serialize_entry("sourceFile", __v)?;
}
if let ::core::option::Option::Some(__v) = self.begin {
__map.serialize_entry("begin", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.end {
__map.serialize_entry("end", &::buffa::json_helpers::ProtoJson(&__v))?;
}
if let ::core::option::Option::Some(__v) = self.semantic {
__map
.serialize_entry(
"semantic",
&::buffa::json_helpers::ClosedEnumJson(&__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for AnnotationView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "GeneratedCodeInfo.Annotation";
const FULL_NAME: &'static str = "google.protobuf.GeneratedCodeInfo.Annotation";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.GeneratedCodeInfo.Annotation";
}
::buffa::impl_default_view_instance!(AnnotationView);
::buffa::impl_view_reborrow!(AnnotationView);
#[derive(Clone, Debug)]
pub struct AnnotationOwnedView(::buffa::OwnedView<AnnotationView<'static>>);
impl AnnotationOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AnnotationOwnedView(::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(
AnnotationOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::super::generated_code_info::Annotation,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AnnotationOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &AnnotationView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::super::generated_code_info::Annotation,
::buffa::DecodeError,
> {
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 path(&self) -> &::buffa::RepeatedView<'_, i32> {
&self.0.reborrow().path
}
#[must_use]
pub fn source_file(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().source_file
}
#[must_use]
pub fn begin(&self) -> ::core::option::Option<i32> {
self.0.reborrow().begin
}
#[must_use]
pub fn end(&self) -> ::core::option::Option<i32> {
self.0.reborrow().end
}
#[must_use]
pub fn semantic(
&self,
) -> ::core::option::Option<
super::super::super::generated_code_info::annotation::Semantic,
> {
self.0.reborrow().semantic
}
}
impl ::core::convert::From<::buffa::OwnedView<AnnotationView<'static>>>
for AnnotationOwnedView {
fn from(inner: ::buffa::OwnedView<AnnotationView<'static>>) -> Self {
AnnotationOwnedView(inner)
}
}
impl ::core::convert::From<AnnotationOwnedView>
for ::buffa::OwnedView<AnnotationView<'static>> {
fn from(wrapper: AnnotationOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<AnnotationView<'static>>>
for AnnotationOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<AnnotationView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView
for super::super::super::generated_code_info::Annotation {
type View<'a> = AnnotationView<'a>;
type ViewHandle = AnnotationOwnedView;
}
#[cfg(feature = "json")]
impl ::serde::Serialize for AnnotationOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
}