mirror of
https://github.com/minio/minio-rs.git
synced 2025-12-06 15:26:51 +08:00
Adopt the typed-builder crate throughout the S3 API to provide compile-time validation of builder patterns. This change improves type safety and developer experience when constructing S3 API requests.
50 lines
2.1 KiB
Rust
50 lines
2.1 KiB
Rust
// MinIO Rust Library for Amazon S3 Compatible Cloud Storage
|
|
// Copyright 2025 MinIO, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use crate::s3::builders::{CreateBucket, CreateBucketBldr};
|
|
use crate::s3::client::MinioClient;
|
|
|
|
impl MinioClient {
|
|
/// Creates a [`CreateBucket`] request builder.
|
|
///
|
|
/// To execute the request, call [`CreateBucket::send()`](crate::s3::types::S3Api::send),
|
|
/// which returns a [`Result`] containing a [`CreateBucketResponse`](crate::s3::response::CreateBucketResponse).
|
|
///
|
|
/// # Example
|
|
///
|
|
/// ```no_run
|
|
/// use minio::s3::MinioClient;
|
|
/// use minio::s3::creds::StaticProvider;
|
|
/// use minio::s3::http::BaseUrl;
|
|
/// use minio::s3::response::CreateBucketResponse;
|
|
/// use minio::s3::types::S3Api;
|
|
/// use minio::s3::response::a_response_traits::{HasBucket, HasRegion};
|
|
///
|
|
/// #[tokio::main]
|
|
/// async fn main() {
|
|
/// let base_url = "http://localhost:9000/".parse::<BaseUrl>().unwrap();
|
|
/// let static_provider = StaticProvider::new("minioadmin", "minioadmin", None);
|
|
/// let client = MinioClient::new(base_url, Some(static_provider), None, None).unwrap();
|
|
/// let resp: CreateBucketResponse = client
|
|
/// .create_bucket("bucket-name")
|
|
/// .build().send().await.unwrap();
|
|
/// println!("Made bucket '{}' in region '{}'", resp.bucket(), resp.region());
|
|
/// }
|
|
/// ```
|
|
pub fn create_bucket<S: Into<String>>(&self, bucket: S) -> CreateBucketBldr {
|
|
CreateBucket::builder().client(self.clone()).bucket(bucket)
|
|
}
|
|
}
|