29 lines
794 B
Rust
29 lines
794 B
Rust
pub mod filesystem;
|
|
pub mod memory;
|
|
|
|
use async_trait::async_trait;
|
|
use bytes::Bytes;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum SegmentStoreError {
|
|
#[error("segment not found: {0}")]
|
|
NotFound(String),
|
|
#[error("io error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
}
|
|
|
|
pub type SegmentStoreResult<T> = Result<T, SegmentStoreError>;
|
|
|
|
#[async_trait]
|
|
pub trait SegmentStore: Send + Sync {
|
|
async fn write_segment(&self, channel_id: &str, name: &str, data: Bytes)
|
|
-> SegmentStoreResult<()>;
|
|
|
|
async fn read_segment(&self, channel_id: &str, name: &str) -> SegmentStoreResult<Bytes>;
|
|
|
|
async fn list_segments(&self, channel_id: &str) -> SegmentStoreResult<Vec<String>>;
|
|
|
|
async fn delete_segment(&self, channel_id: &str, name: &str) -> SegmentStoreResult<()>;
|
|
}
|