1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use async_trait::async_trait;
use std::{
    fmt::Debug,
    ops::{Deref, DerefMut},
};

use crate::{Contract, IndexedBlock, IndexedLog, IndexedTransaction, Result};

pub trait Insertable: Send + Sync + Debug {}

impl Insertable for IndexedBlock {}
impl Insertable for IndexedTransaction {}
impl Insertable for IndexedLog {}
impl Insertable for Contract {}

#[async_trait]
pub trait Storage: 'static + Sized + Send + Sync + Debug + Deref + DerefMut {
    async fn insert_block(&self, block: &IndexedBlock) -> Result<()>;

    async fn insert_transaction(&self, transaction: &IndexedTransaction) -> Result<()>;

    async fn insert_log(&self, log: &IndexedLog) -> Result<()>;

    async fn insert_contract(&self, contract: &Contract) -> Result<()>;
}