Rename some exposed types (#96)

This commit is contained in:
Aditya Manthramurthy 2024-06-18 13:55:01 -07:00 committed by GitHub
parent b0d31e1126
commit 1d917a8b7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 26 additions and 19 deletions

View File

@ -18,7 +18,7 @@ use http::Method;
use crate::s3::{
client::Client,
error::Error,
response::GetObjectResponse2,
response::GetObjectResponse,
sse::{Sse, SseCustomerKey},
types::{S3Api, S3Request, ToS3Request},
utils::{check_bucket_name, merge, to_http_header_value, Multimap, UtcTime},
@ -214,5 +214,5 @@ impl ToS3Request for GetObject {
}
impl S3Api for GetObject {
type S3Response = GetObjectResponse2;
type S3Response = GetObjectResponse;
}

View File

@ -740,7 +740,8 @@ impl ListObjects {
self
}
/// Set this to include versions.
/// Set this to include versions. Defaults to false. Has no effect when
/// `use_api_v1` is set.
pub fn include_versions(mut self, include_versions: bool) -> Self {
self.include_versions = include_versions;
self

View File

@ -26,7 +26,7 @@ use tokio_stream::iter as stream_iter;
use crate::s3::{
client_core::ClientCore,
error::Error,
response::{RemoveObjectResponse2, RemoveObjectsResponse},
response::{RemoveObjectResponse, RemoveObjectsResponse},
types::{S3Api, S3Request, ToS3Request, ToStream},
utils::{check_bucket_name, md5sum_hash, merge, Multimap},
Client,
@ -127,7 +127,7 @@ impl RemoveObject {
}
impl S3Api for RemoveObject {
type S3Response = RemoveObjectResponse2;
type S3Response = RemoveObjectResponse;
}
impl ToS3Request for RemoveObject {

View File

@ -20,6 +20,7 @@ use super::{
Client,
};
/// ClientCore exposes lower-level APIs not exposed by the high-level client.
#[derive(Debug, Clone)]
pub struct ClientCore(Client);

View File

@ -39,7 +39,7 @@ mod put_object;
mod remove_objects;
pub use buckets::{GetBucketVersioningResponse, ListBucketsResponse};
pub use get_object::GetObjectResponse2;
pub use get_object::GetObjectResponse;
pub use list_objects::{
ListObjectVersionsResponse, ListObjectsResponse, ListObjectsV1Response, ListObjectsV2Response,
};
@ -49,9 +49,7 @@ pub use put_object::{
CreateMultipartUploadResponse2, PutObjectContentResponse, PutObjectResponse,
UploadPartResponse2,
};
pub use remove_objects::{
DeleteError, DeletedObject, RemoveObjectResponse2, RemoveObjectsResponse,
};
pub use remove_objects::{DeleteError, DeletedObject, RemoveObjectResponse, RemoveObjectsResponse};
#[derive(Debug)]
/// Base response for bucket operation
@ -77,9 +75,6 @@ pub struct ObjectResponse {
pub version_id: Option<String>,
}
/// Response of [remove_object()](crate::s3::client::Client::remove_object) API
pub type RemoveObjectResponse = ObjectResponse;
#[derive(Debug)]
/// Base Upload ID response
pub struct UploadIdResponse {

View File

@ -22,7 +22,7 @@ use crate::s3::{
types::{FromS3Response, S3Request},
};
pub struct GetObjectResponse2 {
pub struct GetObjectResponse {
pub headers: http::HeaderMap,
pub region: String,
pub bucket_name: String,
@ -34,7 +34,7 @@ pub struct GetObjectResponse2 {
}
#[async_trait]
impl FromS3Response for GetObjectResponse2 {
impl FromS3Response for GetObjectResponse {
async fn from_s3response<'a>(
req: S3Request<'a>,
response: reqwest::Response,
@ -57,7 +57,7 @@ impl FromS3Response for GetObjectResponse2 {
let content = ObjectContent::new_from_stream(body, Some(content_length));
Ok(GetObjectResponse2 {
Ok(GetObjectResponse {
headers: header_map,
region: req.region.unwrap_or("").to_string(),
bucket_name: req.bucket.unwrap().to_string(),

View File

@ -27,7 +27,7 @@ use crate::s3::{
};
#[derive(Debug, Clone)]
pub struct RemoveObjectResponse2 {
pub struct RemoveObjectResponse {
pub headers: HeaderMap,
/// Value of the `x-amz-delete-marker` header.
pub is_delete_marker: bool,
@ -37,7 +37,7 @@ pub struct RemoveObjectResponse2 {
}
#[async_trait]
impl FromS3Response for RemoveObjectResponse2 {
impl FromS3Response for RemoveObjectResponse {
async fn from_s3response<'a>(
_req: S3Request<'a>,
resp: reqwest::Response,
@ -52,7 +52,7 @@ impl FromS3Response for RemoveObjectResponse2 {
.get("x-amz-version-id")
.map(|v| v.to_str().unwrap().to_string());
Ok(RemoveObjectResponse2 {
Ok(RemoveObjectResponse {
headers,
is_delete_marker,
version_id,
@ -79,7 +79,7 @@ pub struct DeletedObject {
}
/// Response of
/// [remove_objects_api()](crate::s3::client_core::ClientCore::delete_objects)
/// [delete_objects()](crate::s3::client_core::ClientCore::delete_objects)
/// S3 API. It is also returned by the
/// [remove_objects()](crate::s3::client::Client::remove_objects) API in the
/// form of a stream.
@ -89,12 +89,22 @@ pub struct RemoveObjectsResponse {
pub result: Vec<DeleteResult>,
}
/// Result of deleting an object.
#[derive(Clone, Debug)]
pub enum DeleteResult {
Deleted(DeletedObject),
Error(DeleteError),
}
impl From<DeleteResult> for Result<DeletedObject, DeleteError> {
fn from(result: DeleteResult) -> Self {
match result {
DeleteResult::Deleted(obj) => Ok(obj),
DeleteResult::Error(err) => Err(err),
}
}
}
impl DeleteResult {
pub fn is_deleted(&self) -> bool {
matches!(self, DeleteResult::Deleted(_))