#[derive(Clone, Debug, Default)]
pub struct DatabaseChangesLazyView<'a> {
pub table_changes: ::buffa::LazyRepeatedView<
'a,
super::super::__buffa::lazy_view::TableChangeLazyView<'a>,
>,
}
impl<'a> DatabaseChangesLazyView<'a> {
#[doc(hidden)]
pub fn _decode_lazy_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let mut view = Self::default();
view._merge_lazy(buf, ctx)?;
::core::result::Result::Ok(view)
}
#[doc(hidden)]
pub fn _merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur: &'a [u8] = buf;
while !cur.is_empty() {
let tag = ::buffa::encoding::Tag::decode(&mut 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::<&'a [u8]>())?;
view.table_changes.push_bytes(sub, __sub_ctx);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
}
::core::result::Result::Ok(())
}
}
impl<'a> ::buffa::LazyMessageView<'a> for DatabaseChangesLazyView<'a> {
type Owned = super::super::DatabaseChanges;
fn decode_lazy(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::_decode_lazy_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_lazy_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
Self::_decode_lazy_ctx(buf, ctx)
}
fn merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
self._merge_lazy(buf, ctx)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::DatabaseChanges, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
#[allow(unused_imports)]
use ::buffa::MessageView as _;
let __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes> = ::core::option::Option::None;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::DatabaseChanges {
table_changes: {
let mut __out = ::buffa::alloc::vec::Vec::with_capacity(
self.table_changes.len(),
);
for __r in self.table_changes.iter() {
__out.push(__r?.to_owned_message()?);
}
__out
},
..::core::default::Default::default()
})
}
}
impl<'a> DatabaseChangesLazyView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
pub fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
let mut size = 0u64;
for __frag in self.table_changes.raw_elements() {
size
+= 1u64 + ::buffa::encoding::varint_len(__frag.len() as u64) as u64
+ __frag.len() as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
pub fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
for __frag in self.table_changes.raw_elements() {
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(__frag.len() as u64, buf);
buf.put_slice(__frag);
}
}
#[inline]
pub fn encode(&self, buf: &mut impl ::buffa::EncodeSink) {
self.try_encode(buf).unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encode(
&self,
buf: &mut impl ::buffa::EncodeSink,
) -> ::core::result::Result<(), ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
::buffa::checked_encode_size(self.compute_size(&mut __cache))?;
self.write_to(&mut __cache, buf);
::core::result::Result::Ok(())
}
#[inline]
#[must_use]
pub fn encoded_len(&self) -> u32 {
self.try_encoded_len().unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encoded_len(&self) -> ::core::result::Result<u32, ::buffa::EncodeError> {
::buffa::checked_encode_size(self.compute_size(&mut ::buffa::SizeCache::new()))
}
#[inline]
#[must_use]
pub fn encode_to_vec(&self) -> ::buffa::alloc::vec::Vec<u8> {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf
}
pub fn try_encode_to_vec(
&self,
) -> ::core::result::Result<::buffa::alloc::vec::Vec<u8>, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf)
}
#[inline]
#[must_use]
pub fn encode_to_bytes(&self) -> ::buffa::bytes::Bytes {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf.freeze()
}
pub fn try_encode_to_bytes(
&self,
) -> ::core::result::Result<::buffa::bytes::Bytes, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf.freeze())
}
}
impl<'a> ::buffa::MessageName for DatabaseChangesLazyView<'a> {
const PACKAGE: &'static str = "sf.substreams.sink.database.v1";
const NAME: &'static str = "DatabaseChanges";
const FULL_NAME: &'static str = "sf.substreams.sink.database.v1.DatabaseChanges";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.sink.database.v1.DatabaseChanges";
}
#[derive(Clone, Debug, Default)]
pub struct TableChangeLazyView<'a> {
pub table: &'a str,
pub ordinal: u64,
pub operation: ::buffa::EnumValue<super::super::table_change::Operation>,
pub fields: ::buffa::LazyRepeatedView<
'a,
super::super::__buffa::lazy_view::FieldLazyView<'a>,
>,
pub primary_key: ::core::option::Option<
super::super::__buffa::view::oneof::table_change::PrimaryKey<'a>,
>,
}
impl<'a> TableChangeLazyView<'a> {
#[doc(hidden)]
pub fn _decode_lazy_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let mut view = Self::default();
view._merge_lazy(buf, ctx)?;
::core::result::Result::Ok(view)
}
#[doc(hidden)]
pub fn _merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur: &'a [u8] = buf;
while !cur.is_empty() {
let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.table = ::buffa::types::borrow_str(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.ordinal = ::buffa::types::decode_uint64(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.operation = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
5u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
ctx.register_element_memory(::core::mem::size_of::<&'a [u8]>())?;
view.fields.push_bytes(sub, __sub_ctx);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.primary_key = Some(
super::super::__buffa::view::oneof::table_change::PrimaryKey::Pk(
::buffa::types::borrow_str(&mut cur)?,
),
);
}
6u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
if let Some(
super::super::__buffa::view::oneof::table_change::PrimaryKey::CompositePk(
ref mut existing,
),
) = view.primary_key
{
::buffa::MessageView::merge_into_view(
&mut **existing,
sub,
__sub_ctx,
)?;
} else {
view.primary_key = Some(
super::super::__buffa::view::oneof::table_change::PrimaryKey::CompositePk(
::buffa::alloc::boxed::Box::new(
<super::super::__buffa::view::CompositePrimaryKeyView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
),
),
);
}
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
}
::core::result::Result::Ok(())
}
}
impl<'a> ::buffa::LazyMessageView<'a> for TableChangeLazyView<'a> {
type Owned = super::super::TableChange;
fn decode_lazy(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::_decode_lazy_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_lazy_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
Self::_decode_lazy_ctx(buf, ctx)
}
fn merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
self._merge_lazy(buf, ctx)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::TableChange, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
#[allow(unused_imports)]
use ::buffa::MessageView as _;
let __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes> = ::core::option::Option::None;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::TableChange {
table: self.table.to_string(),
ordinal: self.ordinal,
operation: self.operation,
fields: {
let mut __out = ::buffa::alloc::vec::Vec::with_capacity(
self.fields.len(),
);
for __r in self.fields.iter() {
__out.push(__r?.to_owned_message()?);
}
__out
},
primary_key: match self.primary_key.as_ref() {
::core::option::Option::Some(v) => {
::core::option::Option::Some(
match v {
super::super::__buffa::view::oneof::table_change::PrimaryKey::Pk(
v,
) => {
super::super::__buffa::oneof::table_change::PrimaryKey::Pk(
v.to_string(),
)
}
super::super::__buffa::view::oneof::table_change::PrimaryKey::CompositePk(
v,
) => {
super::super::__buffa::oneof::table_change::PrimaryKey::CompositePk(
::buffa::alloc::boxed::Box::new(
v.to_owned_from_source(__buffa_src)?,
),
)
}
},
)
}
::core::option::Option::None => ::core::option::Option::None,
},
..::core::default::Default::default()
})
}
}
impl<'a> TableChangeLazyView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
pub fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
let mut size = 0u64;
if !self.table.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.table) as u64;
}
if let ::core::option::Option::Some(ref v) = self.primary_key {
match v {
super::super::__buffa::view::oneof::table_change::PrimaryKey::Pk(x) => {
size += 1u64 + ::buffa::types::string_encoded_len(x) as u64;
}
super::super::__buffa::view::oneof::table_change::PrimaryKey::CompositePk(
x,
) => {
let __slot = __cache.reserve();
let inner = x.compute_size(__cache);
__cache.set(__slot, inner);
size
+= 1u64 + ::buffa::encoding::varint_len(inner as u64) as u64
+ inner as u64;
}
}
}
if self.ordinal != 0u64 {
size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64;
}
{
let val = self.operation.to_i32();
if val != 0 {
size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
}
}
for __frag in self.fields.raw_elements() {
size
+= 1u64 + ::buffa::encoding::varint_len(__frag.len() as u64) as u64
+ __frag.len() as u64;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
pub fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
if !self.table.is_empty() {
::buffa::types::put_string_field(1u32, &self.table, buf);
}
if let ::core::option::Option::Some(ref v) = self.primary_key {
match v {
super::super::__buffa::view::oneof::table_change::PrimaryKey::Pk(x) => {
::buffa::types::put_string_field(2u32, x, buf);
}
super::super::__buffa::view::oneof::table_change::PrimaryKey::CompositePk(
x,
) => {
::buffa::types::put_len_delimited_header(
6u32,
u64::from(__cache.consume_next()),
buf,
);
x.write_to(__cache, buf);
}
}
}
if self.ordinal != 0u64 {
::buffa::types::put_uint64_field(3u32, self.ordinal, buf);
}
{
let val = self.operation.to_i32();
if val != 0 {
::buffa::types::put_int32_field(4u32, val, buf);
}
}
for __frag in self.fields.raw_elements() {
::buffa::encoding::Tag::new(
5u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(__frag.len() as u64, buf);
buf.put_slice(__frag);
}
}
#[inline]
pub fn encode(&self, buf: &mut impl ::buffa::EncodeSink) {
self.try_encode(buf).unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encode(
&self,
buf: &mut impl ::buffa::EncodeSink,
) -> ::core::result::Result<(), ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
::buffa::checked_encode_size(self.compute_size(&mut __cache))?;
self.write_to(&mut __cache, buf);
::core::result::Result::Ok(())
}
#[inline]
#[must_use]
pub fn encoded_len(&self) -> u32 {
self.try_encoded_len().unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encoded_len(&self) -> ::core::result::Result<u32, ::buffa::EncodeError> {
::buffa::checked_encode_size(self.compute_size(&mut ::buffa::SizeCache::new()))
}
#[inline]
#[must_use]
pub fn encode_to_vec(&self) -> ::buffa::alloc::vec::Vec<u8> {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf
}
pub fn try_encode_to_vec(
&self,
) -> ::core::result::Result<::buffa::alloc::vec::Vec<u8>, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf)
}
#[inline]
#[must_use]
pub fn encode_to_bytes(&self) -> ::buffa::bytes::Bytes {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf.freeze()
}
pub fn try_encode_to_bytes(
&self,
) -> ::core::result::Result<::buffa::bytes::Bytes, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf.freeze())
}
}
impl<'a> ::buffa::MessageName for TableChangeLazyView<'a> {
const PACKAGE: &'static str = "sf.substreams.sink.database.v1";
const NAME: &'static str = "TableChange";
const FULL_NAME: &'static str = "sf.substreams.sink.database.v1.TableChange";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.sink.database.v1.TableChange";
}
#[derive(Clone, Debug, Default)]
pub struct CompositePrimaryKeyLazyView<'a> {
pub keys: ::buffa::MapView<'a, &'a str, &'a str>,
}
impl<'a> CompositePrimaryKeyLazyView<'a> {
#[doc(hidden)]
pub fn _decode_lazy_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let mut view = Self::default();
view._merge_lazy(buf, ctx)?;
::core::result::Result::Ok(view)
}
#[doc(hidden)]
pub fn _merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur: &'a [u8] = buf;
while !cur.is_empty() {
let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?;
let mut entry_cur: &'a [u8] = entry_bytes;
let mut key = "";
let mut val = "";
ctx.register_element_memory(
::buffa::__private::element_footprint(&key)
+ ::buffa::__private::element_footprint(&val),
)?;
while !entry_cur.is_empty() {
let entry_tag = ::buffa::encoding::Tag::decode(&mut entry_cur)?;
match entry_tag.field_number() {
1 => {
::buffa::encoding::check_wire_type(
entry_tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
key = ::buffa::types::borrow_str(&mut entry_cur)?;
}
2 => {
::buffa::encoding::check_wire_type(
entry_tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
val = ::buffa::types::borrow_str(&mut entry_cur)?;
}
_ => {
::buffa::encoding::skip_field_depth(
entry_tag,
&mut entry_cur,
ctx.depth(),
)?;
}
}
}
view.keys.push(key, val);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
}
::core::result::Result::Ok(())
}
}
impl<'a> ::buffa::LazyMessageView<'a> for CompositePrimaryKeyLazyView<'a> {
type Owned = super::super::CompositePrimaryKey;
fn decode_lazy(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::_decode_lazy_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_lazy_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
Self::_decode_lazy_ctx(buf, ctx)
}
fn merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
self._merge_lazy(buf, ctx)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CompositePrimaryKey,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
#[allow(unused_imports)]
use ::buffa::MessageView as _;
let __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes> = ::core::option::Option::None;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::CompositePrimaryKey {
keys: self
.keys
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect(),
..::core::default::Default::default()
})
}
}
impl<'a> CompositePrimaryKeyLazyView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
pub fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
let mut size = 0u64;
#[allow(clippy::for_kv_map)]
for (k, v) in &self.keys {
let entry_size: u64 = 1u64 + ::buffa::types::string_encoded_len(k) as u64
+ 1u64 + ::buffa::types::string_encoded_len(v) as u64;
size += 1u64 + ::buffa::encoding::varint_len(entry_size) as u64 + entry_size;
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
pub fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
for (k, v) in &self.keys {
let entry_size: u64 = 1u64 + ::buffa::types::string_encoded_len(k) as u64
+ 1u64 + ::buffa::types::string_encoded_len(v) as u64;
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(entry_size, buf);
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::types::encode_string(k, buf);
::buffa::encoding::Tag::new(
2u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::types::encode_string(v, buf);
}
}
#[inline]
pub fn encode(&self, buf: &mut impl ::buffa::EncodeSink) {
self.try_encode(buf).unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encode(
&self,
buf: &mut impl ::buffa::EncodeSink,
) -> ::core::result::Result<(), ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
::buffa::checked_encode_size(self.compute_size(&mut __cache))?;
self.write_to(&mut __cache, buf);
::core::result::Result::Ok(())
}
#[inline]
#[must_use]
pub fn encoded_len(&self) -> u32 {
self.try_encoded_len().unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encoded_len(&self) -> ::core::result::Result<u32, ::buffa::EncodeError> {
::buffa::checked_encode_size(self.compute_size(&mut ::buffa::SizeCache::new()))
}
#[inline]
#[must_use]
pub fn encode_to_vec(&self) -> ::buffa::alloc::vec::Vec<u8> {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf
}
pub fn try_encode_to_vec(
&self,
) -> ::core::result::Result<::buffa::alloc::vec::Vec<u8>, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf)
}
#[inline]
#[must_use]
pub fn encode_to_bytes(&self) -> ::buffa::bytes::Bytes {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf.freeze()
}
pub fn try_encode_to_bytes(
&self,
) -> ::core::result::Result<::buffa::bytes::Bytes, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf.freeze())
}
}
impl<'a> ::buffa::MessageName for CompositePrimaryKeyLazyView<'a> {
const PACKAGE: &'static str = "sf.substreams.sink.database.v1";
const NAME: &'static str = "CompositePrimaryKey";
const FULL_NAME: &'static str = "sf.substreams.sink.database.v1.CompositePrimaryKey";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.sink.database.v1.CompositePrimaryKey";
}
#[derive(Clone, Debug, Default)]
pub struct FieldLazyView<'a> {
pub name: &'a str,
pub value: &'a str,
pub update_op: ::buffa::EnumValue<super::super::field::UpdateOp>,
}
impl<'a> FieldLazyView<'a> {
#[doc(hidden)]
pub fn _decode_lazy_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let mut view = Self::default();
view._merge_lazy(buf, ctx)?;
::core::result::Result::Ok(view)
}
#[doc(hidden)]
pub fn _merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur: &'a [u8] = buf;
while !cur.is_empty() {
let tag = ::buffa::encoding::Tag::decode(&mut 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.value = ::buffa::types::borrow_str(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.update_op = ::buffa::EnumValue::from(
::buffa::types::decode_int32(&mut cur)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
}
::core::result::Result::Ok(())
}
}
impl<'a> ::buffa::LazyMessageView<'a> for FieldLazyView<'a> {
type Owned = super::super::Field;
fn decode_lazy(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::_decode_lazy_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
.with_element_memory(&__elem),
)
}
fn decode_lazy_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
Self::_decode_lazy_ctx(buf, ctx)
}
fn merge_lazy(
&mut self,
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<(), ::buffa::DecodeError> {
self._merge_lazy(buf, ctx)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Field, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
#[allow(unused_imports)]
use ::buffa::MessageView as _;
let __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes> = ::core::option::Option::None;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Field {
name: self.name.to_string(),
value: self.value.to_string(),
update_op: self.update_op,
..::core::default::Default::default()
})
}
}
impl<'a> FieldLazyView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
pub fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
let mut size = 0u64;
if !self.name.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
}
if !self.value.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.value) as u64;
}
{
let val = self.update_op.to_i32();
if val != 0 {
size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
}
}
::buffa::saturate_size(size)
}
#[allow(clippy::needless_borrow)]
pub fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
#[allow(unused_imports)]
use ::buffa::ViewEncode as _;
if !self.name.is_empty() {
::buffa::types::put_string_field(1u32, &self.name, buf);
}
if !self.value.is_empty() {
::buffa::types::put_string_field(2u32, &self.value, buf);
}
{
let val = self.update_op.to_i32();
if val != 0 {
::buffa::types::put_int32_field(4u32, val, buf);
}
}
}
#[inline]
pub fn encode(&self, buf: &mut impl ::buffa::EncodeSink) {
self.try_encode(buf).unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encode(
&self,
buf: &mut impl ::buffa::EncodeSink,
) -> ::core::result::Result<(), ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
::buffa::checked_encode_size(self.compute_size(&mut __cache))?;
self.write_to(&mut __cache, buf);
::core::result::Result::Ok(())
}
#[inline]
#[must_use]
pub fn encoded_len(&self) -> u32 {
self.try_encoded_len().unwrap_or_else(|_| ::buffa::encode_size_overflow())
}
pub fn try_encoded_len(&self) -> ::core::result::Result<u32, ::buffa::EncodeError> {
::buffa::checked_encode_size(self.compute_size(&mut ::buffa::SizeCache::new()))
}
#[inline]
#[must_use]
pub fn encode_to_vec(&self) -> ::buffa::alloc::vec::Vec<u8> {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf
}
pub fn try_encode_to_vec(
&self,
) -> ::core::result::Result<::buffa::alloc::vec::Vec<u8>, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::alloc::vec::Vec::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf)
}
#[inline]
#[must_use]
pub fn encode_to_bytes(&self) -> ::buffa::bytes::Bytes {
let mut __cache = ::buffa::SizeCache::new();
let __size = match ::buffa::checked_encode_size(
self.compute_size(&mut __cache),
) {
::core::result::Result::Ok(__size) => __size as usize,
::core::result::Result::Err(_) => ::buffa::encode_size_overflow(),
};
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
__buf.freeze()
}
pub fn try_encode_to_bytes(
&self,
) -> ::core::result::Result<::buffa::bytes::Bytes, ::buffa::EncodeError> {
let mut __cache = ::buffa::SizeCache::new();
let __size = ::buffa::checked_encode_size(self.compute_size(&mut __cache))?
as usize;
let mut __buf = ::buffa::bytes::BytesMut::with_capacity(__size);
self.write_to(&mut __cache, &mut __buf);
::buffa::debug_assert_two_pass(__buf.len(), __size);
::core::result::Result::Ok(__buf.freeze())
}
}
impl<'a> ::buffa::MessageName for FieldLazyView<'a> {
const PACKAGE: &'static str = "sf.substreams.sink.database.v1";
const NAME: &'static str = "Field";
const FULL_NAME: &'static str = "sf.substreams.sink.database.v1.Field";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.sink.database.v1.Field";
}