use std::error;
use std::future::Future;
pub mod jsonl;
pub mod mem;
pub use jsonl::{JsonlStore, JsonlStoreError};
pub use mem::MemStore;
pub trait Store<R>: Send {
type Error: error::Error + Send + Sync + 'static;
type Segment<'a>: Segment<R, Error = Self::Error> + Send
where
Self: 'a;
fn append(
&mut self,
window: i64,
records: Vec<R>,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn oldest(
&mut self,
after: Option<i64>,
) -> impl Future<Output = Result<Option<Self::Segment<'_>>, Self::Error>> + Send;
fn pipeline_hint(&self) -> Option<&str> {
None
}
}
pub trait Segment<R> {
type Error;
fn window(&self) -> i64;
fn records(&mut self) -> impl Future<Output = Result<Vec<R>, Self::Error>> + Send;
fn commit(self) -> impl Future<Output = Result<(), Self::Error>> + Send;
}