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/deltas.proto

#[derive(Clone, PartialEq, Default)]
pub struct StoreDeltas {
    /// Field 1: `store_deltas`
    pub store_deltas: ::buffa::alloc::vec::Vec<StoreDelta>,
}
impl ::core::fmt::Debug for StoreDeltas {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("StoreDeltas").field("store_deltas", &self.store_deltas).finish()
    }
}
impl StoreDeltas {
    /// 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.StoreDeltas";
}
::buffa::impl_default_instance!(StoreDeltas);
impl ::buffa::MessageName for StoreDeltas {
    const PACKAGE: &'static str = "sf.substreams.v1";
    const NAME: &'static str = "StoreDeltas";
    const FULL_NAME: &'static str = "sf.substreams.v1.StoreDeltas";
    const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.StoreDeltas";
}
impl ::buffa::Message for StoreDeltas {
    /// 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;
        for v in &self.store_deltas {
            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 _;
        for v in &self.store_deltas {
            ::buffa::types::put_len_delimited_header(
                1u32,
                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::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.store_deltas.push(elem);
            }
            _ => {
                ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.store_deltas.clear();
    }
}
#[derive(Clone, PartialEq, Default)]
pub struct StoreDelta {
    /// Field 1: `operation`
    pub operation: ::buffa::EnumValue<store_delta::Operation>,
    /// Field 2: `ordinal`
    pub ordinal: u64,
    /// Field 3: `key`
    pub key: ::buffa::alloc::string::String,
    /// Field 4: `old_value`
    pub old_value: ::buffa::alloc::vec::Vec<u8>,
    /// Field 5: `new_value`
    pub new_value: ::buffa::alloc::vec::Vec<u8>,
}
impl ::core::fmt::Debug for StoreDelta {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("StoreDelta")
            .field("operation", &self.operation)
            .field("ordinal", &self.ordinal)
            .field("key", &self.key)
            .field("old_value", &self.old_value)
            .field("new_value", &self.new_value)
            .finish()
    }
}
impl StoreDelta {
    /// 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.StoreDelta";
}
::buffa::impl_default_instance!(StoreDelta);
impl ::buffa::MessageName for StoreDelta {
    const PACKAGE: &'static str = "sf.substreams.v1";
    const NAME: &'static str = "StoreDelta";
    const FULL_NAME: &'static str = "sf.substreams.v1.StoreDelta";
    const TYPE_URL: &'static str = "type.googleapis.com/sf.substreams.v1.StoreDelta";
}
impl ::buffa::Message for StoreDelta {
    /// 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;
        {
            let val = self.operation.to_i32();
            if val != 0 {
                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
            }
        }
        if self.ordinal != 0u64 {
            size += 1u64 + ::buffa::types::uint64_encoded_len(self.ordinal) as u64;
        }
        if !self.key.is_empty() {
            size += 1u64 + ::buffa::types::string_encoded_len(&self.key) as u64;
        }
        if !self.old_value.is_empty() {
            size += 1u64 + ::buffa::types::bytes_encoded_len(&self.old_value) as u64;
        }
        if !self.new_value.is_empty() {
            size += 1u64 + ::buffa::types::bytes_encoded_len(&self.new_value) 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 _;
        {
            let val = self.operation.to_i32();
            if val != 0 {
                ::buffa::types::put_int32_field(1u32, val, buf);
            }
        }
        if self.ordinal != 0u64 {
            ::buffa::types::put_uint64_field(2u32, self.ordinal, buf);
        }
        if !self.key.is_empty() {
            ::buffa::types::put_string_field(3u32, &self.key, buf);
        }
        if !self.old_value.is_empty() {
            ::buffa::types::put_shared_bytes_field(4u32, &self.old_value, buf);
        }
        if !self.new_value.is_empty() {
            ::buffa::types::put_shared_bytes_field(5u32, &self.new_value, 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.operation = ::buffa::EnumValue::from(
                    ::buffa::types::decode_int32(buf)?,
                );
            }
            2u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::Varint,
                )?;
                self.ordinal = ::buffa::types::decode_uint64(buf)?;
            }
            3u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::types::merge_string(&mut self.key, buf)?;
            }
            4u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::types::merge_bytes(&mut self.old_value, buf)?;
            }
            5u32 => {
                ::buffa::encoding::check_wire_type(
                    tag,
                    ::buffa::encoding::WireType::LengthDelimited,
                )?;
                ::buffa::types::merge_bytes(&mut self.new_value, buf)?;
            }
            _ => {
                ::buffa::encoding::skip_field_depth(tag, buf, ctx.depth())?;
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.operation = ::buffa::EnumValue::from(0);
        self.ordinal = 0u64;
        self.key.clear();
        self.old_value.clear();
        self.new_value.clear();
    }
}
pub mod store_delta {
    #[allow(unused_imports)]
    use super::*;
    #[allow(non_camel_case_types)]
    #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
    #[repr(i32)]
    pub enum Operation {
        UNSET = 0i32,
        CREATE = 1i32,
        UPDATE = 2i32,
        DELETE = 3i32,
    }
    impl Operation {
        ///Idiomatic alias for [`Self::UNSET`]; `Debug` prints the variant name.
        #[allow(non_upper_case_globals)]
        pub const Unset: Self = Self::UNSET;
        ///Idiomatic alias for [`Self::CREATE`]; `Debug` prints the variant name.
        #[allow(non_upper_case_globals)]
        pub const Create: Self = Self::CREATE;
        ///Idiomatic alias for [`Self::UPDATE`]; `Debug` prints the variant name.
        #[allow(non_upper_case_globals)]
        pub const Update: Self = Self::UPDATE;
        ///Idiomatic alias for [`Self::DELETE`]; `Debug` prints the variant name.
        #[allow(non_upper_case_globals)]
        pub const Delete: Self = Self::DELETE;
    }
    impl ::core::default::Default for Operation {
        fn default() -> Self {
            Self::UNSET
        }
    }
    impl ::buffa::Enumeration for Operation {
        fn from_i32(value: i32) -> ::core::option::Option<Self> {
            match value {
                0i32 => ::core::option::Option::Some(Self::UNSET),
                1i32 => ::core::option::Option::Some(Self::CREATE),
                2i32 => ::core::option::Option::Some(Self::UPDATE),
                3i32 => ::core::option::Option::Some(Self::DELETE),
                _ => ::core::option::Option::None,
            }
        }
        fn to_i32(&self) -> i32 {
            *self as i32
        }
        fn proto_name(&self) -> &'static str {
            match self {
                Self::UNSET => "UNSET",
                Self::CREATE => "CREATE",
                Self::UPDATE => "UPDATE",
                Self::DELETE => "DELETE",
            }
        }
        fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
            match name {
                "UNSET" => ::core::option::Option::Some(Self::UNSET),
                "CREATE" => ::core::option::Option::Some(Self::CREATE),
                "UPDATE" => ::core::option::Option::Some(Self::UPDATE),
                "DELETE" => ::core::option::Option::Some(Self::DELETE),
                _ => ::core::option::Option::None,
            }
        }
        fn values() -> &'static [Self] {
            &[Self::UNSET, Self::CREATE, Self::UPDATE, Self::DELETE]
        }
    }
}