@@ -114,10 +114,7 @@ pub async fn put_get_delete_list(storage: &DynObjectStore) {
114114 let bytes = range_result. unwrap ( ) ;
115115 assert_eq ! ( bytes, data. slice( range. start as usize ..range. end as usize ) ) ;
116116
117- let opts = GetOptions {
118- range : Some ( GetRange :: Bounded ( 2 ..5 ) ) ,
119- ..Default :: default ( )
120- } ;
117+ let opts = GetOptions :: new ( ) . with_range ( Some ( GetRange :: Bounded ( 2 ..5 ) ) ) ;
121118 let result = storage. get_opts ( & location, opts) . await . unwrap ( ) ;
122119 // Data is `"arbitrary data"`, length 14 bytes
123120 assert_eq ! ( result. meta. size, 14 ) ; // Should return full object size (#5272)
@@ -131,20 +128,14 @@ pub async fn put_get_delete_list(storage: &DynObjectStore) {
131128 // Should be a non-fatal error
132129 out_of_range_result. unwrap_err ( ) ;
133130
134- let opts = GetOptions {
135- range : Some ( GetRange :: Bounded ( 2 ..100 ) ) ,
136- ..Default :: default ( )
137- } ;
131+ let opts = GetOptions :: new ( ) . with_range ( Some ( GetRange :: Bounded ( 2 ..100 ) ) ) ;
138132 let result = storage. get_opts ( & location, opts) . await . unwrap ( ) ;
139133 assert_eq ! ( result. range, 2 ..14 ) ;
140134 assert_eq ! ( result. meta. size, 14 ) ;
141135 let bytes = result. bytes ( ) . await . unwrap ( ) ;
142136 assert_eq ! ( bytes, b"bitrary data" . as_ref( ) ) ;
143137
144- let opts = GetOptions {
145- range : Some ( GetRange :: Suffix ( 2 ) ) ,
146- ..Default :: default ( )
147- } ;
138+ let opts = GetOptions :: new ( ) . with_range ( Some ( GetRange :: Suffix ( 2 ) ) ) ;
148139 match storage. get_opts ( & location, opts) . await {
149140 Ok ( result) => {
150141 assert_eq ! ( result. range, 12 ..14 ) ;
@@ -156,10 +147,7 @@ pub async fn put_get_delete_list(storage: &DynObjectStore) {
156147 Err ( e) => panic ! ( "{e}" ) ,
157148 }
158149
159- let opts = GetOptions {
160- range : Some ( GetRange :: Suffix ( 100 ) ) ,
161- ..Default :: default ( )
162- } ;
150+ let opts = GetOptions :: new ( ) . with_range ( Some ( GetRange :: Suffix ( 100 ) ) ) ;
163151 match storage. get_opts ( & location, opts) . await {
164152 Ok ( result) => {
165153 assert_eq ! ( result. range, 0 ..14 ) ;
@@ -171,20 +159,14 @@ pub async fn put_get_delete_list(storage: &DynObjectStore) {
171159 Err ( e) => panic ! ( "{e}" ) ,
172160 }
173161
174- let opts = GetOptions {
175- range : Some ( GetRange :: Offset ( 3 ) ) ,
176- ..Default :: default ( )
177- } ;
162+ let opts = GetOptions :: new ( ) . with_range ( Some ( GetRange :: Offset ( 3 ) ) ) ;
178163 let result = storage. get_opts ( & location, opts) . await . unwrap ( ) ;
179164 assert_eq ! ( result. range, 3 ..14 ) ;
180165 assert_eq ! ( result. meta. size, 14 ) ;
181166 let bytes = result. bytes ( ) . await . unwrap ( ) ;
182167 assert_eq ! ( bytes, b"itrary data" . as_ref( ) ) ;
183168
184- let opts = GetOptions {
185- range : Some ( GetRange :: Offset ( 100 ) ) ,
186- ..Default :: default ( )
187- } ;
169+ let opts = GetOptions :: new ( ) . with_range ( Some ( GetRange :: Offset ( 100 ) ) ) ;
188170 storage. get_opts ( & location, opts) . await . unwrap_err ( ) ;
189171
190172 let ranges = vec ! [ 0 ..1 , 2 ..3 , 0 ..5 ] ;
@@ -520,76 +502,55 @@ pub async fn get_opts(storage: &dyn ObjectStore) {
520502 storage. put ( & path, "foo" . into ( ) ) . await . unwrap ( ) ;
521503 let meta = storage. head ( & path) . await . unwrap ( ) ;
522504
523- let options = GetOptions {
524- if_unmodified_since : Some ( meta. last_modified ) ,
525- ..GetOptions :: default ( )
526- } ;
505+ let options = GetOptions :: new ( ) . with_if_unmodified_since ( Some ( meta. last_modified ) ) ;
527506 match storage. get_opts ( & path, options) . await {
528507 Ok ( _) | Err ( Error :: NotSupported { .. } ) => { }
529508 Err ( e) => panic ! ( "{e}" ) ,
530509 }
531510
532- let options = GetOptions {
533- if_unmodified_since : Some ( meta. last_modified + chrono:: Duration :: try_hours ( 10 ) . unwrap ( ) ) ,
534- ..GetOptions :: default ( )
535- } ;
511+ let options = GetOptions :: new ( ) . with_if_unmodified_since ( Some (
512+ meta. last_modified + chrono:: Duration :: try_hours ( 10 ) . unwrap ( ) ,
513+ ) ) ;
536514 match storage. get_opts ( & path, options) . await {
537515 Ok ( _) | Err ( Error :: NotSupported { .. } ) => { }
538516 Err ( e) => panic ! ( "{e}" ) ,
539517 }
540518
541- let options = GetOptions {
542- if_unmodified_since : Some ( meta. last_modified - chrono:: Duration :: try_hours ( 10 ) . unwrap ( ) ) ,
543- ..GetOptions :: default ( )
544- } ;
519+ let options = GetOptions :: new ( ) . with_if_unmodified_since ( Some (
520+ meta. last_modified - chrono:: Duration :: try_hours ( 10 ) . unwrap ( ) ,
521+ ) ) ;
545522 match storage. get_opts ( & path, options) . await {
546523 Err ( Error :: Precondition { .. } | Error :: NotSupported { .. } ) => { }
547524 d => panic ! ( "{d:?}" ) ,
548525 }
549526
550- let options = GetOptions {
551- if_modified_since : Some ( meta. last_modified ) ,
552- ..GetOptions :: default ( )
553- } ;
527+ let options = GetOptions :: new ( ) . with_if_modified_since ( Some ( meta. last_modified ) ) ;
554528 match storage. get_opts ( & path, options) . await {
555529 Err ( Error :: NotModified { .. } | Error :: NotSupported { .. } ) => { }
556530 d => panic ! ( "{d:?}" ) ,
557531 }
558532
559- let options = GetOptions {
560- if_modified_since : Some ( meta. last_modified - chrono:: Duration :: try_hours ( 10 ) . unwrap ( ) ) ,
561- ..GetOptions :: default ( )
562- } ;
533+ let options = GetOptions :: new ( ) . with_if_modified_since ( Some (
534+ meta. last_modified - chrono:: Duration :: try_hours ( 10 ) . unwrap ( ) ,
535+ ) ) ;
563536 match storage. get_opts ( & path, options) . await {
564537 Ok ( _) | Err ( Error :: NotSupported { .. } ) => { }
565538 Err ( e) => panic ! ( "{e}" ) ,
566539 }
567540
568541 let tag = meta. e_tag . unwrap ( ) ;
569- let options = GetOptions {
570- if_match : Some ( tag. clone ( ) ) ,
571- ..GetOptions :: default ( )
572- } ;
542+ let options = GetOptions :: new ( ) . with_if_match ( Some ( tag. clone ( ) ) ) ;
573543 storage. get_opts ( & path, options) . await . unwrap ( ) ;
574544
575- let options = GetOptions {
576- if_match : Some ( "invalid" . to_string ( ) ) ,
577- ..GetOptions :: default ( )
578- } ;
545+ let options = GetOptions :: new ( ) . with_if_match ( Some ( "invalid" . to_string ( ) ) ) ;
579546 let err = storage. get_opts ( & path, options) . await . unwrap_err ( ) ;
580547 assert ! ( matches!( err, Error :: Precondition { .. } ) , "{err}" ) ;
581548
582- let options = GetOptions {
583- if_none_match : Some ( tag. clone ( ) ) ,
584- ..GetOptions :: default ( )
585- } ;
549+ let options = GetOptions :: new ( ) . with_if_none_match ( Some ( tag. clone ( ) ) ) ;
586550 let err = storage. get_opts ( & path, options) . await . unwrap_err ( ) ;
587551 assert ! ( matches!( err, Error :: NotModified { .. } ) , "{err}" ) ;
588552
589- let options = GetOptions {
590- if_none_match : Some ( "invalid" . to_string ( ) ) ,
591- ..GetOptions :: default ( )
592- } ;
553+ let options = GetOptions :: new ( ) . with_if_none_match ( Some ( "invalid" . to_string ( ) ) ) ;
593554 storage. get_opts ( & path, options) . await . unwrap ( ) ;
594555
595556 let result = storage. put ( & path, "test" . into ( ) ) . await . unwrap ( ) ;
@@ -599,26 +560,17 @@ pub async fn get_opts(storage: &dyn ObjectStore) {
599560 let meta = storage. head ( & path) . await . unwrap ( ) ;
600561 assert_eq ! ( meta. e_tag. unwrap( ) , new_tag) ;
601562
602- let options = GetOptions {
603- if_match : Some ( new_tag) ,
604- ..GetOptions :: default ( )
605- } ;
563+ let options = GetOptions :: new ( ) . with_if_match ( Some ( new_tag. clone ( ) ) ) ;
606564 storage. get_opts ( & path, options) . await . unwrap ( ) ;
607565
608- let options = GetOptions {
609- if_match : Some ( tag) ,
610- ..GetOptions :: default ( )
611- } ;
566+ let options = GetOptions :: new ( ) . with_if_match ( Some ( tag) ) ;
612567 let err = storage. get_opts ( & path, options) . await . unwrap_err ( ) ;
613568 assert ! ( matches!( err, Error :: Precondition { .. } ) , "{err}" ) ;
614569
615570 if let Some ( version) = meta. version {
616571 storage. put ( & path, "bar" . into ( ) ) . await . unwrap ( ) ;
617572
618- let options = GetOptions {
619- version : Some ( version) ,
620- ..GetOptions :: default ( )
621- } ;
573+ let options = GetOptions :: new ( ) . with_version ( Some ( version) ) ;
622574
623575 // Can retrieve previous version
624576 let get_opts = storage. get_opts ( & path, options) . await . unwrap ( ) ;
0 commit comments