#[derive(Clone, Debug, Default)]
pub struct StoreDeltasView<'a> {
pub store_deltas: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::StoreDeltaView<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for StoreDeltasView<'a> {
type Owned = super::super::StoreDeltas;
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 __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(
::core::mem::size_of::<super::super::__buffa::view::StoreDeltaView>(),
)?;
view.store_deltas
.push(
<super::super::__buffa::view::StoreDeltaView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::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::StoreDeltas, ::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::StoreDeltas, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::StoreDeltas {
store_deltas: self
.store_deltas
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for StoreDeltasView<'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.store_deltas {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
+ inner_size as u64;
}
::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.store_deltas {
::buffa::types::put_len_delimited_header(
1u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
}
}
impl<'a> ::buffa::MessageName for StoreDeltasView<'a> {
const PACKAGE: &'static str = "sf.substreams.v1";
const NAME: &'static str = "StoreDeltas";
const FULL_NAME: &'static str = "sf.substreams.v1.StoreDeltas";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.StoreDeltas";
}
::buffa::impl_default_view_instance!(StoreDeltasView);
::buffa::impl_view_reborrow!(StoreDeltasView);
#[derive(Clone, Debug)]
pub struct StoreDeltasOwnedView(::buffa::OwnedView<StoreDeltasView<'static>>);
impl StoreDeltasOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StoreDeltasOwnedView(::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(
StoreDeltasOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::StoreDeltas,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StoreDeltasOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &StoreDeltasView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::StoreDeltas {
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 store_deltas(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::StoreDeltaView<'_>> {
&self.0.reborrow().store_deltas
}
}
impl ::core::convert::From<::buffa::OwnedView<StoreDeltasView<'static>>>
for StoreDeltasOwnedView {
fn from(inner: ::buffa::OwnedView<StoreDeltasView<'static>>) -> Self {
StoreDeltasOwnedView(inner)
}
}
impl ::core::convert::From<StoreDeltasOwnedView>
for ::buffa::OwnedView<StoreDeltasView<'static>> {
fn from(wrapper: StoreDeltasOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<StoreDeltasView<'static>>>
for StoreDeltasOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<StoreDeltasView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::StoreDeltas {
type View<'a> = StoreDeltasView<'a>;
type ViewHandle = StoreDeltasOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct StoreDeltaView<'a> {
pub operation: ::buffa::EnumValue<super::super::store_delta::Operation>,
pub ordinal: u64,
pub key: &'a str,
pub old_value: &'a [u8],
pub new_value: &'a [u8],
}
impl<'a> ::buffa::MessageView<'a> for StoreDeltaView<'a> {
type Owned = super::super::StoreDelta;
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::Varint,
)?;
view.operation = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.ordinal = ::buffa::types::decode_uint64(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.key = ::buffa::types::borrow_str(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.old_value = ::buffa::types::borrow_bytes(&mut cur)?;
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.new_value = ::buffa::types::borrow_bytes(&mut cur)?;
}
_ => {
::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::StoreDelta, ::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::StoreDelta, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::StoreDelta {
operation: self.operation,
ordinal: self.ordinal,
key: self.key.to_string(),
old_value: (self.old_value).to_vec(),
new_value: (self.new_value).to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for StoreDeltaView<'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;
{
let val = self.operation.to_i32();
if val != 0 {
size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
}
}
if self.ordinal != 0u64 {
size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64;
}
if !self.key.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.key) as u64;
}
if !self.old_value.is_empty() {
size += 1u64 + ::buffa::types::bytes_encoded_len(&self.old_value) as u64;
}
if !self.new_value.is_empty() {
size += 1u64 + ::buffa::types::bytes_encoded_len(&self.new_value) 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 _;
{
let val = self.operation.to_i32();
if val != 0 {
::buffa::types::put_int32_field(1u32, val, buf);
}
}
if self.ordinal != 0u64 {
::buffa::types::put_uint64_field(2u32, self.ordinal, buf);
}
if !self.key.is_empty() {
::buffa::types::put_string_field(3u32, &self.key, buf);
}
if !self.old_value.is_empty() {
::buffa::types::put_shared_bytes_field(4u32, &self.old_value, buf);
}
if !self.new_value.is_empty() {
::buffa::types::put_shared_bytes_field(5u32, &self.new_value, buf);
}
}
}
impl<'a> ::buffa::MessageName for StoreDeltaView<'a> {
const PACKAGE: &'static str = "sf.substreams.v1";
const NAME: &'static str = "StoreDelta";
const FULL_NAME: &'static str = "sf.substreams.v1.StoreDelta";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.StoreDelta";
}
::buffa::impl_default_view_instance!(StoreDeltaView);
::buffa::impl_view_reborrow!(StoreDeltaView);
#[derive(Clone, Debug)]
pub struct StoreDeltaOwnedView(::buffa::OwnedView<StoreDeltaView<'static>>);
impl StoreDeltaOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StoreDeltaOwnedView(::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(
StoreDeltaOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::StoreDelta,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
StoreDeltaOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &StoreDeltaView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::StoreDelta {
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 operation(&self) -> ::buffa::EnumValue<super::super::store_delta::Operation> {
self.0.reborrow().operation
}
#[must_use]
pub fn ordinal(&self) -> u64 {
self.0.reborrow().ordinal
}
#[must_use]
pub fn key(&self) -> &'_ str {
self.0.reborrow().key
}
#[must_use]
pub fn old_value(&self) -> &'_ [u8] {
self.0.reborrow().old_value
}
#[must_use]
pub fn new_value(&self) -> &'_ [u8] {
self.0.reborrow().new_value
}
}
impl ::core::convert::From<::buffa::OwnedView<StoreDeltaView<'static>>>
for StoreDeltaOwnedView {
fn from(inner: ::buffa::OwnedView<StoreDeltaView<'static>>) -> Self {
StoreDeltaOwnedView(inner)
}
}
impl ::core::convert::From<StoreDeltaOwnedView>
for ::buffa::OwnedView<StoreDeltaView<'static>> {
fn from(wrapper: StoreDeltaOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<StoreDeltaView<'static>>>
for StoreDeltaOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<StoreDeltaView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::StoreDelta {
type View<'a> = StoreDeltaView<'a>;
type ViewHandle = StoreDeltaOwnedView;
}