use super::*; use async_trait::async_trait; use hyper::Body; use std::fmt::Debug; /// ObjectApiLayer is an abstract API to an S3-like object store. /// implementing this trait allows to extend the composable API's. #[async_trait] pub trait ObjectApiLayer: Debug + Send + Sync { async fn list_objects(&self, params: ListObjectsParams) -> ApiResult; async fn get_object(&self, params: GetObjectParams) -> ApiResult; async fn put_object(&self, params: PutObjectParams) -> ApiResult; async fn delete_object(&self, params: DeleteObjectParams) -> ApiResult; // TODO: multipart upload // async fn initiate_multipart_upload(&self, params: InitiateMultipartUploadParams) -> ApiResult; // async fn complete_multipart_upload(&self, params: CompleteMultipartUploadParams) -> ApiResult; // async fn put_upload_part(&self, params: PutUploadPartParams) -> ApiResult; // async fn list_upload_parts(&self, params: ListUploadPartsParams) -> ApiResult; // TODO: batch object operations (see http://docs.aws.amazon.com/AmazonS3/latest/API/batch-ops-deleting-objects.html) // async fn get_objects(&self, params: GetObjectsParams) -> ApiResult; // async fn put_objects(&self, params: PutObjectsParams) -> ApiResult; // async fn delete_objects(&self, params: DeleteObjectsParams) -> ApiResult; // TODO: versioning // async fn list_object_versions(&self, params: ListObjectsParams) -> ApiResult; } #[derive(Debug, Clone)] pub struct ObjectInfo { pub bucket: String, pub key: String, pub version_id: String, pub size: u64, pub last_modified: String, pub etag: String, pub storage_class: String, pub owner: UserInfo, } #[derive(Debug, Clone)] pub struct ObjectRange { pub start: Option, pub end: Option, } #[derive(Debug, Clone)] pub struct AuthInfo { pub access_key: String, pub secret_key: String, pub owner: UserInfo, } #[derive(Debug, Clone)] pub struct MetaParams { pub bucket: String, // can be empty pub key: String, // can be empty pub auth: Option, } #[derive(Debug, Clone)] pub struct ListObjectsParams { pub meta: MetaParams, pub bucket: String, pub prefix: String, pub delimiter: String, pub marker: String, pub max_keys: i32, pub encoding_type: String, // TODO: list objects v2 // pub start_after: String, } #[derive(Debug, Clone)] pub struct ListObjectsReply { pub bucket: String, pub prefix: String, pub delimiter: String, pub marker: String, pub max_keys: i32, pub encoding_type: String, // TODO: list objects v2 // pub start_after: String, pub is_truncated: bool, pub next_marker: String, pub objects: Vec, pub common_prefixes: Vec, } #[derive(Debug, Clone)] pub struct GetObjectParams { pub bucket: String, pub key: String, pub version_id: String, // partial reads pub head_only: bool, // = HTTP HEAD method - no body should be returned pub range: ObjectRange, // TODO: conditional reads (e.g. if-match, if-none-match) ? // pub if_modified_since: Option