#[derive(Clone, Debug, Default)]
pub struct KeysView<'a> {
pub keys: ::buffa::RepeatedView<'a, &'a str>,
}
impl<'a> ::buffa::MessageView<'a> for KeysView<'a> {
type Owned = super::super::Keys;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
#[inline]
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __elem = ::buffa::types::borrow_str(&mut cur)?;
ctx.register_element_memory(
::buffa::__private::element_footprint(&__elem),
)?;
view.keys.push(__elem);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Keys, ::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::Keys, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Keys {
keys: self.keys.iter().map(|s| s.to_string()).collect(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for KeysView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u64;
for v in &self.keys {
size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.keys {
::buffa::types::put_string_field(1u32, v, buf);
}
}
}
impl<'a> ::buffa::MessageName for KeysView<'a> {
const PACKAGE: &'static str = "sf.substreams.index.v1";
const NAME: &'static str = "Keys";
const FULL_NAME: &'static str = "sf.substreams.index.v1.Keys";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.index.v1.Keys";
}
::buffa::impl_default_view_instance!(KeysView);
::buffa::impl_view_reborrow!(KeysView);
#[derive(Clone, Debug)]
pub struct KeysOwnedView(::buffa::OwnedView<KeysView<'static>>);
impl KeysOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(KeysOwnedView(::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(
KeysOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Keys,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(KeysOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &KeysView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Keys {
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 keys(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
&self.0.reborrow().keys
}
}
impl ::core::convert::From<::buffa::OwnedView<KeysView<'static>>> for KeysOwnedView {
fn from(inner: ::buffa::OwnedView<KeysView<'static>>) -> Self {
KeysOwnedView(inner)
}
}
impl ::core::convert::From<KeysOwnedView> for ::buffa::OwnedView<KeysView<'static>> {
fn from(wrapper: KeysOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<KeysView<'static>>> for KeysOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<KeysView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Keys {
type View<'a> = KeysView<'a>;
type ViewHandle = KeysOwnedView;
}