#[derive(Clone, Debug, Default)]
pub struct ApiView<'a> {
pub name: &'a str,
pub methods: ::buffa::RepeatedView<'a, super::super::__buffa::view::MethodView<'a>>,
pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
pub version: &'a str,
pub source_context: ::buffa::MessageFieldView<
super::super::__buffa::view::SourceContextView<'a>,
>,
pub mixins: ::buffa::RepeatedView<'a, super::super::__buffa::view::MixinView<'a>>,
pub syntax: ::buffa::EnumValue<super::super::Syntax>,
pub edition: &'a str,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for ApiView<'a> {
type Owned = super::super::Api;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.name = ::buffa::types::borrow_str(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.version = ::buffa::types::borrow_str(&mut cur)?;
}
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.source_context.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.source_context = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::SourceContextView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
}
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.syntax = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.edition = ::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)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::MethodView>(),
)?;
view.methods
.push(
<super::super::__buffa::view::MethodView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
)?;
view.options
.push(
<super::super::__buffa::view::OptionView 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)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::MixinView>(),
)?;
view.mixins
.push(
<super::super::__buffa::view::MixinView 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::Api, ::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::Api, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Api {
name: self.name.to_string(),
methods: self
.methods
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
options: self
.options
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
version: self.version.to_string(),
source_context: match self.source_context.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::SourceContext,
::buffa::Inline<super::super::SourceContext>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
mixins: self
.mixins
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
syntax: self.syntax,
edition: self.edition.to_string(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ApiView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if !self.name.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
}
for v in &self.methods {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.options {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
if !self.version.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.version) as u64;
}
if self.source_context.is_set() {
let __slot = __cache.reserve();
let inner_size = self.source_context.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
for v in &self.mixins {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
{
let val = self.syntax.to_i32();
if val != 0 {
size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
}
}
if !self.edition.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.edition) as u64;
}
size += self.__buffa_unknown_fields.encoded_len() as u64;
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.name.is_empty() {
::buffa::types::put_string_field(1u32, &self.name, buf);
}
for v in &self.methods {
::buffa::types::put_len_delimited_header(
2u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
for v in &self.options {
::buffa::types::put_len_delimited_header(
3u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
if !self.version.is_empty() {
::buffa::types::put_string_field(4u32, &self.version, buf);
}
if self.source_context.is_set() {
::buffa::types::put_len_delimited_header(
5u32,
u64::from(__cache.consume_next()),
buf,
);
self.source_context.write_to(__cache, buf);
}
for v in &self.mixins {
::buffa::types::put_len_delimited_header(
6u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
{
let val = self.syntax.to_i32();
if val != 0 {
::buffa::types::put_int32_field(7u32, val, buf);
}
}
if !self.edition.is_empty() {
::buffa::types::put_string_field(8u32, &self.edition, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'a> ::buffa::MessageName for ApiView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "Api";
const FULL_NAME: &'static str = "google.protobuf.Api";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Api";
}
::buffa::impl_default_view_instance!(ApiView);
::buffa::impl_view_reborrow!(ApiView);
#[derive(Clone, Debug)]
pub struct ApiOwnedView(::buffa::OwnedView<ApiView<'static>>);
impl ApiOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(ApiOwnedView(::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(
ApiOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Api,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(ApiOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &ApiView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Api {
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) -> &'_ str {
self.0.reborrow().name
}
#[must_use]
pub fn methods(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::MethodView<'_>> {
&self.0.reborrow().methods
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
&self.0.reborrow().options
}
#[must_use]
pub fn version(&self) -> &'_ str {
self.0.reborrow().version
}
#[must_use]
pub fn source_context(
&self,
) -> &::buffa::MessageFieldView<super::super::__buffa::view::SourceContextView<'_>> {
&self.0.reborrow().source_context
}
#[must_use]
pub fn mixins(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::MixinView<'_>> {
&self.0.reborrow().mixins
}
#[must_use]
pub fn syntax(&self) -> ::buffa::EnumValue<super::super::Syntax> {
self.0.reborrow().syntax
}
#[must_use]
pub fn edition(&self) -> &'_ str {
self.0.reborrow().edition
}
}
impl ::core::convert::From<::buffa::OwnedView<ApiView<'static>>> for ApiOwnedView {
fn from(inner: ::buffa::OwnedView<ApiView<'static>>) -> Self {
ApiOwnedView(inner)
}
}
impl ::core::convert::From<ApiOwnedView> for ::buffa::OwnedView<ApiView<'static>> {
fn from(wrapper: ApiOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ApiView<'static>>> for ApiOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ApiView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Api {
type View<'a> = ApiView<'a>;
type ViewHandle = ApiOwnedView;
}
#[cfg(feature = "reflect")]
const _: () = {
impl<'a> ::buffa_descriptor::reflect::ReflectMessage for ApiView<'a> {
fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
super::super::__buffa::reflect::descriptor_pool()
.message(Self::__buffa_reflect_message_index())
}
fn pool(
&self,
) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
super::super::__buffa::reflect::descriptor_pool()
}
fn get(
&self,
field: &::buffa_descriptor::FieldDescriptor,
) -> ::buffa_descriptor::reflect::ValueRef<'_> {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match field.number() {
1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
2u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.methods),
3u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
4u32 => ::buffa_descriptor::reflect::ValueRef::String(self.version),
5u32 => {
::buffa_descriptor::reflect::ValueRef::Message(
::buffa_descriptor::reflect::ReflectCow::Borrowed(
&*self.source_context,
),
)
}
6u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.mixins),
7u32 => {
::buffa_descriptor::reflect::ValueRef::EnumNumber(
self.syntax.to_i32(),
)
}
8u32 => ::buffa_descriptor::reflect::ValueRef::String(self.edition),
_ => {
::core::debug_assert!(
false,
"field number {} is not a member of this view's reflect get()",
field.number(),
);
::buffa_descriptor::reflect::ValueRef::Bool(false)
}
}
}
fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
match field.number() {
1u32 => !self.name.is_empty(),
2u32 => !::buffa::RepeatedView::is_empty(&self.methods),
3u32 => !::buffa::RepeatedView::is_empty(&self.options),
4u32 => !self.version.is_empty(),
5u32 => self.source_context.is_set(),
6u32 => !::buffa::RepeatedView::is_empty(&self.mixins),
7u32 => self.syntax.to_i32() != 0,
8u32 => !self.edition.is_empty(),
_ => false,
}
}
fn for_each_set(
&self,
f: &mut dyn ::core::ops::FnMut(
&::buffa_descriptor::FieldDescriptor,
::buffa_descriptor::reflect::ValueRef<'_>,
),
) {
let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
self,
);
for fd in md.fields() {
if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
}
}
}
fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
let bytes = ::buffa::ViewEncode::encode_to_vec(self);
let options = ::buffa::DecodeOptions::new()
.with_element_memory_limit(
bytes
.len()
.saturating_mul(128)
.max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
)
.with_unknown_field_limit(
bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
);
::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
::buffa::alloc::sync::Arc::clone(
super::super::__buffa::reflect::descriptor_pool(),
),
Self::__buffa_reflect_message_index(),
&bytes,
&options,
)
.expect("view re-encodes to bytes decodable against its own descriptor")
}
}
impl<'a> ::buffa_descriptor::reflect::ReflectElement for ApiView<'a> {
fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
::buffa_descriptor::reflect::ValueRef::Message(
::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
)
}
}
impl<'a> ApiView<'a> {
#[doc(hidden)]
fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
*IDX
.get_or_init(|| {
super::super::__buffa::reflect::descriptor_pool()
.message_index(<Self as ::buffa::MessageName>::FULL_NAME)
.expect(
"generated view type is registered in the embedded descriptor pool",
)
})
}
}
};
#[derive(Clone, Debug, Default)]
pub struct MethodView<'a> {
pub name: &'a str,
pub request_type_url: &'a str,
pub request_streaming: bool,
pub response_type_url: &'a str,
pub response_streaming: bool,
pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
pub syntax: ::buffa::EnumValue<super::super::Syntax>,
pub edition: &'a str,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for MethodView<'a> {
type Owned = super::super::Method;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.name = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.request_type_url = ::buffa::types::borrow_str(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.request_streaming = ::buffa::types::decode_bool(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.response_type_url = ::buffa::types::borrow_str(&mut cur)?;
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.response_streaming = ::buffa::types::decode_bool(&mut cur)?;
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.syntax = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.edition = ::buffa::types::borrow_str(&mut cur)?;
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
)?;
view.options
.push(
<super::super::__buffa::view::OptionView 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::Method, ::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::Method, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Method {
name: self.name.to_string(),
request_type_url: self.request_type_url.to_string(),
request_streaming: self.request_streaming,
response_type_url: self.response_type_url.to_string(),
response_streaming: self.response_streaming,
options: self
.options
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
syntax: self.syntax,
edition: self.edition.to_string(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for MethodView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if !self.name.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
}
if !self.request_type_url.is_empty() {
size
+= 1u64
+ ::buffa::types::string_encoded_len(&self.request_type_url) as u64;
}
if self.request_streaming {
size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
}
if !self.response_type_url.is_empty() {
size
+= 1u64
+ ::buffa::types::string_encoded_len(&self.response_type_url) as u64;
}
if self.response_streaming {
size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
}
for v in &self.options {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
{
let val = self.syntax.to_i32();
if val != 0 {
size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
}
}
if !self.edition.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.edition) as u64;
}
size += self.__buffa_unknown_fields.encoded_len() as u64;
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.name.is_empty() {
::buffa::types::put_string_field(1u32, &self.name, buf);
}
if !self.request_type_url.is_empty() {
::buffa::types::put_string_field(2u32, &self.request_type_url, buf);
}
if self.request_streaming {
::buffa::types::put_bool_field(3u32, self.request_streaming, buf);
}
if !self.response_type_url.is_empty() {
::buffa::types::put_string_field(4u32, &self.response_type_url, buf);
}
if self.response_streaming {
::buffa::types::put_bool_field(5u32, self.response_streaming, buf);
}
for v in &self.options {
::buffa::types::put_len_delimited_header(
6u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
{
let val = self.syntax.to_i32();
if val != 0 {
::buffa::types::put_int32_field(7u32, val, buf);
}
}
if !self.edition.is_empty() {
::buffa::types::put_string_field(8u32, &self.edition, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'a> ::buffa::MessageName for MethodView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "Method";
const FULL_NAME: &'static str = "google.protobuf.Method";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Method";
}
::buffa::impl_default_view_instance!(MethodView);
::buffa::impl_view_reborrow!(MethodView);
#[derive(Clone, Debug)]
pub struct MethodOwnedView(::buffa::OwnedView<MethodView<'static>>);
impl MethodOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(MethodOwnedView(::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(
MethodOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Method,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(MethodOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &MethodView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Method {
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) -> &'_ str {
self.0.reborrow().name
}
#[must_use]
pub fn request_type_url(&self) -> &'_ str {
self.0.reborrow().request_type_url
}
#[must_use]
pub fn request_streaming(&self) -> bool {
self.0.reborrow().request_streaming
}
#[must_use]
pub fn response_type_url(&self) -> &'_ str {
self.0.reborrow().response_type_url
}
#[must_use]
pub fn response_streaming(&self) -> bool {
self.0.reborrow().response_streaming
}
#[must_use]
pub fn options(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
&self.0.reborrow().options
}
#[must_use]
pub fn syntax(&self) -> ::buffa::EnumValue<super::super::Syntax> {
self.0.reborrow().syntax
}
#[must_use]
pub fn edition(&self) -> &'_ str {
self.0.reborrow().edition
}
}
impl ::core::convert::From<::buffa::OwnedView<MethodView<'static>>> for MethodOwnedView {
fn from(inner: ::buffa::OwnedView<MethodView<'static>>) -> Self {
MethodOwnedView(inner)
}
}
impl ::core::convert::From<MethodOwnedView> for ::buffa::OwnedView<MethodView<'static>> {
fn from(wrapper: MethodOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<MethodView<'static>>>
for MethodOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<MethodView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Method {
type View<'a> = MethodView<'a>;
type ViewHandle = MethodOwnedView;
}
#[cfg(feature = "reflect")]
const _: () = {
impl<'a> ::buffa_descriptor::reflect::ReflectMessage for MethodView<'a> {
fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
super::super::__buffa::reflect::descriptor_pool()
.message(Self::__buffa_reflect_message_index())
}
fn pool(
&self,
) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
super::super::__buffa::reflect::descriptor_pool()
}
fn get(
&self,
field: &::buffa_descriptor::FieldDescriptor,
) -> ::buffa_descriptor::reflect::ValueRef<'_> {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match field.number() {
1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
2u32 => {
::buffa_descriptor::reflect::ValueRef::String(self.request_type_url)
}
3u32 => {
::buffa_descriptor::reflect::ValueRef::Bool(self.request_streaming)
}
4u32 => {
::buffa_descriptor::reflect::ValueRef::String(self.response_type_url)
}
5u32 => {
::buffa_descriptor::reflect::ValueRef::Bool(self.response_streaming)
}
6u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
7u32 => {
::buffa_descriptor::reflect::ValueRef::EnumNumber(
self.syntax.to_i32(),
)
}
8u32 => ::buffa_descriptor::reflect::ValueRef::String(self.edition),
_ => {
::core::debug_assert!(
false,
"field number {} is not a member of this view's reflect get()",
field.number(),
);
::buffa_descriptor::reflect::ValueRef::Bool(false)
}
}
}
fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
match field.number() {
1u32 => !self.name.is_empty(),
2u32 => !self.request_type_url.is_empty(),
3u32 => self.request_streaming,
4u32 => !self.response_type_url.is_empty(),
5u32 => self.response_streaming,
6u32 => !::buffa::RepeatedView::is_empty(&self.options),
7u32 => self.syntax.to_i32() != 0,
8u32 => !self.edition.is_empty(),
_ => false,
}
}
fn for_each_set(
&self,
f: &mut dyn ::core::ops::FnMut(
&::buffa_descriptor::FieldDescriptor,
::buffa_descriptor::reflect::ValueRef<'_>,
),
) {
let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
self,
);
for fd in md.fields() {
if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
}
}
}
fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
let bytes = ::buffa::ViewEncode::encode_to_vec(self);
let options = ::buffa::DecodeOptions::new()
.with_element_memory_limit(
bytes
.len()
.saturating_mul(128)
.max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
)
.with_unknown_field_limit(
bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
);
::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
::buffa::alloc::sync::Arc::clone(
super::super::__buffa::reflect::descriptor_pool(),
),
Self::__buffa_reflect_message_index(),
&bytes,
&options,
)
.expect("view re-encodes to bytes decodable against its own descriptor")
}
}
impl<'a> ::buffa_descriptor::reflect::ReflectElement for MethodView<'a> {
fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
::buffa_descriptor::reflect::ValueRef::Message(
::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
)
}
}
impl<'a> MethodView<'a> {
#[doc(hidden)]
fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
*IDX
.get_or_init(|| {
super::super::__buffa::reflect::descriptor_pool()
.message_index(<Self as ::buffa::MessageName>::FULL_NAME)
.expect(
"generated view type is registered in the embedded descriptor pool",
)
})
}
}
};
#[derive(Clone, Debug, Default)]
pub struct MixinView<'a> {
pub name: &'a str,
pub root: &'a str,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for MixinView<'a> {
type Owned = super::super::Mixin;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.name = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.root = ::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::Mixin, ::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::Mixin, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Mixin {
name: self.name.to_string(),
root: self.root.to_string(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for MixinView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
if !self.name.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
}
if !self.root.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.root) as u64;
}
size += self.__buffa_unknown_fields.encoded_len() as u64;
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.name.is_empty() {
::buffa::types::put_string_field(1u32, &self.name, buf);
}
if !self.root.is_empty() {
::buffa::types::put_string_field(2u32, &self.root, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'a> ::buffa::MessageName for MixinView<'a> {
const PACKAGE: &'static str = "google.protobuf";
const NAME: &'static str = "Mixin";
const FULL_NAME: &'static str = "google.protobuf.Mixin";
const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Mixin";
}
::buffa::impl_default_view_instance!(MixinView);
::buffa::impl_view_reborrow!(MixinView);
#[derive(Clone, Debug)]
pub struct MixinOwnedView(::buffa::OwnedView<MixinView<'static>>);
impl MixinOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(MixinOwnedView(::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(
MixinOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Mixin,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(MixinOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &MixinView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Mixin {
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) -> &'_ str {
self.0.reborrow().name
}
#[must_use]
pub fn root(&self) -> &'_ str {
self.0.reborrow().root
}
}
impl ::core::convert::From<::buffa::OwnedView<MixinView<'static>>> for MixinOwnedView {
fn from(inner: ::buffa::OwnedView<MixinView<'static>>) -> Self {
MixinOwnedView(inner)
}
}
impl ::core::convert::From<MixinOwnedView> for ::buffa::OwnedView<MixinView<'static>> {
fn from(wrapper: MixinOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<MixinView<'static>>> for MixinOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<MixinView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Mixin {
type View<'a> = MixinView<'a>;
type ViewHandle = MixinOwnedView;
}
#[cfg(feature = "reflect")]
const _: () = {
impl<'a> ::buffa_descriptor::reflect::ReflectMessage for MixinView<'a> {
fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
super::super::__buffa::reflect::descriptor_pool()
.message(Self::__buffa_reflect_message_index())
}
fn pool(
&self,
) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
super::super::__buffa::reflect::descriptor_pool()
}
fn get(
&self,
field: &::buffa_descriptor::FieldDescriptor,
) -> ::buffa_descriptor::reflect::ValueRef<'_> {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
match field.number() {
1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
2u32 => ::buffa_descriptor::reflect::ValueRef::String(self.root),
_ => {
::core::debug_assert!(
false,
"field number {} is not a member of this view's reflect get()",
field.number(),
);
::buffa_descriptor::reflect::ValueRef::Bool(false)
}
}
}
fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
match field.number() {
1u32 => !self.name.is_empty(),
2u32 => !self.root.is_empty(),
_ => false,
}
}
fn for_each_set(
&self,
f: &mut dyn ::core::ops::FnMut(
&::buffa_descriptor::FieldDescriptor,
::buffa_descriptor::reflect::ValueRef<'_>,
),
) {
let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
self,
);
for fd in md.fields() {
if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
}
}
}
fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
let bytes = ::buffa::ViewEncode::encode_to_vec(self);
let options = ::buffa::DecodeOptions::new()
.with_element_memory_limit(
bytes
.len()
.saturating_mul(128)
.max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
)
.with_unknown_field_limit(
bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
);
::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
::buffa::alloc::sync::Arc::clone(
super::super::__buffa::reflect::descriptor_pool(),
),
Self::__buffa_reflect_message_index(),
&bytes,
&options,
)
.expect("view re-encodes to bytes decodable against its own descriptor")
}
}
impl<'a> ::buffa_descriptor::reflect::ReflectElement for MixinView<'a> {
fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
::buffa_descriptor::reflect::ValueRef::Message(
::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
)
}
}
impl<'a> MixinView<'a> {
#[doc(hidden)]
fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
*IDX
.get_or_init(|| {
super::super::__buffa::reflect::descriptor_pool()
.message_index(<Self as ::buffa::MessageName>::FULL_NAME)
.expect(
"generated view type is registered in the embedded descriptor pool",
)
})
}
}
};