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/foundational-store/service/v2/service.proto

/// GetRequest specifies the parameters for retrieving values from the store.
/// Used by both Get and GetFirst operations to query the foundational store.
#[derive(Clone, PartialEq, Default)]
pub struct GetRequest {
    /// The block number at which to query the data.
    /// This ensures queries are performed against a specific point in the blockchain history.
    ///
    /// Field 1: `block_number`
    pub block_number: u64,
    /// The block hash for additional verification and fork-awareness.
    /// Ensures the query is performed against the correct block in case of chain forks.
    ///
    /// Field 2: `block_hash`
    pub block_hash: ::buffa::alloc::vec::Vec<u8>,
    /// The keys to retrieve from the store.
    /// For Get: exact key matches are returned.
    /// For GetFirst: the first key \>= each requested key is returned (lexicographically).
    ///
    /// Field 3: `keys`
    pub keys: ::buffa::alloc::vec::Vec<super::super::model::v2::Key>,
}
impl ::core::fmt::Debug for GetRequest {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("GetRequest")
            .field("block_number", &self.block_number)
            .field("block_hash", &self.block_hash)
            .field("keys", &self.keys)
            .finish()
    }
}
impl GetRequest {
    /// 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.foundational_store.service.v2.GetRequest";
}
::buffa::impl_default_instance!(GetRequest);
impl ::buffa::MessageName for GetRequest {
    const PACKAGE: &'static str = "sf.substreams.foundational_store.service.v2";
    const NAME: &'static str = "GetRequest";
    const FULL_NAME: &'static str = "sf.substreams.foundational_store.service.v2.GetRequest";
    const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.foundational_store.service.v2.GetRequest";
}
impl ::buffa::Message for GetRequest {
    /// 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.block_number != 0u64 {
            size += 1u64 + ::buffa::types::uint64_encoded_len(self.block_number) as u64;
        }
        if !self.block_hash.is_empty() {
            size += 1u64 + ::buffa::types::bytes_encoded_len(&self.block_hash) as u64;
        }
        for v in &self.keys {
            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)
    }
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::EncodeSink,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        if self.block_number != 0u64 {
            ::buffa::types::put_uint64_field(1u32, self.block_number, buf);
        }
        if !self.block_hash.is_empty() {
            ::buffa::types::put_shared_bytes_field(2u32, &self.block_hash, buf);
        }
        for v in &self.keys {
            ::buffa::types::put_len_delimited_header(
                3u32,
                u64::from(__cache.consume_next()),
                buf,
            );
            v.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::Varint,
                )?;
                self.block_number = ::buffa::types::decode_uint64(buf)?;
            }
            2u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::types::merge_bytes(&mut self.block_hash, buf)?;
            }
            3u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                let mut elem = ::core::default::Default::default();
                ctx.register_element_memory(
                    ::buffa::__private::element_footprint(&elem),
                )?;
                ::buffa::Message::merge_length_delimited(&mut elem, buf, ctx)?;
                self.keys.push(elem);
            }
            _ => {
                ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.block_number = 0u64;
        self.block_hash.clear();
        self.keys.clear();
    }
}
/// GetResponse contains the results of a store query operation.
/// Provides batch results for multiple keys with consistent block-level metadata.
#[derive(Clone, PartialEq, Default)]
pub struct GetResponse {
    /// Indicates whether the requested block has been processed by the store.
    /// When false, some entries may not be available even if they should exist.
    ///
    /// Field 1: `block_reached`
    pub block_reached: bool,
    /// The query results for each requested key.
    /// Each entry corresponds to one of the keys in the request, in the same order.
    ///
    /// Field 2: `entries`
    pub entries: ::buffa::MessageField<
        super::super::model::v2::QueriedEntries,
        ::buffa::Inline<super::super::model::v2::QueriedEntries>,
    >,
}
impl ::core::fmt::Debug for GetResponse {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("GetResponse")
            .field("block_reached", &self.block_reached)
            .field("entries", &self.entries)
            .finish()
    }
}
impl GetResponse {
    /// 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.foundational_store.service.v2.GetResponse";
}
::buffa::impl_default_instance!(GetResponse);
impl ::buffa::MessageName for GetResponse {
    const PACKAGE: &'static str = "sf.substreams.foundational_store.service.v2";
    const NAME: &'static str = "GetResponse";
    const FULL_NAME: &'static str = "sf.substreams.foundational_store.service.v2.GetResponse";
    const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.foundational_store.service.v2.GetResponse";
}
impl ::buffa::Message for GetResponse {
    /// 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.block_reached {
            size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
        }
        if self.entries.is_set() {
            let __slot = __cache.reserve();
            let inner_size = self.entries.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.block_reached {
            ::buffa::types::put_bool_field(1u32, self.block_reached, buf);
        }
        if self.entries.is_set() {
            ::buffa::types::put_len_delimited_header(
                2u32,
                u64::from(__cache.consume_next()),
                buf,
            );
            self.entries.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::Varint,
                )?;
                self.block_reached = ::buffa::types::decode_bool(buf)?;
            }
            2u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::Message::merge_length_delimited(
                    self.entries.get_or_insert_default(),
                    buf,
                    ctx,
                )?;
            }
            _ => {
                ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.block_reached = false;
        self.entries = ::buffa::MessageField::none();
    }
}