use s3s::dto::*; use s3s::s3_error; use s3s::S3Result; use s3s::S3; use s3s::{S3Request, S3Response}; use crate::store::ECStore; #[async_trait::async_trait] impl S3 for ECStore { #[tracing::instrument] async fn create_bucket( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = CreateBucketOutput::default(); // TODO: handle other fields Ok(S3Response::new(output)) } #[tracing::instrument] async fn copy_object( &self, req: S3Request, ) -> S3Result> { let input = req.input; let (bucket, key) = match input.copy_source { CopySource::AccessPoint { .. } => return Err(s3_error!(NotImplemented)), CopySource::Bucket { ref bucket, ref key, .. } => (bucket, key), }; let output = CopyObjectOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn delete_bucket( &self, req: S3Request, ) -> S3Result> { let input = req.input; Ok(S3Response::new(DeleteBucketOutput {})) } #[tracing::instrument] async fn delete_object( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = DeleteObjectOutput::default(); // TODO: handle other fields Ok(S3Response::new(output)) } #[tracing::instrument] async fn delete_objects( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = DeleteObjectsOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn get_bucket_location( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = GetBucketLocationOutput::default(); Ok(S3Response::new(output)) } #[tracing::instrument] async fn get_object( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = GetObjectOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn head_bucket( &self, req: S3Request, ) -> S3Result> { let input = req.input; Ok(S3Response::new(HeadBucketOutput::default())) } #[tracing::instrument] async fn head_object( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = HeadObjectOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn list_buckets( &self, _: S3Request, ) -> S3Result> { let output = ListBucketsOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn list_objects( &self, req: S3Request, ) -> S3Result> { let v2_resp = self.list_objects_v2(req.map_input(Into::into)).await?; Ok(v2_resp.map_output(|v2| ListObjectsOutput { contents: v2.contents, delimiter: v2.delimiter, encoding_type: v2.encoding_type, name: v2.name, prefix: v2.prefix, max_keys: v2.max_keys, ..Default::default() })) } #[tracing::instrument] async fn list_objects_v2( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = ListObjectsV2Output { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn put_object( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = PutObjectOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn create_multipart_upload( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = CreateMultipartUploadOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn upload_part( &self, req: S3Request, ) -> S3Result> { let UploadPartInput { body, upload_id, part_number, .. } = req.input; let output = UploadPartOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn upload_part_copy( &self, req: S3Request, ) -> S3Result> { let input = req.input; let output = UploadPartCopyOutput { ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn list_parts( &self, req: S3Request, ) -> S3Result> { let ListPartsInput { bucket, key, upload_id, .. } = req.input; let output = ListPartsOutput { bucket: Some(bucket), key: Some(key), upload_id: Some(upload_id), ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn complete_multipart_upload( &self, req: S3Request, ) -> S3Result> { let CompleteMultipartUploadInput { multipart_upload, bucket, key, upload_id, .. } = req.input; let output = CompleteMultipartUploadOutput { bucket: Some(bucket), key: Some(key), ..Default::default() }; Ok(S3Response::new(output)) } #[tracing::instrument] async fn abort_multipart_upload( &self, req: S3Request, ) -> S3Result> { Ok(S3Response::new(AbortMultipartUploadOutput { ..Default::default() })) } }