substreams 0.8.0-beta

Substreams SDK - A streaming data engine for The Graph - by StreamingFast
Documentation
// @generated by buffa-codegen. DO NOT EDIT.
// source: sf/substreams/v1/clock.proto

/// Clock is a pointer to a block with added timestamp
#[derive(Clone, PartialEq, Default)]
pub struct Clock {
    /// Field 1: `id`
    pub id: ::buffa::alloc::string::String,
    /// Field 2: `number`
    pub number: u64,
    /// Field 3: `timestamp`
    pub timestamp: ::buffa::MessageField<
        ::buffa_types::google::protobuf::Timestamp,
        ::buffa::Inline<::buffa_types::google::protobuf::Timestamp>,
    >,
}
impl ::core::fmt::Debug for Clock {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("Clock")
            .field("id", &self.id)
            .field("number", &self.number)
            .field("timestamp", &self.timestamp)
            .finish()
    }
}
impl Clock {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.Clock";
}
::buffa::impl_default_instance!(Clock);
impl ::buffa::MessageName for Clock {
    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";
}
impl ::buffa::Message for Clock {
    /// Returns the total encoded size in bytes.
    ///
    /// Accumulates in `u64` (which cannot overflow for in-memory
    /// data) and saturates to `u32` at return, so a message whose
    /// encoded size exceeds the 2 GiB protobuf limit yields a value
    /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry
    /// points reject, never a silently wrapped size.
    #[allow(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)
    }
    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);
        }
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        ctx: ::buffa::DecodeContext<'_>,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        match tag.field_number() {
            1u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::types::merge_string(&mut self.id, buf)?;
            }
            2u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::Varint,
                )?;
                self.number = ::buffa::types::decode_uint64(buf)?;
            }
            3u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::Message::merge_length_delimited(
                    self.timestamp.get_or_insert_default(),
                    buf,
                    ctx,
                )?;
            }
            _ => {
                ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.id.clear();
        self.number = 0u64;
        self.timestamp = ::buffa::MessageField::none();
    }
}
/// BlockRef is a pointer to a block to which we don't know the timestamp
#[derive(Clone, PartialEq, Default)]
pub struct BlockRef {
    /// Field 1: `id`
    pub id: ::buffa::alloc::string::String,
    /// Field 2: `number`
    pub number: u64,
}
impl ::core::fmt::Debug for BlockRef {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("BlockRef")
            .field("id", &self.id)
            .field("number", &self.number)
            .finish()
    }
}
impl BlockRef {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.BlockRef";
}
::buffa::impl_default_instance!(BlockRef);
impl ::buffa::MessageName for BlockRef {
    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";
}
impl ::buffa::Message for BlockRef {
    /// Returns the total encoded size in bytes.
    ///
    /// Accumulates in `u64` (which cannot overflow for in-memory
    /// data) and saturates to `u32` at return, so a message whose
    /// encoded size exceeds the 2 GiB protobuf limit yields a value
    /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry
    /// points reject, never a silently wrapped size.
    #[allow(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)
    }
    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);
        }
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        ctx: ::buffa::DecodeContext<'_>,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        match tag.field_number() {
            1u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::types::merge_string(&mut self.id, buf)?;
            }
            2u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::Varint,
                )?;
                self.number = ::buffa::types::decode_uint64(buf)?;
            }
            _ => {
                ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.id.clear();
        self.number = 0u64;
    }
}