#[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 CodecMulticodecSpecView<'a> {
pub name: &'a str,
pub code: &'a [u8],
pub prefix: &'a [u8],
pub tag: ::buffa::EnumValue<super::super::CodecTag>,
pub key_material_kind: ::buffa::EnumValue<super::super::CodecKeyMaterialKind>,
pub fixed_length: u32,
pub variable_length: bool,
pub algorithm_name: &'a str,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecMulticodecSpecView<'a> {
type Owned = super::super::CodecMulticodecSpec;
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 = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.code = ::buffa::types::borrow_bytes(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.prefix = ::buffa::types::borrow_bytes(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.tag = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.key_material_kind = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.fixed_length = ::buffa::types::decode_uint32(&mut cur)?;
}
7u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.variable_length = ::buffa::types::decode_bool(&mut cur)?;
}
8u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.algorithm_name = ::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::CodecMulticodecSpec,
::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::CodecMulticodecSpec,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecMulticodecSpec {
name: self.name.to_string(),
code: (self.code).to_vec(),
prefix: (self.prefix).to_vec(),
tag: self.tag,
key_material_kind: self.key_material_kind,
fixed_length: self.fixed_length,
variable_length: self.variable_length,
algorithm_name: self.algorithm_name.to_string(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecMulticodecSpecView<'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.name.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.name) as u32;
}
if !self.code.is_empty() {
size += 1u32 + ::buffa::types::bytes_encoded_len(&self.code) as u32;
}
if !self.prefix.is_empty() {
size += 1u32 + ::buffa::types::bytes_encoded_len(&self.prefix) as u32;
}
{
let val = self.tag.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
{
let val = self.key_material_kind.to_i32();
if val != 0 {
size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
}
}
if self.fixed_length != 0u32 {
size += 1u32 + ::buffa::types::uint32_encoded_len(self.fixed_length) as u32;
}
if self.variable_length {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if !self.algorithm_name.is_empty() {
size
+= 1u32
+ ::buffa::types::string_encoded_len(&self.algorithm_name) 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.name.is_empty() {
::buffa::types::put_string_field(1u32, &self.name, buf);
}
if !self.code.is_empty() {
::buffa::types::put_bytes_field(2u32, &self.code, buf);
}
if !self.prefix.is_empty() {
::buffa::types::put_bytes_field(3u32, &self.prefix, buf);
}
{
let val = self.tag.to_i32();
if val != 0 {
::buffa::types::put_int32_field(4u32, val, buf);
}
}
{
let val = self.key_material_kind.to_i32();
if val != 0 {
::buffa::types::put_int32_field(5u32, val, buf);
}
}
if self.fixed_length != 0u32 {
::buffa::types::put_uint32_field(6u32, self.fixed_length, buf);
}
if self.variable_length {
::buffa::types::put_bool_field(7u32, self.variable_length, buf);
}
if !self.algorithm_name.is_empty() {
::buffa::types::put_string_field(8u32, &self.algorithm_name, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecMulticodecSpecView<'__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_empty_str(self.name) {
__map.serialize_entry("name", self.name)?;
}
if !::buffa::json_helpers::skip_if::is_empty_bytes(self.code) {
__map.serialize_entry("code", &::buffa::json_helpers::BytesJson(self.code))?;
}
if !::buffa::json_helpers::skip_if::is_empty_bytes(self.prefix) {
__map
.serialize_entry(
"prefix",
&::buffa::json_helpers::BytesJson(self.prefix),
)?;
}
if !::buffa::json_helpers::skip_if::is_default_enum_value(&self.tag) {
__map.serialize_entry("tag", &self.tag)?;
}
if !::buffa::json_helpers::skip_if::is_default_enum_value(
&self.key_material_kind,
) {
__map.serialize_entry("keyMaterialKind", &self.key_material_kind)?;
}
if !::buffa::json_helpers::skip_if::is_zero_u32(&self.fixed_length) {
__map
.serialize_entry(
"fixedLength",
&::buffa::json_helpers::ProtoJson(&self.fixed_length),
)?;
}
if self.variable_length {
__map.serialize_entry("variableLength", &self.variable_length)?;
}
if !::buffa::json_helpers::skip_if::is_empty_str(self.algorithm_name) {
__map.serialize_entry("algorithmName", self.algorithm_name)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecMulticodecSpecView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecMulticodecSpec";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecMulticodecSpec";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecMulticodecSpec";
}
::buffa::impl_default_view_instance!(CodecMulticodecSpecView);
::buffa::impl_view_reborrow!(CodecMulticodecSpecView);
#[derive(Clone, Debug)]
pub struct CodecMulticodecSpecOwnedView(
::buffa::OwnedView<CodecMulticodecSpecView<'static>>,
);
impl CodecMulticodecSpecOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMulticodecSpecOwnedView(::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(
CodecMulticodecSpecOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecMulticodecSpec,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMulticodecSpecOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecMulticodecSpecView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecMulticodecSpec,
::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) -> &'_ str {
self.0.reborrow().name
}
#[must_use]
pub fn code(&self) -> &'_ [u8] {
self.0.reborrow().code
}
#[must_use]
pub fn prefix(&self) -> &'_ [u8] {
self.0.reborrow().prefix
}
#[must_use]
pub fn tag(&self) -> ::buffa::EnumValue<super::super::CodecTag> {
self.0.reborrow().tag
}
#[must_use]
pub fn key_material_kind(
&self,
) -> ::buffa::EnumValue<super::super::CodecKeyMaterialKind> {
self.0.reborrow().key_material_kind
}
#[must_use]
pub fn fixed_length(&self) -> u32 {
self.0.reborrow().fixed_length
}
#[must_use]
pub fn variable_length(&self) -> bool {
self.0.reborrow().variable_length
}
#[must_use]
pub fn algorithm_name(&self) -> &'_ str {
self.0.reborrow().algorithm_name
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecMulticodecSpecView<'static>>>
for CodecMulticodecSpecOwnedView {
fn from(inner: ::buffa::OwnedView<CodecMulticodecSpecView<'static>>) -> Self {
CodecMulticodecSpecOwnedView(inner)
}
}
impl ::core::convert::From<CodecMulticodecSpecOwnedView>
for ::buffa::OwnedView<CodecMulticodecSpecView<'static>> {
fn from(wrapper: CodecMulticodecSpecOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecMulticodecSpecView<'static>>>
for CodecMulticodecSpecOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecMulticodecSpecView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecMulticodecSpec {
type View<'a> = CodecMulticodecSpecView<'a>;
type ViewHandle = CodecMulticodecSpecOwnedView;
}
impl ::serde::Serialize for CodecMulticodecSpecOwnedView {
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 CodecMulticodecLookupResultView<'a> {
pub name: &'a str,
pub prefix_length: u32,
pub metadata: ::buffa::MessageFieldView<
super::super::__buffa::view::CodecMulticodecSpecView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecMulticodecLookupResultView<'a> {
type Owned = super::super::CodecMulticodecLookupResult;
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 = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.prefix_length = ::buffa::types::decode_uint32(&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.metadata.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.metadata = ::buffa::MessageFieldView::set(
<super::super::__buffa::view::CodecMulticodecSpecView 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::CodecMulticodecLookupResult,
::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::CodecMulticodecLookupResult,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecMulticodecLookupResult {
name: self.name.to_string(),
prefix_length: self.prefix_length,
metadata: match self.metadata.as_option() {
Some(v) => {
::buffa::MessageField::<
super::super::CodecMulticodecSpec,
>::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 CodecMulticodecLookupResultView<'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.name.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.name) as u32;
}
if self.prefix_length != 0u32 {
size += 1u32 + ::buffa::types::uint32_encoded_len(self.prefix_length) as u32;
}
if self.metadata.is_set() {
let __slot = __cache.reserve();
let inner_size = self.metadata.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 !self.name.is_empty() {
::buffa::types::put_string_field(1u32, &self.name, buf);
}
if self.prefix_length != 0u32 {
::buffa::types::put_uint32_field(2u32, self.prefix_length, buf);
}
if self.metadata.is_set() {
::buffa::types::put_len_delimited_header(3u32, __cache.consume_next(), buf);
self.metadata.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecMulticodecLookupResultView<'__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_empty_str(self.name) {
__map.serialize_entry("name", self.name)?;
}
if !::buffa::json_helpers::skip_if::is_zero_u32(&self.prefix_length) {
__map
.serialize_entry(
"prefixLength",
&::buffa::json_helpers::ProtoJson(&self.prefix_length),
)?;
}
{
if let ::core::option::Option::Some(__v) = self.metadata.as_option() {
__map.serialize_entry("metadata", __v)?;
}
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecMulticodecLookupResultView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecMulticodecLookupResult";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecMulticodecLookupResult";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecMulticodecLookupResult";
}
::buffa::impl_default_view_instance!(CodecMulticodecLookupResultView);
::buffa::impl_view_reborrow!(CodecMulticodecLookupResultView);
#[derive(Clone, Debug)]
pub struct CodecMulticodecLookupResultOwnedView(
::buffa::OwnedView<CodecMulticodecLookupResultView<'static>>,
);
impl CodecMulticodecLookupResultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMulticodecLookupResultOwnedView(::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(
CodecMulticodecLookupResultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecMulticodecLookupResult,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMulticodecLookupResultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecMulticodecLookupResultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecMulticodecLookupResult,
::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) -> &'_ str {
self.0.reborrow().name
}
#[must_use]
pub fn prefix_length(&self) -> u32 {
self.0.reborrow().prefix_length
}
#[must_use]
pub fn metadata(
&self,
) -> &::buffa::MessageFieldView<
super::super::__buffa::view::CodecMulticodecSpecView<'_>,
> {
&self.0.reborrow().metadata
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecMulticodecLookupResultView<'static>>>
for CodecMulticodecLookupResultOwnedView {
fn from(
inner: ::buffa::OwnedView<CodecMulticodecLookupResultView<'static>>,
) -> Self {
CodecMulticodecLookupResultOwnedView(inner)
}
}
impl ::core::convert::From<CodecMulticodecLookupResultOwnedView>
for ::buffa::OwnedView<CodecMulticodecLookupResultView<'static>> {
fn from(wrapper: CodecMulticodecLookupResultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecMulticodecLookupResultView<'static>>>
for CodecMulticodecLookupResultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecMulticodecLookupResultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecMulticodecLookupResult {
type View<'a> = CodecMulticodecLookupResultView<'a>;
type ViewHandle = CodecMulticodecLookupResultOwnedView;
}
impl ::serde::Serialize for CodecMulticodecLookupResultOwnedView {
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 CodecMulticodecTableResultView<'a> {
pub entries: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::CodecMulticodecSpecView<'a>,
>,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecMulticodecTableResultView<'a> {
type Owned = super::super::CodecMulticodecTableResult;
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.entries
.push(
<super::super::__buffa::view::CodecMulticodecSpecView 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::CodecMulticodecTableResult,
::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::CodecMulticodecTableResult,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecMulticodecTableResult {
entries: self
.entries
.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 CodecMulticodecTableResultView<'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.entries {
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.entries {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecMulticodecTableResultView<'__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.entries.is_empty() {
__map.serialize_entry("entries", &*self.entries)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecMulticodecTableResultView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecMulticodecTableResult";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecMulticodecTableResult";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecMulticodecTableResult";
}
::buffa::impl_default_view_instance!(CodecMulticodecTableResultView);
::buffa::impl_view_reborrow!(CodecMulticodecTableResultView);
#[derive(Clone, Debug)]
pub struct CodecMulticodecTableResultOwnedView(
::buffa::OwnedView<CodecMulticodecTableResultView<'static>>,
);
impl CodecMulticodecTableResultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMulticodecTableResultOwnedView(::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(
CodecMulticodecTableResultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecMulticodecTableResult,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMulticodecTableResultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecMulticodecTableResultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecMulticodecTableResult,
::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 entries(
&self,
) -> &::buffa::RepeatedView<
'_,
super::super::__buffa::view::CodecMulticodecSpecView<'_>,
> {
&self.0.reborrow().entries
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecMulticodecTableResultView<'static>>>
for CodecMulticodecTableResultOwnedView {
fn from(inner: ::buffa::OwnedView<CodecMulticodecTableResultView<'static>>) -> Self {
CodecMulticodecTableResultOwnedView(inner)
}
}
impl ::core::convert::From<CodecMulticodecTableResultOwnedView>
for ::buffa::OwnedView<CodecMulticodecTableResultView<'static>> {
fn from(wrapper: CodecMulticodecTableResultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecMulticodecTableResultView<'static>>>
for CodecMulticodecTableResultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecMulticodecTableResultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecMulticodecTableResult {
type View<'a> = CodecMulticodecTableResultView<'a>;
type ViewHandle = CodecMulticodecTableResultOwnedView;
}
impl ::serde::Serialize for CodecMulticodecTableResultOwnedView {
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 CodecMultikeyParseResultView<'a> {
pub codec_name: &'a str,
pub algorithm_name: &'a str,
pub public_key: &'a [u8],
pub expected_public_key_length: u32,
pub variable_public_key_length: bool,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecMultikeyParseResultView<'a> {
type Owned = super::super::CodecMultikeyParseResult;
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.codec_name = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.algorithm_name = ::buffa::types::borrow_str(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.public_key = ::buffa::types::borrow_bytes(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.expected_public_key_length = ::buffa::types::decode_uint32(
&mut cur,
)?;
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.variable_public_key_length = ::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::CodecMultikeyParseResult,
::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::CodecMultikeyParseResult,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecMultikeyParseResult {
codec_name: self.codec_name.to_string(),
algorithm_name: self.algorithm_name.to_string(),
public_key: (self.public_key).to_vec(),
expected_public_key_length: self.expected_public_key_length,
variable_public_key_length: self.variable_public_key_length,
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecMultikeyParseResultView<'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.codec_name.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.codec_name) as u32;
}
if !self.algorithm_name.is_empty() {
size
+= 1u32
+ ::buffa::types::string_encoded_len(&self.algorithm_name) as u32;
}
if !self.public_key.is_empty() {
size += 1u32 + ::buffa::types::bytes_encoded_len(&self.public_key) as u32;
}
if self.expected_public_key_length != 0u32 {
size
+= 1u32
+ ::buffa::types::uint32_encoded_len(self.expected_public_key_length)
as u32;
}
if self.variable_public_key_length {
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 !self.codec_name.is_empty() {
::buffa::types::put_string_field(1u32, &self.codec_name, buf);
}
if !self.algorithm_name.is_empty() {
::buffa::types::put_string_field(2u32, &self.algorithm_name, buf);
}
if !self.public_key.is_empty() {
::buffa::types::put_bytes_field(3u32, &self.public_key, buf);
}
if self.expected_public_key_length != 0u32 {
::buffa::types::put_uint32_field(4u32, self.expected_public_key_length, buf);
}
if self.variable_public_key_length {
::buffa::types::put_bool_field(5u32, self.variable_public_key_length, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecMultikeyParseResultView<'__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_empty_str(self.codec_name) {
__map.serialize_entry("codecName", self.codec_name)?;
}
if !::buffa::json_helpers::skip_if::is_empty_str(self.algorithm_name) {
__map.serialize_entry("algorithmName", self.algorithm_name)?;
}
if !::buffa::json_helpers::skip_if::is_empty_bytes(self.public_key) {
__map
.serialize_entry(
"publicKey",
&::buffa::json_helpers::BytesJson(self.public_key),
)?;
}
if !::buffa::json_helpers::skip_if::is_zero_u32(
&self.expected_public_key_length,
) {
__map
.serialize_entry(
"expectedPublicKeyLength",
&::buffa::json_helpers::ProtoJson(&self.expected_public_key_length),
)?;
}
if self.variable_public_key_length {
__map
.serialize_entry(
"variablePublicKeyLength",
&self.variable_public_key_length,
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecMultikeyParseResultView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecMultikeyParseResult";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecMultikeyParseResult";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecMultikeyParseResult";
}
::buffa::impl_default_view_instance!(CodecMultikeyParseResultView);
::buffa::impl_view_reborrow!(CodecMultikeyParseResultView);
#[derive(Clone, Debug)]
pub struct CodecMultikeyParseResultOwnedView(
::buffa::OwnedView<CodecMultikeyParseResultView<'static>>,
);
impl CodecMultikeyParseResultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMultikeyParseResultOwnedView(::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(
CodecMultikeyParseResultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecMultikeyParseResult,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecMultikeyParseResultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecMultikeyParseResultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecMultikeyParseResult,
::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 codec_name(&self) -> &'_ str {
self.0.reborrow().codec_name
}
#[must_use]
pub fn algorithm_name(&self) -> &'_ str {
self.0.reborrow().algorithm_name
}
#[must_use]
pub fn public_key(&self) -> &'_ [u8] {
self.0.reborrow().public_key
}
#[must_use]
pub fn expected_public_key_length(&self) -> u32 {
self.0.reborrow().expected_public_key_length
}
#[must_use]
pub fn variable_public_key_length(&self) -> bool {
self.0.reborrow().variable_public_key_length
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecMultikeyParseResultView<'static>>>
for CodecMultikeyParseResultOwnedView {
fn from(inner: ::buffa::OwnedView<CodecMultikeyParseResultView<'static>>) -> Self {
CodecMultikeyParseResultOwnedView(inner)
}
}
impl ::core::convert::From<CodecMultikeyParseResultOwnedView>
for ::buffa::OwnedView<CodecMultikeyParseResultView<'static>> {
fn from(wrapper: CodecMultikeyParseResultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecMultikeyParseResultView<'static>>>
for CodecMultikeyParseResultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecMultikeyParseResultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecMultikeyParseResult {
type View<'a> = CodecMultikeyParseResultView<'a>;
type ViewHandle = CodecMultikeyParseResultOwnedView;
}
impl ::serde::Serialize for CodecMultikeyParseResultOwnedView {
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 CodecDagCborVerifyCidResultView<'a> {
pub valid: bool,
pub expected_cid: &'a str,
pub actual_cid: &'a str,
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecDagCborVerifyCidResultView<'a> {
type Owned = super::super::CodecDagCborVerifyCidResult;
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.valid = ::buffa::types::decode_bool(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.expected_cid = ::buffa::types::borrow_str(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.actual_cid = ::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::CodecDagCborVerifyCidResult,
::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::CodecDagCborVerifyCidResult,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecDagCborVerifyCidResult {
valid: self.valid,
expected_cid: self.expected_cid.to_string(),
actual_cid: self.actual_cid.to_string(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecDagCborVerifyCidResultView<'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.valid {
size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
}
if !self.expected_cid.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.expected_cid) as u32;
}
if !self.actual_cid.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.actual_cid) 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.valid {
::buffa::types::put_bool_field(1u32, self.valid, buf);
}
if !self.expected_cid.is_empty() {
::buffa::types::put_string_field(2u32, &self.expected_cid, buf);
}
if !self.actual_cid.is_empty() {
::buffa::types::put_string_field(3u32, &self.actual_cid, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecDagCborVerifyCidResultView<'__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.valid {
__map.serialize_entry("valid", &self.valid)?;
}
if !::buffa::json_helpers::skip_if::is_empty_str(self.expected_cid) {
__map.serialize_entry("expectedCid", self.expected_cid)?;
}
if !::buffa::json_helpers::skip_if::is_empty_str(self.actual_cid) {
__map.serialize_entry("actualCid", self.actual_cid)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecDagCborVerifyCidResultView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecDagCborVerifyCidResult";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecDagCborVerifyCidResult";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecDagCborVerifyCidResult";
}
::buffa::impl_default_view_instance!(CodecDagCborVerifyCidResultView);
::buffa::impl_view_reborrow!(CodecDagCborVerifyCidResultView);
#[derive(Clone, Debug)]
pub struct CodecDagCborVerifyCidResultOwnedView(
::buffa::OwnedView<CodecDagCborVerifyCidResultView<'static>>,
);
impl CodecDagCborVerifyCidResultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecDagCborVerifyCidResultOwnedView(::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(
CodecDagCborVerifyCidResultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecDagCborVerifyCidResult,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecDagCborVerifyCidResultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecDagCborVerifyCidResultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecDagCborVerifyCidResult,
::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 valid(&self) -> bool {
self.0.reborrow().valid
}
#[must_use]
pub fn expected_cid(&self) -> &'_ str {
self.0.reborrow().expected_cid
}
#[must_use]
pub fn actual_cid(&self) -> &'_ str {
self.0.reborrow().actual_cid
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecDagCborVerifyCidResultView<'static>>>
for CodecDagCborVerifyCidResultOwnedView {
fn from(
inner: ::buffa::OwnedView<CodecDagCborVerifyCidResultView<'static>>,
) -> Self {
CodecDagCborVerifyCidResultOwnedView(inner)
}
}
impl ::core::convert::From<CodecDagCborVerifyCidResultOwnedView>
for ::buffa::OwnedView<CodecDagCborVerifyCidResultView<'static>> {
fn from(wrapper: CodecDagCborVerifyCidResultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecDagCborVerifyCidResultView<'static>>>
for CodecDagCborVerifyCidResultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecDagCborVerifyCidResultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecDagCborVerifyCidResult {
type View<'a> = CodecDagCborVerifyCidResultView<'a>;
type ViewHandle = CodecDagCborVerifyCidResultOwnedView;
}
impl ::serde::Serialize for CodecDagCborVerifyCidResultOwnedView {
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 CodecPemDecodeResultView<'a> {
pub label: &'a str,
pub der: &'a [u8],
pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ::buffa::MessageView<'a> for CodecPemDecodeResultView<'a> {
type Owned = super::super::CodecPemDecodeResult;
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.label = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.der = ::buffa::types::borrow_bytes(&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::CodecPemDecodeResult,
::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::CodecPemDecodeResult,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CodecPemDecodeResult {
label: self.label.to_string(),
der: (self.der).to_vec(),
__buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for CodecPemDecodeResultView<'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.label.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.label) as u32;
}
if !self.der.is_empty() {
size += 1u32 + ::buffa::types::bytes_encoded_len(&self.der) 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.label.is_empty() {
::buffa::types::put_string_field(1u32, &self.label, buf);
}
if !self.der.is_empty() {
::buffa::types::put_bytes_field(2u32, &self.der, buf);
}
self.__buffa_unknown_fields.write_to(buf);
}
}
impl<'__a> ::serde::Serialize for CodecPemDecodeResultView<'__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_empty_str(self.label) {
__map.serialize_entry("label", self.label)?;
}
if !::buffa::json_helpers::skip_if::is_empty_bytes(self.der) {
__map.serialize_entry("der", &::buffa::json_helpers::BytesJson(self.der))?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for CodecPemDecodeResultView<'a> {
const PACKAGE: &'static str = "reallyme.codec.v1";
const NAME: &'static str = "CodecPemDecodeResult";
const FULL_NAME: &'static str = "reallyme.codec.v1.CodecPemDecodeResult";
const TYPE_URL: &'static str = "type.googleapis.com/reallyme.codec.v1.CodecPemDecodeResult";
}
::buffa::impl_default_view_instance!(CodecPemDecodeResultView);
::buffa::impl_view_reborrow!(CodecPemDecodeResultView);
#[derive(Clone, Debug)]
pub struct CodecPemDecodeResultOwnedView(
::buffa::OwnedView<CodecPemDecodeResultView<'static>>,
);
impl CodecPemDecodeResultOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecPemDecodeResultOwnedView(::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(
CodecPemDecodeResultOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CodecPemDecodeResult,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CodecPemDecodeResultOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CodecPemDecodeResultView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CodecPemDecodeResult,
::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 label(&self) -> &'_ str {
self.0.reborrow().label
}
#[must_use]
pub fn der(&self) -> &'_ [u8] {
self.0.reborrow().der
}
}
impl ::core::convert::From<::buffa::OwnedView<CodecPemDecodeResultView<'static>>>
for CodecPemDecodeResultOwnedView {
fn from(inner: ::buffa::OwnedView<CodecPemDecodeResultView<'static>>) -> Self {
CodecPemDecodeResultOwnedView(inner)
}
}
impl ::core::convert::From<CodecPemDecodeResultOwnedView>
for ::buffa::OwnedView<CodecPemDecodeResultView<'static>> {
fn from(wrapper: CodecPemDecodeResultOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CodecPemDecodeResultView<'static>>>
for CodecPemDecodeResultOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CodecPemDecodeResultView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CodecPemDecodeResult {
type View<'a> = CodecPemDecodeResultView<'a>;
type ViewHandle = CodecPemDecodeResultOwnedView;
}
impl ::serde::Serialize for CodecPemDecodeResultOwnedView {
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)
}
}