#[derive(Clone, Debug, Default)]
pub struct DatabaseChangesView<'a> {
pub table_changes: ::buffa::RepeatedView<
'a,
super::super::__buffa::view::TableChangeView<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for DatabaseChangesView<'a> {
type Owned = super::super::DatabaseChanges;
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::TableChangeView,
>(),
)?;
view.table_changes
.push(
<super::super::__buffa::view::TableChangeView 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::DatabaseChanges, ::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::DatabaseChanges, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::DatabaseChanges {
table_changes: self
.table_changes
.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 DatabaseChangesView<'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.table_changes {
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.table_changes {
::buffa::types::put_len_delimited_header(
1u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
}
}
impl<'a> ::buffa::MessageName for DatabaseChangesView<'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";
}
::buffa::impl_default_view_instance!(DatabaseChangesView);
::buffa::impl_view_reborrow!(DatabaseChangesView);
#[derive(Clone, Debug)]
pub struct DatabaseChangesOwnedView(::buffa::OwnedView<DatabaseChangesView<'static>>);
impl DatabaseChangesOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DatabaseChangesOwnedView(::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(
DatabaseChangesOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::DatabaseChanges,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
DatabaseChangesOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &DatabaseChangesView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::DatabaseChanges {
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 table_changes(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::TableChangeView<'_>> {
&self.0.reborrow().table_changes
}
}
impl ::core::convert::From<::buffa::OwnedView<DatabaseChangesView<'static>>>
for DatabaseChangesOwnedView {
fn from(inner: ::buffa::OwnedView<DatabaseChangesView<'static>>) -> Self {
DatabaseChangesOwnedView(inner)
}
}
impl ::core::convert::From<DatabaseChangesOwnedView>
for ::buffa::OwnedView<DatabaseChangesView<'static>> {
fn from(wrapper: DatabaseChangesOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<DatabaseChangesView<'static>>>
for DatabaseChangesOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<DatabaseChangesView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::DatabaseChanges {
type View<'a> = DatabaseChangesView<'a>;
type ViewHandle = DatabaseChangesOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct TableChangeView<'a> {
pub table: &'a str,
pub ordinal: u64,
pub operation: ::buffa::EnumValue<super::super::table_change::Operation>,
pub fields: ::buffa::RepeatedView<'a, super::super::__buffa::view::FieldView<'a>>,
pub primary_key: ::core::option::Option<
super::super::__buffa::view::oneof::table_change::PrimaryKey<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for TableChangeView<'a> {
type Owned = super::super::TableChange;
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,
)?;
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::<super::super::__buffa::view::FieldView>(),
)?;
view.fields
.push(
<super::super::__buffa::view::FieldView as ::buffa::MessageView>::decode_view_ctx(
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(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::TableChange, ::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::TableChange, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::TableChange {
table: self.table.to_string(),
ordinal: self.ordinal,
operation: self.operation,
fields: self
.fields
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
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> ::buffa::ViewEncode<'a> for TableChangeView<'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;
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 v in &self.fields {
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 _;
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 v in &self.fields {
::buffa::types::put_len_delimited_header(
5u32,
u64::from(__cache.consume_next()),
buf,
);
v.write_to(__cache, buf);
}
}
}
impl<'a> ::buffa::MessageName for TableChangeView<'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";
}
::buffa::impl_default_view_instance!(TableChangeView);
::buffa::impl_view_reborrow!(TableChangeView);
#[derive(Clone, Debug)]
pub struct TableChangeOwnedView(::buffa::OwnedView<TableChangeView<'static>>);
impl TableChangeOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
TableChangeOwnedView(::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(
TableChangeOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::TableChange,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
TableChangeOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &TableChangeView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::TableChange {
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 table(&self) -> &'_ str {
self.0.reborrow().table
}
#[must_use]
pub fn ordinal(&self) -> u64 {
self.0.reborrow().ordinal
}
#[must_use]
pub fn operation(
&self,
) -> ::buffa::EnumValue<super::super::table_change::Operation> {
self.0.reborrow().operation
}
#[must_use]
pub fn fields(
&self,
) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::FieldView<'_>> {
&self.0.reborrow().fields
}
#[must_use]
pub fn primary_key(
&self,
) -> ::core::option::Option<
&super::super::__buffa::view::oneof::table_change::PrimaryKey<'_>,
> {
self.0.reborrow().primary_key.as_ref()
}
}
impl ::core::convert::From<::buffa::OwnedView<TableChangeView<'static>>>
for TableChangeOwnedView {
fn from(inner: ::buffa::OwnedView<TableChangeView<'static>>) -> Self {
TableChangeOwnedView(inner)
}
}
impl ::core::convert::From<TableChangeOwnedView>
for ::buffa::OwnedView<TableChangeView<'static>> {
fn from(wrapper: TableChangeOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<TableChangeView<'static>>>
for TableChangeOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<TableChangeView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::TableChange {
type View<'a> = TableChangeView<'a>;
type ViewHandle = TableChangeOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct CompositePrimaryKeyView<'a> {
pub keys: ::buffa::MapView<'a, &'a str, &'a str>,
}
impl<'a> ::buffa::MessageView<'a> for CompositePrimaryKeyView<'a> {
type Owned = super::super::CompositePrimaryKey;
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 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(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::CompositePrimaryKey,
::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::CompositePrimaryKey,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
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> ::buffa::ViewEncode<'a> for CompositePrimaryKeyView<'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;
#[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)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration 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);
}
}
}
impl<'a> ::buffa::MessageName for CompositePrimaryKeyView<'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";
}
::buffa::impl_default_view_instance!(CompositePrimaryKeyView);
::buffa::impl_view_reborrow!(CompositePrimaryKeyView);
#[derive(Clone, Debug)]
pub struct CompositePrimaryKeyOwnedView(
::buffa::OwnedView<CompositePrimaryKeyView<'static>>,
);
impl CompositePrimaryKeyOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CompositePrimaryKeyOwnedView(::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(
CompositePrimaryKeyOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::CompositePrimaryKey,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
CompositePrimaryKeyOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &CompositePrimaryKeyView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::CompositePrimaryKey {
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::MapView<'_, &'_ str, &'_ str> {
&self.0.reborrow().keys
}
}
impl ::core::convert::From<::buffa::OwnedView<CompositePrimaryKeyView<'static>>>
for CompositePrimaryKeyOwnedView {
fn from(inner: ::buffa::OwnedView<CompositePrimaryKeyView<'static>>) -> Self {
CompositePrimaryKeyOwnedView(inner)
}
}
impl ::core::convert::From<CompositePrimaryKeyOwnedView>
for ::buffa::OwnedView<CompositePrimaryKeyView<'static>> {
fn from(wrapper: CompositePrimaryKeyOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<CompositePrimaryKeyView<'static>>>
for CompositePrimaryKeyOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<CompositePrimaryKeyView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::CompositePrimaryKey {
type View<'a> = CompositePrimaryKeyView<'a>;
type ViewHandle = CompositePrimaryKeyOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct FieldView<'a> {
pub name: &'a str,
pub value: &'a str,
pub update_op: ::buffa::EnumValue<super::super::field::UpdateOp>,
}
impl<'a> ::buffa::MessageView<'a> for FieldView<'a> {
type Owned = super::super::Field;
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,
)?;
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(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::Field, ::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::Field, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
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> ::buffa::ViewEncode<'a> for FieldView<'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;
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)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::EncodeSink,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration 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);
}
}
}
}
impl<'a> ::buffa::MessageName for FieldView<'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";
}
::buffa::impl_default_view_instance!(FieldView);
::buffa::impl_view_reborrow!(FieldView);
#[derive(Clone, Debug)]
pub struct FieldOwnedView(::buffa::OwnedView<FieldView<'static>>);
impl FieldOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(FieldOwnedView(::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(
FieldOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Field,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(FieldOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &FieldView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Field {
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 value(&self) -> &'_ str {
self.0.reborrow().value
}
#[must_use]
pub fn update_op(&self) -> ::buffa::EnumValue<super::super::field::UpdateOp> {
self.0.reborrow().update_op
}
}
impl ::core::convert::From<::buffa::OwnedView<FieldView<'static>>> for FieldOwnedView {
fn from(inner: ::buffa::OwnedView<FieldView<'static>>) -> Self {
FieldOwnedView(inner)
}
}
impl ::core::convert::From<FieldOwnedView> for ::buffa::OwnedView<FieldView<'static>> {
fn from(wrapper: FieldOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<FieldView<'static>>> for FieldOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<FieldView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Field {
type View<'a> = FieldView<'a>;
type ViewHandle = FieldOwnedView;
}