Skip to content

fixed clippy issues and cleanup of unnecessary imports #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ readme = "README.md"
keywords = ["object-storage", "minio", "s3"]
categories = ["api-bindings", "web-programming::http-client"]

[dependencies.reqwest]
version = "0.12.22"
default-features = false
features = ["stream"]

[features]
default = ["default-tls", "default-crypto"]
default-tls = ["reqwest/default-tls"]
Expand All @@ -23,21 +18,29 @@ rustls-tls = ["reqwest/rustls-tls"]
default-crypto = ["dep:sha2", "dep:hmac"]
ring = ["dep:ring"]

[workspace.dependencies]
uuid = "1.18"
futures-util = "0.3"
reqwest = { version = "0.12", default-features = false }
bytes = "1.10"
async-std = "1.13"


[dependencies]
uuid = { workspace = true, features = ["v4"] }
futures-util = { workspace = true }
bytes = { workspace = true }
async-std = { workspace = true, features = ["attributes"] }
reqwest = { workspace = true, features = ["stream"] }

async-recursion = "1.1.1"
async-std = { version = "1.13.1", features = ["attributes"] }
async-stream = "0.3.6"
async-trait = "0.1.88"
base64 = "0.22.1"
byteorder = "1.5.0"
bytes = "1.10.1"
chrono = "0.4.41"
crc = "3.3.0"
dashmap = "6.1.0"
derivative = "2.2.0"
env_logger = "0.11.8"
futures-util = "0.3.31"
hex = "0.4.3"
hmac = { version = "0.12.1", optional = true }
hyper = { version = "1.6.0", features = ["full"] }
lazy_static = "1.5.0"
Expand All @@ -46,26 +49,25 @@ md5 = "0.8.0"
multimap = "0.10.1"
percent-encoding = "2.3.1"
url = "2.5.4"
rand = { version = "0.8.5", features = ["small_rng"] }
regex = "1.11.1"
ring = { version = "0.17.14", optional = true, default-features = false, features = ["alloc"] }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
serde_json = "1.0.142"
sha2 = { version = "0.10.9", optional = true }
urlencoding = "2.1.3"
xmltree = "0.11.0"
futures = "0.3.31"
http = "1.3.1"
thiserror = "2.0.12"
thiserror = "2.0.14"

[dev-dependencies]
minio-common = { path = "./common" }
minio-macros = { path = "./macros" }
tokio = { version = "1.47.1", features = ["full"] }
minio_common = { path = "./common" }
async-std = { version = "1.13.1", features = ["attributes", "tokio1"] }
clap = { version = "4.5.44", features = ["derive"] }
rand = { version = "0.9.2", features = ["small_rng"] }
quickcheck = "1.0.3"
criterion = "0.7.0"
minio-macros = { path = "./macros" }

[lib]
name = "minio"
Expand Down
17 changes: 10 additions & 7 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[package]
name = "minio_common"
name = "minio-common"
version = "0.1.0"
edition = "2024"

[dependencies]
minio = {path = ".." }
uuid = { workspace = true, features = ["v4"] }
reqwest = { workspace = true }
bytes = { workspace = true }
async-std = { workspace = true }

futures-io = "0.3.31"
tokio = { version = "1.47.1", features = ["full"] }
async-std = "1.13.1"
rand = { version = "0.8.5", features = ["small_rng"] }
bytes = "1.10.1"
rand = { version = "0.9.2", features = ["small_rng"] }

log = "0.4.27"
chrono = "0.4.41"
reqwest = "0.12.22"

http = "1.3.1"
futures = "0.3.31"
uuid = { version = "1.18.0", features = ["v4"] }

