mod file;
pub(crate) mod frame;
mod in_memory;
mod subscription;
pub use file::{Durability, FileEventStore, FileStoreOptions, RecoveryPolicy};
pub use in_memory::InMemoryStore;
pub use subscription::{CatchUpSubscription, SubscriptionCheckpoint};
use crate::{NewEvent, Result, StoredEvent, StreamId};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ExpectedVersion {
Any,
NoStream,
Exact(u64),
}
pub trait EventStore<E: Clone> {
fn append(
&mut self,
stream: &StreamId,
expected: ExpectedVersion,
events: &[NewEvent<E>],
) -> Result<Vec<StoredEvent<E>>>;
fn append_owned(
&mut self,
stream: &StreamId,
expected: ExpectedVersion,
events: Vec<NewEvent<E>>,
) -> Result<Vec<StoredEvent<E>>> {
self.append(stream, expected, &events)
}
fn load_stream(&self, stream: &StreamId, after: Option<u64>) -> Vec<StoredEvent<E>>;
fn load_all(&self, after: Option<u64>, limit: usize) -> Vec<StoredEvent<E>>;
fn stream_version(&self, stream: &StreamId) -> Option<u64>;
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
}