use crate::event::RecordedEvent;
use crate::event::UnsavedEvent;
use crate::stream::Stream;
use futures::Future;
use uuid::Uuid;
pub trait Storage: std::fmt::Debug + Default + Send + std::marker::Unpin + 'static {
fn storage_name() -> &'static str;
fn create_stream(
&mut self,
stream: Stream,
correlation_id: Uuid,
) -> std::pin::Pin<Box<dyn Future<Output = Result<Stream, StorageError>> + Send>>;
fn delete_stream(
&mut self,
stream: &Stream,
correlation_id: Uuid,
) -> std::pin::Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send>>;
fn append_to_stream(
&mut self,
stream_uud: &str,
events: &[UnsavedEvent],
correlation_id: Uuid,
) -> std::pin::Pin<Box<dyn Future<Output = Result<Vec<Uuid>, StorageError>> + Send>>;
fn read_stream(
&self,
stream_uud: String,
version: usize,
limit: usize,
correlation_id: Uuid,
) -> std::pin::Pin<Box<dyn Future<Output = Result<Vec<RecordedEvent>, StorageError>> + Send>>;
fn read_stream_info(
&mut self,
stream_uuid: String,
correlation_id: Uuid,
) -> std::pin::Pin<Box<dyn Future<Output = Result<Stream, StorageError>> + Send>>;
}
pub mod appender;
pub mod inmemory;
pub mod postgres;
pub mod reader;
#[cfg(test)]
mod test;
#[derive(Debug, PartialEq)]
pub enum StorageError {
StreamDoesntExists,
StreamAlreadyExists,
Unknown,
}