use crate::error::StorageError; use myfsio_common::types::*; use std::collections::HashMap; use std::path::PathBuf; use std::pin::Pin; use tokio::io::AsyncRead; pub type StorageResult = Result; pub type AsyncReadStream = Pin>; #[allow(async_fn_in_trait)] pub trait StorageEngine: Send + Sync { async fn list_buckets(&self) -> StorageResult>; async fn create_bucket(&self, name: &str) -> StorageResult<()>; async fn delete_bucket(&self, name: &str) -> StorageResult<()>; async fn bucket_exists(&self, name: &str) -> StorageResult; async fn bucket_stats(&self, name: &str) -> StorageResult; async fn put_object( &self, bucket: &str, key: &str, stream: AsyncReadStream, metadata: Option>, ) -> StorageResult; async fn get_object( &self, bucket: &str, key: &str, ) -> StorageResult<(ObjectMeta, AsyncReadStream)>; async fn get_object_path(&self, bucket: &str, key: &str) -> StorageResult; async fn head_object(&self, bucket: &str, key: &str) -> StorageResult; async fn get_object_version( &self, bucket: &str, key: &str, version_id: &str, ) -> StorageResult<(ObjectMeta, AsyncReadStream)>; async fn get_object_version_path( &self, bucket: &str, key: &str, version_id: &str, ) -> StorageResult; async fn head_object_version( &self, bucket: &str, key: &str, version_id: &str, ) -> StorageResult; async fn get_object_version_metadata( &self, bucket: &str, key: &str, version_id: &str, ) -> StorageResult>; async fn delete_object(&self, bucket: &str, key: &str) -> StorageResult<()>; async fn delete_object_version( &self, bucket: &str, key: &str, version_id: &str, ) -> StorageResult<()>; async fn copy_object( &self, src_bucket: &str, src_key: &str, dst_bucket: &str, dst_key: &str, ) -> StorageResult; async fn get_object_metadata( &self, bucket: &str, key: &str, ) -> StorageResult>; async fn put_object_metadata( &self, bucket: &str, key: &str, metadata: &HashMap, ) -> StorageResult<()>; async fn list_objects( &self, bucket: &str, params: &ListParams, ) -> StorageResult; async fn list_objects_shallow( &self, bucket: &str, params: &ShallowListParams, ) -> StorageResult; async fn initiate_multipart( &self, bucket: &str, key: &str, metadata: Option>, ) -> StorageResult; async fn upload_part( &self, bucket: &str, upload_id: &str, part_number: u32, stream: AsyncReadStream, ) -> StorageResult; async fn upload_part_copy( &self, bucket: &str, upload_id: &str, part_number: u32, src_bucket: &str, src_key: &str, range: Option<(u64, u64)>, ) -> StorageResult<(String, chrono::DateTime)>; async fn complete_multipart( &self, bucket: &str, upload_id: &str, parts: &[PartInfo], ) -> StorageResult; async fn abort_multipart(&self, bucket: &str, upload_id: &str) -> StorageResult<()>; async fn list_parts(&self, bucket: &str, upload_id: &str) -> StorageResult>; async fn list_multipart_uploads(&self, bucket: &str) -> StorageResult>; async fn get_bucket_config(&self, bucket: &str) -> StorageResult; async fn set_bucket_config(&self, bucket: &str, config: &BucketConfig) -> StorageResult<()>; async fn is_versioning_enabled(&self, bucket: &str) -> StorageResult; async fn set_versioning(&self, bucket: &str, enabled: bool) -> StorageResult<()>; async fn list_object_versions( &self, bucket: &str, key: &str, ) -> StorageResult>; async fn list_bucket_object_versions( &self, bucket: &str, prefix: Option<&str>, ) -> StorageResult>; async fn get_object_tags(&self, bucket: &str, key: &str) -> StorageResult>; async fn set_object_tags(&self, bucket: &str, key: &str, tags: &[Tag]) -> StorageResult<()>; async fn delete_object_tags(&self, bucket: &str, key: &str) -> StorageResult<()>; }