@@ -9,8 +9,10 @@ use crate::bucket_ops::{BucketConfiguration, CreateBucketResponse};
9
9
use crate :: command:: { Command , Multipart } ;
10
10
use crate :: creds:: Credentials ;
11
11
use crate :: region:: Region ;
12
- #[ cfg( feature = "with-tokio" ) ]
13
- use crate :: request:: tokio_backend:: { client, HttpsConnector } ;
12
+ #[ cfg( any( feature = "with-tokio" , feature = "use-tokio-native-tls" ) ) ]
13
+ use crate :: request:: tokio_backend:: client;
14
+ #[ cfg( any( feature = "use-tokio-native-tls" , feature = "tokio-rustls-tls" ) ) ]
15
+ use crate :: request:: tokio_backend:: HttpsConnector ;
14
16
use crate :: request:: ResponseData ;
15
17
#[ cfg( any( feature = "with-tokio" , feature = "with-async-std" ) ) ]
16
18
use crate :: request:: ResponseDataStream ;
@@ -106,8 +108,14 @@ pub struct Bucket {
106
108
pub request_timeout : Option < Duration > ,
107
109
path_style : bool ,
108
110
listobjects_v2 : bool ,
109
- #[ cfg( feature = "with -tokio" ) ]
111
+ #[ cfg( any ( feature = "use -tokio-native-tls" , feature = "tokio-rustls-tls" ) ) ]
110
112
http_client : Arc < hyper:: Client < HttpsConnector < hyper:: client:: HttpConnector > > > ,
113
+ #[ cfg( all(
114
+ feature = "with-tokio" ,
115
+ not( feature = "use-tokio-native-tls" ) ,
116
+ not( feature = "tokio-rustls-tls" )
117
+ ) ) ]
118
+ http_client : Arc < hyper:: Client < hyper:: client:: HttpConnector > > ,
111
119
}
112
120
113
121
impl Bucket {
@@ -126,7 +134,16 @@ impl Bucket {
126
134
}
127
135
}
128
136
129
- #[ cfg( feature = "with-tokio" ) ]
137
+ #[ cfg( all(
138
+ feature = "with-tokio" ,
139
+ not( feature = "use-tokio-native-tls" ) ,
140
+ not( feature = "tokio-rustls-tls" )
141
+ ) ) ]
142
+ pub fn http_client ( & self ) -> Arc < hyper:: Client < hyper:: client:: HttpConnector > > {
143
+ Arc :: clone ( & self . http_client )
144
+ }
145
+
146
+ #[ cfg( any( feature = "use-tokio-native-tls" , feature = "tokio-rustls-tls" ) ) ]
130
147
pub fn http_client ( & self ) -> Arc < hyper:: Client < HttpsConnector < hyper:: client:: HttpConnector > > > {
131
148
Arc :: clone ( & self . http_client )
132
149
}
@@ -224,7 +241,7 @@ impl Bucket {
224
241
& self ,
225
242
post_policy : PostPolicy < ' a > ,
226
243
) -> Result < PresignedPost , S3Error > {
227
- post_policy. sign ( self . clone ( ) ) . await
244
+ post_policy. sign ( Box :: new ( self . clone ( ) ) ) . await
228
245
}
229
246
230
247
/// Get a presigned url for putting object to a given path
@@ -557,8 +574,12 @@ impl Bucket {
557
574
///
558
575
/// let bucket = Bucket::new(bucket_name, region, credentials).unwrap();
559
576
/// ```
560
- pub fn new ( name : & str , region : Region , credentials : Credentials ) -> Result < Bucket , S3Error > {
561
- Ok ( Bucket {
577
+ pub fn new (
578
+ name : & str ,
579
+ region : Region ,
580
+ credentials : Credentials ,
581
+ ) -> Result < Box < Bucket > , S3Error > {
582
+ Ok ( Box :: new ( Bucket {
562
583
name : name. into ( ) ,
563
584
region,
564
585
credentials : Arc :: new ( RwLock :: new ( credentials) ) ,
@@ -567,9 +588,9 @@ impl Bucket {
567
588
request_timeout : DEFAULT_REQUEST_TIMEOUT ,
568
589
path_style : false ,
569
590
listobjects_v2 : true ,
570
- #[ cfg( feature = "with-tokio" ) ]
591
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
571
592
http_client : Arc :: new ( client ( DEFAULT_REQUEST_TIMEOUT ) ?) ,
572
- } )
593
+ } ) )
573
594
}
574
595
575
596
/// Instantiate a public existing `Bucket`.
@@ -593,13 +614,13 @@ impl Bucket {
593
614
request_timeout : DEFAULT_REQUEST_TIMEOUT ,
594
615
path_style : false ,
595
616
listobjects_v2 : true ,
596
- #[ cfg( feature = "with-tokio" ) ]
617
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
597
618
http_client : Arc :: new ( client ( DEFAULT_REQUEST_TIMEOUT ) ?) ,
598
619
} )
599
620
}
600
621
601
- pub fn with_path_style ( & self ) -> Bucket {
602
- Bucket {
622
+ pub fn with_path_style ( & self ) -> Box < Bucket > {
623
+ Box :: new ( Bucket {
603
624
name : self . name . clone ( ) ,
604
625
region : self . region . clone ( ) ,
605
626
credentials : self . credentials . clone ( ) ,
@@ -608,9 +629,9 @@ impl Bucket {
608
629
request_timeout : self . request_timeout ,
609
630
path_style : true ,
610
631
listobjects_v2 : self . listobjects_v2 ,
611
- #[ cfg( feature = "with-tokio" ) ]
632
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
612
633
http_client : self . http_client . clone ( ) ,
613
- }
634
+ } )
614
635
}
615
636
616
637
pub fn with_extra_headers ( & self , extra_headers : HeaderMap ) -> Result < Bucket , S3Error > {
@@ -623,7 +644,7 @@ impl Bucket {
623
644
request_timeout : self . request_timeout ,
624
645
path_style : self . path_style ,
625
646
listobjects_v2 : self . listobjects_v2 ,
626
- #[ cfg( feature = "with-tokio" ) ]
647
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
627
648
http_client : self . http_client . clone ( ) ,
628
649
} )
629
650
}
@@ -641,13 +662,13 @@ impl Bucket {
641
662
request_timeout : self . request_timeout ,
642
663
path_style : self . path_style ,
643
664
listobjects_v2 : self . listobjects_v2 ,
644
- #[ cfg( feature = "with-tokio" ) ]
665
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
645
666
http_client : self . http_client . clone ( ) ,
646
667
} )
647
668
}
648
669
649
- pub fn with_request_timeout ( & self , request_timeout : Duration ) -> Result < Bucket , S3Error > {
650
- Ok ( Bucket {
670
+ pub fn with_request_timeout ( & self , request_timeout : Duration ) -> Result < Box < Bucket > , S3Error > {
671
+ Ok ( Box :: new ( Bucket {
651
672
name : self . name . clone ( ) ,
652
673
region : self . region . clone ( ) ,
653
674
credentials : self . credentials . clone ( ) ,
@@ -656,9 +677,9 @@ impl Bucket {
656
677
request_timeout : Some ( request_timeout) ,
657
678
path_style : self . path_style ,
658
679
listobjects_v2 : self . listobjects_v2 ,
659
- #[ cfg( feature = "with-tokio" ) ]
680
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
660
681
http_client : Arc :: new ( client ( Some ( request_timeout) ) ?) ,
661
- } )
682
+ } ) )
662
683
}
663
684
664
685
pub fn with_listobjects_v1 ( & self ) -> Bucket {
@@ -671,7 +692,7 @@ impl Bucket {
671
692
request_timeout : self . request_timeout ,
672
693
path_style : self . path_style ,
673
694
listobjects_v2 : false ,
674
- #[ cfg( feature = "with-tokio" ) ]
695
+ #[ cfg( any ( feature = "use-tokio-native-tls" , feature = " with-tokio") ) ]
675
696
http_client : self . http_client . clone ( ) ,
676
697
}
677
698
}
@@ -2492,7 +2513,7 @@ mod test {
2492
2513
. unwrap ( )
2493
2514
}
2494
2515
2495
- fn test_aws_bucket ( ) -> Bucket {
2516
+ fn test_aws_bucket ( ) -> Box < Bucket > {
2496
2517
Bucket :: new (
2497
2518
"rust-s3-test" ,
2498
2519
"eu-central-1" . parse ( ) . unwrap ( ) ,
@@ -2501,7 +2522,7 @@ mod test {
2501
2522
. unwrap ( )
2502
2523
}
2503
2524
2504
- fn test_wasabi_bucket ( ) -> Bucket {
2525
+ fn test_wasabi_bucket ( ) -> Box < Bucket > {
2505
2526
Bucket :: new (
2506
2527
"rust-s3" ,
2507
2528
"wa-eu-central-1" . parse ( ) . unwrap ( ) ,
@@ -2510,7 +2531,7 @@ mod test {
2510
2531
. unwrap ( )
2511
2532
}
2512
2533
2513
- fn test_gc_bucket ( ) -> Bucket {
2534
+ fn test_gc_bucket ( ) -> Box < Bucket > {
2514
2535
let mut bucket = Bucket :: new (
2515
2536
"rust-s3" ,
2516
2537
Region :: Custom {
@@ -2524,7 +2545,7 @@ mod test {
2524
2545
bucket
2525
2546
}
2526
2547
2527
- fn test_minio_bucket ( ) -> Bucket {
2548
+ fn test_minio_bucket ( ) -> Box < Bucket > {
2528
2549
Bucket :: new (
2529
2550
"rust-s3" ,
2530
2551
Region :: Custom {
@@ -2538,11 +2559,11 @@ mod test {
2538
2559
}
2539
2560
2540
2561
#[ allow( dead_code) ]
2541
- fn test_digital_ocean_bucket ( ) -> Bucket {
2562
+ fn test_digital_ocean_bucket ( ) -> Box < Bucket > {
2542
2563
Bucket :: new ( "rust-s3" , Region :: DoFra1 , test_digital_ocean_credentials ( ) ) . unwrap ( )
2543
2564
}
2544
2565
2545
- fn test_r2_bucket ( ) -> Bucket {
2566
+ fn test_r2_bucket ( ) -> Box < Bucket > {
2546
2567
Bucket :: new (
2547
2568
"rust-s3" ,
2548
2569
Region :: R2 {
@@ -2680,7 +2701,7 @@ mod test {
2680
2701
)
2681
2702
) ]
2682
2703
async fn streaming_big_aws_put_head_get_delete_object ( ) {
2683
- streaming_test_put_get_delete_big_object ( test_aws_bucket ( ) ) . await ;
2704
+ streaming_test_put_get_delete_big_object ( * test_aws_bucket ( ) ) . await ;
2684
2705
}
2685
2706
2686
2707
#[ ignore]
@@ -2700,7 +2721,7 @@ mod test {
2700
2721
)
2701
2722
) ]
2702
2723
async fn streaming_big_gc_put_head_get_delete_object ( ) {
2703
- streaming_test_put_get_delete_big_object ( test_gc_bucket ( ) ) . await ;
2724
+ streaming_test_put_get_delete_big_object ( * test_gc_bucket ( ) ) . await ;
2704
2725
}
2705
2726
2706
2727
#[ ignore]
@@ -2713,7 +2734,7 @@ mod test {
2713
2734
)
2714
2735
) ]
2715
2736
async fn streaming_big_minio_put_head_get_delete_object ( ) {
2716
- streaming_test_put_get_delete_big_object ( test_minio_bucket ( ) ) . await ;
2737
+ streaming_test_put_get_delete_big_object ( * test_minio_bucket ( ) ) . await ;
2717
2738
}
2718
2739
2719
2740
// Test multi-part upload
@@ -2838,7 +2859,7 @@ mod test {
2838
2859
}
2839
2860
2840
2861
#[ maybe_async:: maybe_async]
2841
- async fn streaming_test_put_get_delete_small_object ( bucket : Bucket ) {
2862
+ async fn streaming_test_put_get_delete_small_object ( bucket : Box < Bucket > ) {
2842
2863
init ( ) ;
2843
2864
let remote_path = "+stream_test_small" ;
2844
2865
let content: Vec < u8 > = object ( 1000 ) ;
@@ -2949,7 +2970,7 @@ mod test {
2949
2970
) ) ]
2950
2971
#[ test]
2951
2972
fn aws_put_head_get_delete_object_blocking ( ) {
2952
- put_head_get_list_delete_object_blocking ( test_aws_bucket ( ) )
2973
+ put_head_get_list_delete_object_blocking ( * test_aws_bucket ( ) )
2953
2974
}
2954
2975
2955
2976
#[ ignore]
@@ -2959,7 +2980,7 @@ mod test {
2959
2980
) ) ]
2960
2981
#[ test]
2961
2982
fn gc_put_head_get_delete_object_blocking ( ) {
2962
- put_head_get_list_delete_object_blocking ( test_gc_bucket ( ) )
2983
+ put_head_get_list_delete_object_blocking ( * test_gc_bucket ( ) )
2963
2984
}
2964
2985
2965
2986
#[ ignore]
@@ -2969,7 +2990,7 @@ mod test {
2969
2990
) ) ]
2970
2991
#[ test]
2971
2992
fn wasabi_put_head_get_delete_object_blocking ( ) {
2972
- put_head_get_list_delete_object_blocking ( test_wasabi_bucket ( ) )
2993
+ put_head_get_list_delete_object_blocking ( * test_wasabi_bucket ( ) )
2973
2994
}
2974
2995
2975
2996
#[ ignore]
@@ -2979,7 +3000,7 @@ mod test {
2979
3000
) ) ]
2980
3001
#[ test]
2981
3002
fn minio_put_head_get_delete_object_blocking ( ) {
2982
- put_head_get_list_delete_object_blocking ( test_minio_bucket ( ) )
3003
+ put_head_get_list_delete_object_blocking ( * test_minio_bucket ( ) )
2983
3004
}
2984
3005
2985
3006
#[ ignore]
@@ -2989,7 +3010,7 @@ mod test {
2989
3010
) ) ]
2990
3011
#[ test]
2991
3012
fn digital_ocean_put_head_get_delete_object_blocking ( ) {
2992
- put_head_get_list_delete_object_blocking ( test_digital_ocean_bucket ( ) )
3013
+ put_head_get_list_delete_object_blocking ( * test_digital_ocean_bucket ( ) )
2993
3014
}
2994
3015
2995
3016
#[ ignore]
@@ -3002,7 +3023,7 @@ mod test {
3002
3023
)
3003
3024
) ]
3004
3025
async fn aws_put_head_get_delete_object ( ) {
3005
- put_head_get_delete_object ( test_aws_bucket ( ) , true ) . await ;
3026
+ put_head_get_delete_object ( * test_aws_bucket ( ) , true ) . await ;
3006
3027
}
3007
3028
3008
3029
#[ ignore]
@@ -3021,7 +3042,7 @@ mod test {
3021
3042
)
3022
3043
) ]
3023
3044
async fn gc_test_put_head_get_delete_object ( ) {
3024
- put_head_get_delete_object ( test_gc_bucket ( ) , true ) . await ;
3045
+ put_head_get_delete_object ( * test_gc_bucket ( ) , true ) . await ;
3025
3046
}
3026
3047
3027
3048
#[ ignore]
@@ -3034,7 +3055,7 @@ mod test {
3034
3055
)
3035
3056
) ]
3036
3057
async fn wasabi_test_put_head_get_delete_object ( ) {
3037
- put_head_get_delete_object ( test_wasabi_bucket ( ) , true ) . await ;
3058
+ put_head_get_delete_object ( * test_wasabi_bucket ( ) , true ) . await ;
3038
3059
}
3039
3060
3040
3061
#[ ignore]
@@ -3047,7 +3068,7 @@ mod test {
3047
3068
)
3048
3069
) ]
3049
3070
async fn minio_test_put_head_get_delete_object ( ) {
3050
- put_head_get_delete_object ( test_minio_bucket ( ) , true ) . await ;
3071
+ put_head_get_delete_object ( * test_minio_bucket ( ) , true ) . await ;
3051
3072
}
3052
3073
3053
3074
// Keeps failing on tokio-rustls-tls
@@ -3074,7 +3095,7 @@ mod test {
3074
3095
)
3075
3096
) ]
3076
3097
async fn r2_test_put_head_get_delete_object ( ) {
3077
- put_head_get_delete_object ( test_r2_bucket ( ) , false ) . await ;
3098
+ put_head_get_delete_object ( * test_r2_bucket ( ) , false ) . await ;
3078
3099
}
3079
3100
3080
3101
#[ maybe_async:: test(
0 commit comments