use crate::error::Error; use actix_web::web::Bytes; use futures_util::stream::Stream; use std::fmt::Debug; use tokio::io::{AsyncRead, AsyncWrite}; pub(crate) mod file_store; pub(crate) mod object_store; pub(crate) trait Identifier: Send + Sync + Clone + Debug { fn to_bytes(&self) -> Result, Error>; fn from_bytes(bytes: Vec) -> Result where Self: Sized; } #[async_trait::async_trait(?Send)] pub(crate) trait Store: Send + Sync + Clone + Debug + 'static { type Identifier: Identifier; type Stream: Stream>; async fn save_async_read(&self, reader: &mut Reader) -> Result where Reader: AsyncRead + Unpin; async fn save_bytes(&self, bytes: Bytes) -> Result; async fn to_stream( &self, identifier: &Self::Identifier, from_start: Option, len: Option, ) -> Result; async fn read_into( &self, identifier: &Self::Identifier, writer: &mut Writer, ) -> Result<(), std::io::Error> where Writer: AsyncWrite + Send + Unpin; async fn len(&self, identifier: &Self::Identifier) -> Result; async fn remove(&self, identifier: &Self::Identifier) -> Result<(), Error>; }