1use async_trait::async_trait;
2use futures::Stream;
3
4use crate::event::StreamEvent;
5use crate::filter::StreamFilter;
6use crate::namespace::Namespace;
7
8#[async_trait]
10pub trait WriteQueueBackend: Send + Sync {
11 async fn publish<N: Namespace>(
12 &self,
13 namespace: &N,
14 payload: &[u8],
15 filter_value: Option<&str>,
16 ) -> crate::Result<()>;
17}
18
19#[async_trait]
21pub trait ReadStreamBackend: Send + Sync {
22 async fn stream_exists<N: Namespace>(&self, namespace: &N) -> crate::Result<bool>;
24
25 async fn create_read_stream<N: Namespace>(
27 &self,
28 namespace: &N,
29 max_event_bytes: u64,
30 ) -> crate::Result<()>;
31
32 async fn publish_to_stream(&self, event: &StreamEvent) -> crate::Result<()>;
34
35 async fn populate_stream(&self, events: &[StreamEvent]) -> crate::Result<()>;
37
38 async fn subscribe_live<N: Namespace>(
40 &self,
41 namespace: &N,
42 filter: Option<&StreamFilter>,
43 ) -> crate::Result<impl Stream<Item = crate::Result<StreamEvent>> + Send>;
44}