hdp_primitives/task/datalake/
mod.rs

1use alloy::primitives::U256;
2use anyhow::Result;
3use serde::{Deserialize, Serialize};
4use std::{fmt::Display, str::FromStr};
5
6use self::{compute::Computation, envelope::DatalakeEnvelope};
7
8pub mod block_sampled;
9pub mod compute;
10pub mod datalake_type;
11pub mod envelope;
12pub mod transactions;
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct DatalakeCompute {
16    pub datalake: DatalakeEnvelope,
17    pub compute: Computation,
18}
19
20impl DatalakeCompute {
21    pub fn new(datalake: DatalakeEnvelope, compute: Computation) -> Self {
22        Self { datalake, compute }
23    }
24}
25
26pub trait DatalakeCollection {
27    fn to_index(&self) -> u8;
28    fn serialize(&self) -> Result<Vec<u8>>;
29    fn deserialize(encoded: &[u8]) -> Result<Self>
30    where
31        Self: Sized;
32}
33
34pub trait DatalakeField: FromStr + Display {
35    fn from_index(index: u8) -> Result<Self>
36    where
37        Self: Sized;
38    fn to_index(&self) -> u8;
39    fn decode_field_from_rlp(&self, rlp: &[u8]) -> U256;
40}