[lib]
name = "minio_common"
Expand Down
4 changes: 2 additions & 2 deletions common/src/cleanup_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ impl CleanupGuard {
pub async fn cleanup(client: Client, bucket_name: &str) {
tokio::select!(
_ = tokio::time::sleep(std::time::Duration::from_secs(60)) => {
eprintln!("Cleanup timeout after 60s while removing bucket {}", bucket_name);
eprintln!("Cleanup timeout after 60s while removing bucket {bucket_name}");
},
outcome = client.delete_and_purge_bucket(bucket_name) => {
match outcome {
Ok(_) => {
//eprintln!("Bucket {} removed successfully", bucket_name);
}
Err(e) => {
eprintln!("Error removing bucket '{}':\n{}", bucket_name, e);
eprintln!("Error removing bucket '{bucket_name}':\n{e}");
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions common/src/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub fn create_bucket_replication_config_example(dst_bucket: &str) -> Replication
rules: vec![ReplicationRule {
id: Some(String::from("rule1")),
destination: Destination {
bucket_arn: String::from(&format!("arn:aws:s3:::{}", dst_bucket)),
bucket_arn: String::from(&format!("arn:aws:s3:::{dst_bucket}")),
..Default::default()
},
filter: Some(Filter {
Expand Down Expand Up @@ -170,8 +170,8 @@ pub fn create_object_lock_config_example() -> ObjectLockConfig {
pub fn create_post_policy_example(bucket_name: &str, object_name: &str) -> PostPolicy {
let expiration: DateTime<Utc> = utc_now() + chrono::Duration::days(5);

let mut policy = PostPolicy::new(&bucket_name, expiration).unwrap();
policy.add_equals_condition("key", &object_name).unwrap();
let mut policy = PostPolicy::new(bucket_name, expiration).unwrap();
policy.add_equals_condition("key", object_name).unwrap();
policy
.add_content_length_range_condition(1024 * 1024, 4 * 1024 * 1024)
.unwrap();
Expand All @@ -189,7 +189,7 @@ pub fn create_select_content_data() -> (String, String) {
(body, data)
}
pub fn create_select_content_request() -> SelectRequest {
let request = SelectRequest::new_csv_input_output(
SelectRequest::new_csv_input_output(
"select * from S3Object",
CsvInputSerialization {
compression_type: None,
Expand All @@ -209,6 +209,5 @@ pub fn create_select_content_request() -> SelectRequest {
record_delimiter: None,
},
)
.unwrap();
request
.unwrap()
}
6 changes: 3 additions & 3 deletions common/src/rand_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use futures::AsyncRead;
use futures_io::AsyncRead;
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
Expand All @@ -34,7 +34,7 @@ impl io::Read for RandReader {
let bytes_read = buf.len().min(self.size as usize);

if bytes_read > 0 {
let random: &mut dyn rand::RngCore = &mut rand::thread_rng();
let random: &mut dyn rand::RngCore = &mut rand::rng();
random.fill_bytes(&mut buf[0..bytes_read]);
}

Expand All @@ -53,7 +53,7 @@ impl AsyncRead for RandReader {
let bytes_read = buf.len().min(self.size as usize);

if bytes_read > 0 {
let random: &mut dyn rand::RngCore = &mut rand::thread_rng();
let random: &mut dyn rand::RngCore = &mut rand::rng();
random.fill_bytes(&mut buf[0..bytes_read]);
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/rand_src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use async_std::stream::Stream;
use bytes::Bytes;
use futures::io::AsyncRead;
use futures_io::AsyncRead;
use rand::prelude::SmallRng;
use rand::{RngCore, SeedableRng};
use std::io;
Expand All @@ -30,7 +30,7 @@ pub struct RandSrc {
impl RandSrc {
#[allow(dead_code)]
pub fn new(size: u64) -> RandSrc {
let rng = SmallRng::from_entropy();
let rng: SmallRng = SmallRng::from_os_rng();
RandSrc { size, rng }
}
}
Expand Down
12 changes: 6 additions & 6 deletions common/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,30 @@ impl TestContext {

let host: String =
std::env::var("SERVER_ENDPOINT").unwrap_or(DEFAULT_SERVER_ENDPOINT.to_string());
log::debug!("SERVER_ENDPOINT={}", host);
log::debug!("SERVER_ENDPOINT={host}");
let access_key: String =
std::env::var("ACCESS_KEY").unwrap_or(DEFAULT_ACCESS_KEY.to_string());
log::debug!("ACCESS_KEY={}", access_key);
log::debug!("ACCESS_KEY={access_key}");
let secret_key: String =
std::env::var("SECRET_KEY").unwrap_or(DEFAULT_SECRET_KEY.to_string());
log::debug!("SECRET_KEY=*****");
let secure: bool = std::env::var("ENABLE_HTTPS")
.unwrap_or(DEFAULT_ENABLE_HTTPS.to_string())
.parse()
.unwrap_or(false);
log::debug!("ENABLE_HTTPS={}", secure);
log::debug!("ENABLE_HTTPS={secure}");
let ssl_cert: String =
std::env::var("MINIO_SSL_CERT_FILE").unwrap_or(DEFAULT_SSL_CERT_FILE.to_string());
log::debug!("MINIO_SSL_CERT_FILE={}", ssl_cert);
log::debug!("MINIO_SSL_CERT_FILE={ssl_cert}");
let ssl_cert_file: PathBuf = ssl_cert.into();
let ignore_cert_check: bool = std::env::var("IGNORE_CERT_CHECK")
.unwrap_or(DEFAULT_IGNORE_CERT_CHECK.to_string())
.parse()
.unwrap_or(true);
log::debug!("IGNORE_CERT_CHECK={}", ignore_cert_check);
log::debug!("IGNORE_CERT_CHECK={ignore_cert_check}");
let region: String =
std::env::var("SERVER_REGION").unwrap_or(DEFAULT_SERVER_REGION.to_string());
log::debug!("SERVER_REGION={:?}", region);
log::debug!("SERVER_REGION={region:?}");

let mut base_url: BaseUrl = host.parse().unwrap();
base_url.https = secure;
Expand Down
17 changes: 9 additions & 8 deletions common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

use http::{Response as HttpResponse, StatusCode};
use minio::s3::error::Error;
use rand::distributions::Standard;
use rand::{Rng, thread_rng};

use rand::Rng;
use rand::distr::StandardUniform;
use uuid::Uuid;

pub fn rand_bucket_name() -> String {
Expand All @@ -28,9 +29,9 @@ pub fn rand_object_name() -> String {
}

pub fn rand_object_name_utf8(len: usize) -> String {
let rng = thread_rng();
rng.sample_iter::<char, _>(Standard)
.filter(|c| !c.is_control())
let rng = rand::rng();
rng.sample_iter(StandardUniform)
.filter(|c: &char| !c.is_control())
.take(len)
.collect()
}
Expand All @@ -39,9 +40,9 @@ pub async fn get_bytes_from_response(v: Result<reqwest::Response, Error>) -> byt
match v {
Ok(r) => match r.bytes().await {
Ok(b) => b,
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
},
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}

Expand All @@ -52,5 +53,5 @@ pub fn get_response_from_bytes(bytes: bytes::Bytes) -> reqwest::Response {
.body(bytes)
.expect("Failed to build HTTP response");

reqwest::Response::try_from(http_response).expect("Failed to convert to reqwest::Response")
reqwest::Response::from(http_response)
}
4 changes: 2 additions & 2 deletions examples/append_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use minio::s3::response::{AppendObjectResponse, StatObjectResponse};
use minio::s3::segmented_bytes::SegmentedBytes;
use minio::s3::types::S3Api;
use rand::Rng;
use rand::distributions::Alphanumeric;
use rand::distr::Alphanumeric;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down Expand Up @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
}

fn random_string(len: usize) -> String {
rand::thread_rng()
rand::rng()
.sample_iter(&Alphanumeric)
.take(len)
.map(char::from)
Expand Down
17 changes: 9 additions & 8 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ name = "minio-macros"
version = "0.1.0"
edition = "2024"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
proc-macro = true


[dependencies]
uuid = { workspace = true, features = ["v4"] }
futures-util = { workspace = true }

syn = "2.0.104"
proc-macro2 = "1.0.95"
proc-macro2 = "1.0.97"
quote = "1.0.40"
darling = "0.21.0"
darling_core = "0.21.0"
uuid = { version = "1.17.0", features = ["v4"] }

[dev-dependencies]
minio_common = { path = "../common" }
minio-common = { path = "../common" }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
proc-macro = true
2 changes: 1 addition & 1 deletion macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ pub fn test(
// Expand the macro
match test_attr::expand_test_macro(args, input_fn) {
Ok(expanded) => expanded.into(),
Err(err) => err.into(),
Err(err) => err,
}
}
28 changes: 14 additions & 14 deletions macros/src/test_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl MacroArgs {
}

// Validate that the function has exactly two arguments: ctx and bucket_name
if func.sig.inputs.len() != 2 && !self.no_bucket.is_present() {
if (func.sig.inputs.len() != 2) && !self.no_bucket.is_present() {
let error_msg = "Minio test function must have exactly two arguments: (ctx: TestContext, bucket_name: String)";
return Err(proc_macro::TokenStream::from(
Error::custom(error_msg)
Expand All @@ -80,18 +80,18 @@ impl MacroArgs {
}
}

// Check second argument (bucket_name: String)
if !self.no_bucket.is_present() {
if let Some(FnArg::Typed(pat_type)) = iter.next() {
let type_str = pat_type.ty.to_token_stream().to_string();
if !type_str.contains("String") {
let error_msg = "Second argument must be of type String";
return Err(proc_macro::TokenStream::from(
Error::custom(error_msg)
.with_span(&pat_type.span())
.write_errors(),
));
}
// Check the second argument (bucket_name: String)
if !self.no_bucket.is_present()
&& let Some(FnArg::Typed(pat_type)) = iter.next()
{
let type_str = pat_type.ty.to_token_stream().to_string();
if !type_str.contains("String") {
let error_msg = "Second argument must be of type String";
return Err(proc_macro::TokenStream::from(
Error::custom(error_msg)
.with_span(&pat_type.span())
.write_errors(),
));
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ pub(crate) fn expand_test_macro(

// Setup common prelude
let prelude = quote!(
use ::futures::FutureExt;
use ::futures_util::FutureExt;
use ::std::panic::AssertUnwindSafe;
use ::minio::s3::types::S3Api;
use ::minio::s3::response::a_response_traits::HasBucket;
Expand Down
Loading
Loading