use async_trait::async_trait;
use crate::entry::traits::{AsEncodedEntry, AsEntry};
use crate::entry::SeqNum;
use crate::entry::{EncodedEntry, Entry as P2pandaEntry, LogId};
use crate::hash::Hash;
use crate::identity::PublicKey;
use crate::operation::EncodedOperation;
use crate::schema::SchemaId;
use crate::storage_provider::error::EntryStorageError;
#[async_trait]
pub trait EntryStore {
type Entry: AsEntry + AsEncodedEntry + Clone;
async fn insert_entry(
&self,
entry: &P2pandaEntry,
encoded_entry: &EncodedEntry,
encoded_operation: Option<&EncodedOperation>,
) -> Result<(), EntryStorageError>;
async fn get_entry_at_seq_num(
&self,
public_key: &PublicKey,
log_id: &LogId,
seq_num: &SeqNum,
) -> Result<Option<Self::Entry>, EntryStorageError>;
async fn get_entry(&self, hash: &Hash) -> Result<Option<Self::Entry>, EntryStorageError>;
async fn get_latest_entry(
&self,
public_key: &PublicKey,
log_id: &LogId,
) -> Result<Option<Self::Entry>, EntryStorageError>;
async fn get_entries_by_schema(
&self,
schema: &SchemaId,
) -> Result<Vec<Self::Entry>, EntryStorageError>;
async fn get_paginated_log_entries(
&self,
public_key: &PublicKey,
log_id: &LogId,
seq_num: &SeqNum,
max_number_of_entries: usize,
) -> Result<Vec<Self::Entry>, EntryStorageError>;
async fn get_certificate_pool(
&self,
author_id: &PublicKey,
log_id: &LogId,
seq_num: &SeqNum,
) -> Result<Vec<Self::Entry>, EntryStorageError>;
}