#[derive(Clone, Debug, Default)]
pub struct ClockView<'a> {
pub id: &'a str,
pub number: u64,
pub timestamp: ::buffa::MessageFieldView<
::buffa_types::google::protobuf::__buffa::view::TimestampView<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for ClockView<'a> {
type Owned = super::super::Clock;
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.id = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.number = ::buffa::types::decode_uint64(&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.timestamp.as_mut() {
Some(existing) => {
::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
}
None => {
view.timestamp = ::buffa::MessageFieldView::set(
<::buffa_types::google::protobuf::__buffa::view::TimestampView 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::Clock, ::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::Clock, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::Clock {
id: self.id.to_string(),
number: self.number,
timestamp: match self.timestamp.as_option() {
Some(v) => {
::buffa::MessageField::<
::buffa_types::google::protobuf::Timestamp,
::buffa::Inline<::buffa_types::google::protobuf::Timestamp>,
>::some(v.to_owned_from_source(__buffa_src)?)
}
None => ::buffa::MessageField::none(),
},
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for ClockView<'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.id.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.id) as u64;
}
if self.number != 0u64 {
size += 1u64 + ::buffa::types::uint64_encoded_len(self.number) as u64;
}
if self.timestamp.is_set() {
let __slot = __cache.reserve();
let inner_size = self.timestamp.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.id.is_empty() {
::buffa::types::put_string_field(1u32, &self.id, buf);
}
if self.number != 0u64 {
::buffa::types::put_uint64_field(2u32, self.number, buf);
}
if self.timestamp.is_set() {
::buffa::types::put_len_delimited_header(
3u32,
u64::from(__cache.consume_next()),
buf,
);
self.timestamp.write_to(__cache, buf);
}
}
}
impl<'a> ::buffa::MessageName for ClockView<'a> {
const PACKAGE: &'static str = "sf.substreams.v1";
const NAME: &'static str = "Clock";
const FULL_NAME: &'static str = "sf.substreams.v1.Clock";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.Clock";
}
::buffa::impl_default_view_instance!(ClockView);
::buffa::impl_view_reborrow!(ClockView);
#[derive(Clone, Debug)]
pub struct ClockOwnedView(::buffa::OwnedView<ClockView<'static>>);
impl ClockOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(ClockOwnedView(::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(
ClockOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::Clock,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(ClockOwnedView(::buffa::OwnedView::from_owned(msg)?))
}
#[must_use]
pub fn view(&self) -> &ClockView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::Clock {
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 id(&self) -> &'_ str {
self.0.reborrow().id
}
#[must_use]
pub fn number(&self) -> u64 {
self.0.reborrow().number
}
#[must_use]
pub fn timestamp(
&self,
) -> &::buffa::MessageFieldView<
::buffa_types::google::protobuf::__buffa::view::TimestampView<'_>,
> {
&self.0.reborrow().timestamp
}
}
impl ::core::convert::From<::buffa::OwnedView<ClockView<'static>>> for ClockOwnedView {
fn from(inner: ::buffa::OwnedView<ClockView<'static>>) -> Self {
ClockOwnedView(inner)
}
}
impl ::core::convert::From<ClockOwnedView> for ::buffa::OwnedView<ClockView<'static>> {
fn from(wrapper: ClockOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<ClockView<'static>>> for ClockOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<ClockView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::Clock {
type View<'a> = ClockView<'a>;
type ViewHandle = ClockOwnedView;
}
#[derive(Clone, Debug, Default)]
pub struct BlockRefView<'a> {
pub id: &'a str,
pub number: u64,
}
impl<'a> ::buffa::MessageView<'a> for BlockRefView<'a> {
type Owned = super::super::BlockRef;
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.id = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.number = ::buffa::types::decode_uint64(&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::BlockRef, ::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::BlockRef, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::BlockRef {
id: self.id.to_string(),
number: self.number,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for BlockRefView<'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.id.is_empty() {
size += 1u64 + ::buffa::types::string_encoded_len(&self.id) as u64;
}
if self.number != 0u64 {
size += 1u64 + ::buffa::types::uint64_encoded_len(self.number) 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.id.is_empty() {
::buffa::types::put_string_field(1u32, &self.id, buf);
}
if self.number != 0u64 {
::buffa::types::put_uint64_field(2u32, self.number, buf);
}
}
}
impl<'a> ::buffa::MessageName for BlockRefView<'a> {
const PACKAGE: &'static str = "sf.substreams.v1";
const NAME: &'static str = "BlockRef";
const FULL_NAME: &'static str = "sf.substreams.v1.BlockRef";
const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.BlockRef";
}
::buffa::impl_default_view_instance!(BlockRefView);
::buffa::impl_view_reborrow!(BlockRefView);
#[derive(Clone, Debug)]
pub struct BlockRefOwnedView(::buffa::OwnedView<BlockRefView<'static>>);
impl BlockRefOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(BlockRefOwnedView(::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(
BlockRefOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::BlockRef,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
BlockRefOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &BlockRefView<'_> {
self.0.reborrow()
}
#[must_use]
pub fn to_owned_message(&self) -> super::super::BlockRef {
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 id(&self) -> &'_ str {
self.0.reborrow().id
}
#[must_use]
pub fn number(&self) -> u64 {
self.0.reborrow().number
}
}
impl ::core::convert::From<::buffa::OwnedView<BlockRefView<'static>>>
for BlockRefOwnedView {
fn from(inner: ::buffa::OwnedView<BlockRefView<'static>>) -> Self {
BlockRefOwnedView(inner)
}
}
impl ::core::convert::From<BlockRefOwnedView>
for ::buffa::OwnedView<BlockRefView<'static>> {
fn from(wrapper: BlockRefOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<BlockRefView<'static>>>
for BlockRefOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<BlockRefView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::BlockRef {
type View<'a> = BlockRefView<'a>;
type ViewHandle = BlockRefOwnedView;
}