mirror of
https://github.com/minio/minio-rs.git
synced 2026-01-22 15:42:10 +08:00
Rename some exposed types (#96)
This commit is contained in:
parent
b0d31e1126
commit
1d917a8b7a
@ -18,7 +18,7 @@ use http::Method;
|
|||||||
use crate::s3::{
|
use crate::s3::{
|
||||||
client::Client,
|
client::Client,
|
||||||
error::Error,
|
error::Error,
|
||||||
response::GetObjectResponse2,
|
response::GetObjectResponse,
|
||||||
sse::{Sse, SseCustomerKey},
|
sse::{Sse, SseCustomerKey},
|
||||||
types::{S3Api, S3Request, ToS3Request},
|
types::{S3Api, S3Request, ToS3Request},
|
||||||
utils::{check_bucket_name, merge, to_http_header_value, Multimap, UtcTime},
|
utils::{check_bucket_name, merge, to_http_header_value, Multimap, UtcTime},
|
||||||
@ -214,5 +214,5 @@ impl ToS3Request for GetObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl S3Api for GetObject {
|
impl S3Api for GetObject {
|
||||||
type S3Response = GetObjectResponse2;
|
type S3Response = GetObjectResponse;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -740,7 +740,8 @@ impl ListObjects {
|
|||||||
self
|
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 {
|
pub fn include_versions(mut self, include_versions: bool) -> Self {
|
||||||
self.include_versions = include_versions;
|
self.include_versions = include_versions;
|
||||||
self
|
self
|
||||||
|
|||||||
@ -26,7 +26,7 @@ use tokio_stream::iter as stream_iter;
|
|||||||
use crate::s3::{
|
use crate::s3::{
|
||||||
client_core::ClientCore,
|
client_core::ClientCore,
|
||||||
error::Error,
|
error::Error,
|
||||||
response::{RemoveObjectResponse2, RemoveObjectsResponse},
|
response::{RemoveObjectResponse, RemoveObjectsResponse},
|
||||||
types::{S3Api, S3Request, ToS3Request, ToStream},
|
types::{S3Api, S3Request, ToS3Request, ToStream},
|
||||||
utils::{check_bucket_name, md5sum_hash, merge, Multimap},
|
utils::{check_bucket_name, md5sum_hash, merge, Multimap},
|
||||||
Client,
|
Client,
|
||||||
@ -127,7 +127,7 @@ impl RemoveObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl S3Api for RemoveObject {
|
impl S3Api for RemoveObject {
|
||||||
type S3Response = RemoveObjectResponse2;
|
type S3Response = RemoveObjectResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToS3Request for RemoveObject {
|
impl ToS3Request for RemoveObject {
|
||||||
|
|||||||
@ -20,6 +20,7 @@ use super::{
|
|||||||
Client,
|
Client,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// ClientCore exposes lower-level APIs not exposed by the high-level client.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ClientCore(Client);
|
pub struct ClientCore(Client);
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ mod put_object;
|
|||||||
mod remove_objects;
|
mod remove_objects;
|
||||||
|
|
||||||
pub use buckets::{GetBucketVersioningResponse, ListBucketsResponse};
|
pub use buckets::{GetBucketVersioningResponse, ListBucketsResponse};
|
||||||
pub use get_object::GetObjectResponse2;
|
pub use get_object::GetObjectResponse;
|
||||||
pub use list_objects::{
|
pub use list_objects::{
|
||||||
ListObjectVersionsResponse, ListObjectsResponse, ListObjectsV1Response, ListObjectsV2Response,
|
ListObjectVersionsResponse, ListObjectsResponse, ListObjectsV1Response, ListObjectsV2Response,
|
||||||
};
|
};
|
||||||
@ -49,9 +49,7 @@ pub use put_object::{
|
|||||||
CreateMultipartUploadResponse2, PutObjectContentResponse, PutObjectResponse,
|
CreateMultipartUploadResponse2, PutObjectContentResponse, PutObjectResponse,
|
||||||
UploadPartResponse2,
|
UploadPartResponse2,
|
||||||
};
|
};
|
||||||
pub use remove_objects::{
|
pub use remove_objects::{DeleteError, DeletedObject, RemoveObjectResponse, RemoveObjectsResponse};
|
||||||
DeleteError, DeletedObject, RemoveObjectResponse2, RemoveObjectsResponse,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Base response for bucket operation
|
/// Base response for bucket operation
|
||||||
@ -77,9 +75,6 @@ pub struct ObjectResponse {
|
|||||||
pub version_id: Option<String>,
|
pub version_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Response of [remove_object()](crate::s3::client::Client::remove_object) API
|
|
||||||
pub type RemoveObjectResponse = ObjectResponse;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Base Upload ID response
|
/// Base Upload ID response
|
||||||
pub struct UploadIdResponse {
|
pub struct UploadIdResponse {
|
||||||
|
|||||||
@ -22,7 +22,7 @@ use crate::s3::{
|
|||||||
types::{FromS3Response, S3Request},
|
types::{FromS3Response, S3Request},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct GetObjectResponse2 {
|
pub struct GetObjectResponse {
|
||||||
pub headers: http::HeaderMap,
|
pub headers: http::HeaderMap,
|
||||||
pub region: String,
|
pub region: String,
|
||||||
pub bucket_name: String,
|
pub bucket_name: String,
|
||||||
@ -34,7 +34,7 @@ pub struct GetObjectResponse2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl FromS3Response for GetObjectResponse2 {
|
impl FromS3Response for GetObjectResponse {
|
||||||
async fn from_s3response<'a>(
|
async fn from_s3response<'a>(
|
||||||
req: S3Request<'a>,
|
req: S3Request<'a>,
|
||||||
response: reqwest::Response,
|
response: reqwest::Response,
|
||||||
@ -57,7 +57,7 @@ impl FromS3Response for GetObjectResponse2 {
|
|||||||
|
|
||||||
let content = ObjectContent::new_from_stream(body, Some(content_length));
|
let content = ObjectContent::new_from_stream(body, Some(content_length));
|
||||||
|
|
||||||
Ok(GetObjectResponse2 {
|
Ok(GetObjectResponse {
|
||||||
headers: header_map,
|
headers: header_map,
|
||||||
region: req.region.unwrap_or("").to_string(),
|
region: req.region.unwrap_or("").to_string(),
|
||||||
bucket_name: req.bucket.unwrap().to_string(),
|
bucket_name: req.bucket.unwrap().to_string(),
|
||||||
|
|||||||
@ -27,7 +27,7 @@ use crate::s3::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct RemoveObjectResponse2 {
|
pub struct RemoveObjectResponse {
|
||||||
pub headers: HeaderMap,
|
pub headers: HeaderMap,
|
||||||
/// Value of the `x-amz-delete-marker` header.
|
/// Value of the `x-amz-delete-marker` header.
|
||||||
pub is_delete_marker: bool,
|
pub is_delete_marker: bool,
|
||||||
@ -37,7 +37,7 @@ pub struct RemoveObjectResponse2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl FromS3Response for RemoveObjectResponse2 {
|
impl FromS3Response for RemoveObjectResponse {
|
||||||
async fn from_s3response<'a>(
|
async fn from_s3response<'a>(
|
||||||
_req: S3Request<'a>,
|
_req: S3Request<'a>,
|
||||||
resp: reqwest::Response,
|
resp: reqwest::Response,
|
||||||
@ -52,7 +52,7 @@ impl FromS3Response for RemoveObjectResponse2 {
|
|||||||
.get("x-amz-version-id")
|
.get("x-amz-version-id")
|
||||||
.map(|v| v.to_str().unwrap().to_string());
|
.map(|v| v.to_str().unwrap().to_string());
|
||||||
|
|
||||||
Ok(RemoveObjectResponse2 {
|
Ok(RemoveObjectResponse {
|
||||||
headers,
|
headers,
|
||||||
is_delete_marker,
|
is_delete_marker,
|
||||||
version_id,
|
version_id,
|
||||||
@ -79,7 +79,7 @@ pub struct DeletedObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Response of
|
/// 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
|
/// S3 API. It is also returned by the
|
||||||
/// [remove_objects()](crate::s3::client::Client::remove_objects) API in the
|
/// [remove_objects()](crate::s3::client::Client::remove_objects) API in the
|
||||||
/// form of a stream.
|
/// form of a stream.
|
||||||
@ -89,12 +89,22 @@ pub struct RemoveObjectsResponse {
|
|||||||
pub result: Vec<DeleteResult>,
|
pub result: Vec<DeleteResult>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Result of deleting an object.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum DeleteResult {
|
pub enum DeleteResult {
|
||||||
Deleted(DeletedObject),
|
Deleted(DeletedObject),
|
||||||
Error(DeleteError),
|
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 {
|
impl DeleteResult {
|
||||||
pub fn is_deleted(&self) -> bool {
|
pub fn is_deleted(&self) -> bool {
|
||||||
matches!(self, DeleteResult::Deleted(_))
|
matches!(self, DeleteResult::Deleted(_))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user