#[derive(Clone, Debug, Default)]
pub struct CodecErrorView<'a> {
pub error: ::core::option::Option<
super::super::__buffa::view::oneof::codec_error::Error<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecErrorView<'a> {
type Owned = super::super::CodecError;
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)?;
if let Some(
super::super::__buffa::view::oneof::codec_error::Error::BaseEncoding(
ref mut existing,
),
) = view.error
{
::buffa::MessageView::merge_into_view(
&mut **existing,
sub,
__sub_ctx,
)?;
} else {
view.error = Some(
super::super::__buffa::view::oneof::codec_error::Error::BaseEncoding(
::buffa::alloc::boxed::Box::new(
<super::super::__buffa::view::CodecBaseEncodingErrorView 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)?;
if let Some(
super::super::__buffa::view::oneof::codec_error::Error::Pem(
ref mut existing,
),
) = view.error
{
::buffa::MessageView::merge_into_view(
&mut **existing,
sub,
__sub_ctx,
)?;
} else {
view.error = Some(
super::super::__buffa::view::oneof::codec_error::Error::Pem(
::buffa::alloc::boxed::Box::new(
<super::super::__buffa::view::CodecPemErrorView 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)?;
if let Some(
super::super::__buffa::view::oneof::codec_error::Error::Multiformat(
ref mut existing,
),
) = view.error
{
::buffa::MessageView::merge_into_view(
&mut **existing,
sub,
__sub_ctx,
)?;
} else {
view.error = Some(
super::super::__buffa::view::oneof::codec_error::Error::Multiformat(
::buffa::alloc::boxed::Box::new(
<super::super::__buffa::view::CodecMultiformatErrorView 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)?;
if let Some(
super::super::__buffa::view::oneof::codec_error::Error::Canonicalization(
ref mut existing,
),
) = view.error
{
::buffa::MessageView::merge_into_view(
&mut **existing,
sub,
__sub_ctx,
)?;
} else {
view.error = Some(
super::super::__buffa::view::oneof::codec_error::Error::Canonicalization(
::buffa::alloc::boxed::Box::new(
<super::super::__buffa::view::CodecCanonicalizationErrorView 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::CodecError, ::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::CodecError, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecError {
error: match self.error.as_ref() {
::core::option::Option::Some(v) => {
::core::option::Option::Some(
match v {
super::super::__buffa::view::oneof::codec_error::Error::BaseEncoding(
v,
) => {
super::super::__buffa::oneof::codec_error::Error::BaseEncoding(
::buffa::alloc::boxed::Box::new(
v.to_owned_from_source(__buffa_src)?,
),
)
}
super::super::__buffa::view::oneof::codec_error::Error::Pem(
v,
) => {
super::super::__buffa::oneof::codec_error::Error::Pem(
::buffa::alloc::boxed::Box::new(
v.to_owned_from_source(__buffa_src)?,
),
)
}
super::super::__buffa::view::oneof::codec_error::Error::Multiformat(
v,
) => {
super::super::__buffa::oneof::codec_error::Error::Multiformat(
::buffa::alloc::boxed::Box::new(
v.to_owned_from_source(__buffa_src)?,
),
)
}
super::super::__buffa::view::oneof::codec_error::Error::Canonicalization(
v,
) => {
super::super::__buffa::oneof::codec_error::Error::Canonicalization(
::buffa::alloc::boxed::Box::new(
v.to_owned_from_source(__buffa_src)?,
),
)
}
},
)
}
::core::option::Option::None => ::core::option::Option::None,
},
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecErrorView<'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 ::core::option::Option::Some(ref v) = self.error {
match v {
super::super::__buffa::view::oneof::codec_error::Error::BaseEncoding(
x,
) => {
let __slot = __cache.reserve();
let inner = x.compute_size(__cache);
__cache.set(__slot, inner);
size
+= 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
+ inner;
}
super::super::__buffa::view::oneof::codec_error::Error::Pem(x) => {
let __slot = __cache.reserve();
let inner = x.compute_size(__cache);
__cache.set(__slot, inner);
size
+= 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
+ inner;
}
super::super::__buffa::view::oneof::codec_error::Error::Multiformat(
x,
) => {
let __slot = __cache.reserve();
let inner = x.compute_size(__cache);
__cache.set(__slot, inner);
size
+= 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
+ inner;
}
super::super::__buffa::view::oneof::codec_error::Error::Canonicalization(
x,
) => {
let __slot = __cache.reserve();
let inner = x.compute_size(__cache);
__cache.set(__slot, inner);
size
+= 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
+ inner;
}
}
}
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 ::core::option::Option::Some(ref v) = self.error {
match v {
super::super::__buffa::view::oneof::codec_error::Error::BaseEncoding(
x,
) => {
::buffa::types::put_len_delimited_header(
1u32,
__cache.consume_next(),
buf,
);
x.write_to(__cache, buf);
}
super::super::__buffa::view::oneof::codec_error::Error::Pem(x) => {
::buffa::types::put_len_delimited_header(
2u32,
__cache.consume_next(),
buf,
);
x.write_to(__cache, buf);
}
super::super::__buffa::view::oneof::codec_error::Error::Multiformat(
x,
) => {
::buffa::types::put_len_delimited_header(
3u32,
__cache.consume_next(),
buf,
);
x.write_to(__cache, buf);
}
super::super::__buffa::view::oneof::codec_error::Error::Canonicalization(
x,
) => {
::buffa::types::put_len_delimited_header(
4u32,
__cache.consume_next(),
buf,
);
x.write_to(__cache, buf);
}
}
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecErrorView<'__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(ref __ov) = self.error {
match __ov {
super::super::__buffa::view::oneof::codec_error::Error::BaseEncoding(
v,
) => {
__map.serialize_entry("baseEncoding", v)?;
}
super::super::__buffa::view::oneof::codec_error::Error::Pem(v) => {
__map.serialize_entry("pem", v)?;
}
super::super::__buffa::view::oneof::codec_error::Error::Multiformat(
v,
) => {
__map.serialize_entry("multiformat", v)?;
}
super::super::__buffa::view::oneof::codec_error::Error::Canonicalization(
v,
) => {
__map.serialize_entry("canonicalization", v)?;
}
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecErrorView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecError";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecError";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecError";
}
::buffa::impl_default_view_instance!(CodecErrorView);
::buffa::impl_view_reborrow!(CodecErrorView);
#[derive(Clone, Debug)]
pub struct CodecErrorOwnedView(::buffa::OwnedView<CodecErrorView<'static>>);
impl CodecErrorOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecErrorOwnedView(::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(
CodecErrorOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::CodecError,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecErrorOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecErrorView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::CodecError, ::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 error(
&self,
) -> ::core::option::Option<
&super::super::__buffa::view::oneof::codec_error::Error<'_>,
> {
self.0.reborrow().error.as_ref()
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecErrorView<'static>>>
for CodecErrorOwnedView {
fn from(inner: ::buffa::OwnedView<CodecErrorView<'static>>) -> Self {
CodecErrorOwnedView(inner)
}
}
impl ::core::convert::From<CodecErrorOwnedView>
for ::buffa::OwnedView<CodecErrorView<'static>> {
fn from(wrapper: CodecErrorOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecErrorView<'static>>>
for CodecErrorOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecErrorView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecError {
type View<'a> = CodecErrorView<'a>;
type ViewHandle = CodecErrorOwnedView;
}
impl ::serde::Serialize for CodecErrorOwnedView {
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 CodecBaseEncodingErrorView<'a> {
pub reason: ::buffa::EnumValue<super::super::CodecErrorReason>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecBaseEncodingErrorView<'a> {
type Owned = super::super::CodecBaseEncodingError;
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.reason = ::buffa::EnumValue::from(
::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::CodecBaseEncodingError,
::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::CodecBaseEncodingError,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecBaseEncodingError {
reason: self.reason,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecBaseEncodingErrorView<'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;
{
let val = self.reason.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) 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 _;
{
let val = self.reason.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecBaseEncodingErrorView<'__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 !::buffa::json_helpers::skip_if::is_default_enum_value(&self.reason) {
__map.serialize_entry("reason", &self.reason)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecBaseEncodingErrorView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecBaseEncodingError";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecBaseEncodingError";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecBaseEncodingError";
}
::buffa::impl_default_view_instance!(CodecBaseEncodingErrorView);
::buffa::impl_view_reborrow!(CodecBaseEncodingErrorView);
#[derive(Clone, Debug)]
pub struct CodecBaseEncodingErrorOwnedView(
::buffa::OwnedView<CodecBaseEncodingErrorView<'static>>,
);
impl CodecBaseEncodingErrorOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecBaseEncodingErrorOwnedView(::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(
CodecBaseEncodingErrorOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecBaseEncodingError,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecBaseEncodingErrorOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecBaseEncodingErrorView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecBaseEncodingError,
::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 reason(&self) -> ::buffa::EnumValue<super::super::CodecErrorReason> {
self.0.reborrow().reason
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecBaseEncodingErrorView<'static>>>
for CodecBaseEncodingErrorOwnedView {
fn from(inner: ::buffa::OwnedView<CodecBaseEncodingErrorView<'static>>) -> Self {
CodecBaseEncodingErrorOwnedView(inner)
}
}
impl ::core::convert::From<CodecBaseEncodingErrorOwnedView>
for ::buffa::OwnedView<CodecBaseEncodingErrorView<'static>> {
fn from(wrapper: CodecBaseEncodingErrorOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecBaseEncodingErrorView<'static>>>
for CodecBaseEncodingErrorOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecBaseEncodingErrorView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecBaseEncodingError {
type View<'a> = CodecBaseEncodingErrorView<'a>;
type ViewHandle = CodecBaseEncodingErrorOwnedView;
}
impl ::serde::Serialize for CodecBaseEncodingErrorOwnedView {
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 CodecPemErrorView<'a> {
pub reason: ::buffa::EnumValue<super::super::CodecErrorReason>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecPemErrorView<'a> {
type Owned = super::super::CodecPemError;
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.reason = ::buffa::EnumValue::from(
::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::CodecPemError, ::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::CodecPemError, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecPemError {
reason: self.reason,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecPemErrorView<'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;
{
let val = self.reason.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) 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 _;
{
let val = self.reason.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecPemErrorView<'__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 !::buffa::json_helpers::skip_if::is_default_enum_value(&self.reason) {
__map.serialize_entry("reason", &self.reason)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecPemErrorView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecPemError";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecPemError";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecPemError";
}
::buffa::impl_default_view_instance!(CodecPemErrorView);
::buffa::impl_view_reborrow!(CodecPemErrorView);
#[derive(Clone, Debug)]
pub struct CodecPemErrorOwnedView(::buffa::OwnedView<CodecPemErrorView<'static>>);
impl CodecPemErrorOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecPemErrorOwnedView(::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(
CodecPemErrorOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::CodecPemError,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecPemErrorOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecPemErrorView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::CodecPemError, ::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 reason(&self) -> ::buffa::EnumValue<super::super::CodecErrorReason> {
self.0.reborrow().reason
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecPemErrorView<'static>>>
for CodecPemErrorOwnedView {
fn from(inner: ::buffa::OwnedView<CodecPemErrorView<'static>>) -> Self {
CodecPemErrorOwnedView(inner)
}
}
impl ::core::convert::From<CodecPemErrorOwnedView>
for ::buffa::OwnedView<CodecPemErrorView<'static>> {
fn from(wrapper: CodecPemErrorOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecPemErrorView<'static>>>
for CodecPemErrorOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecPemErrorView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecPemError {
type View<'a> = CodecPemErrorView<'a>;
type ViewHandle = CodecPemErrorOwnedView;
}
impl ::serde::Serialize for CodecPemErrorOwnedView {
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 CodecMultiformatErrorView<'a> {
pub reason: ::buffa::EnumValue<super::super::CodecErrorReason>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecMultiformatErrorView<'a> {
type Owned = super::super::CodecMultiformatError;
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.reason = ::buffa::EnumValue::from(
::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::CodecMultiformatError,
::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::CodecMultiformatError,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecMultiformatError {
reason: self.reason,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecMultiformatErrorView<'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;
{
let val = self.reason.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) 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 _;
{
let val = self.reason.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecMultiformatErrorView<'__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 !::buffa::json_helpers::skip_if::is_default_enum_value(&self.reason) {
__map.serialize_entry("reason", &self.reason)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecMultiformatErrorView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecMultiformatError";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecMultiformatError";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecMultiformatError";
}
::buffa::impl_default_view_instance!(CodecMultiformatErrorView);
::buffa::impl_view_reborrow!(CodecMultiformatErrorView);
#[derive(Clone, Debug)]
pub struct CodecMultiformatErrorOwnedView(
::buffa::OwnedView<CodecMultiformatErrorView<'static>>,
);
impl CodecMultiformatErrorOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMultiformatErrorOwnedView(::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(
CodecMultiformatErrorOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecMultiformatError,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMultiformatErrorOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecMultiformatErrorView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecMultiformatError,
::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 reason(&self) -> ::buffa::EnumValue<super::super::CodecErrorReason> {
self.0.reborrow().reason
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecMultiformatErrorView<'static>>>
for CodecMultiformatErrorOwnedView {
fn from(inner: ::buffa::OwnedView<CodecMultiformatErrorView<'static>>) -> Self {
CodecMultiformatErrorOwnedView(inner)
}
}
impl ::core::convert::From<CodecMultiformatErrorOwnedView>
for ::buffa::OwnedView<CodecMultiformatErrorView<'static>> {
fn from(wrapper: CodecMultiformatErrorOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecMultiformatErrorView<'static>>>
for CodecMultiformatErrorOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecMultiformatErrorView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecMultiformatError {
type View<'a> = CodecMultiformatErrorView<'a>;
type ViewHandle = CodecMultiformatErrorOwnedView;
}
impl ::serde::Serialize for CodecMultiformatErrorOwnedView {
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 CodecCanonicalizationErrorView<'a> {
pub reason: ::buffa::EnumValue<super::super::CodecErrorReason>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecCanonicalizationErrorView<'a> {
type Owned = super::super::CodecCanonicalizationError;
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.reason = ::buffa::EnumValue::from(
::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::CodecCanonicalizationError,
::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::CodecCanonicalizationError,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecCanonicalizationError {
reason: self.reason,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecCanonicalizationErrorView<'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;
{
let val = self.reason.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) 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 _;
{
let val = self.reason.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecCanonicalizationErrorView<'__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 !::buffa::json_helpers::skip_if::is_default_enum_value(&self.reason) {
__map.serialize_entry("reason", &self.reason)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecCanonicalizationErrorView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecCanonicalizationError";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecCanonicalizationError";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecCanonicalizationError";
}
::buffa::impl_default_view_instance!(CodecCanonicalizationErrorView);
::buffa::impl_view_reborrow!(CodecCanonicalizationErrorView);
#[derive(Clone, Debug)]
pub struct CodecCanonicalizationErrorOwnedView(
::buffa::OwnedView<CodecCanonicalizationErrorView<'static>>,
);
impl CodecCanonicalizationErrorOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecCanonicalizationErrorOwnedView(::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(
CodecCanonicalizationErrorOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecCanonicalizationError,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecCanonicalizationErrorOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecCanonicalizationErrorView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecCanonicalizationError,
::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 reason(&self) -> ::buffa::EnumValue<super::super::CodecErrorReason> {
self.0.reborrow().reason
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecCanonicalizationErrorView<'static>>>
for CodecCanonicalizationErrorOwnedView {
fn from(inner: ::buffa::OwnedView<CodecCanonicalizationErrorView<'static>>) -> Self {
CodecCanonicalizationErrorOwnedView(inner)
}
}
impl ::core::convert::From<CodecCanonicalizationErrorOwnedView>
for ::buffa::OwnedView<CodecCanonicalizationErrorView<'static>> {
fn from(wrapper: CodecCanonicalizationErrorOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecCanonicalizationErrorView<'static>>>
for CodecCanonicalizationErrorOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecCanonicalizationErrorView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecCanonicalizationError {
type View<'a> = CodecCanonicalizationErrorView<'a>;
type ViewHandle = CodecCanonicalizationErrorOwnedView;
}
impl ::serde::Serialize for CodecCanonicalizationErrorOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}