@@ -99,8 +99,12 @@ impl ObjectStoreBuilder {
9999 }
100100 }
101101
102- pub fn with_options ( mut self , options : HashMap < String , String > ) -> Self {
103- self . options = options;
102+ pub fn with_options < I : IntoIterator < Item = ( impl Into < String > , impl Into < String > ) > > (
103+ mut self ,
104+ options : I ,
105+ ) -> Self {
106+ self . options
107+ . extend ( options. into_iter ( ) . map ( |( k, v) | ( k. into ( ) , v. into ( ) ) ) ) ;
104108 self
105109 }
106110
@@ -158,7 +162,7 @@ impl ObjectStoreBuilder {
158162 ObjectStoreKind :: Azure => {
159163 let maybe_store = MicrosoftAzureBuilder :: new ( )
160164 . with_url ( url. clone ( ) )
161- . with_options ( & self . options )
165+ . try_with_options ( & self . options ) ?
162166 . with_client_options ( self . client_options . clone ( ) . unwrap_or_default ( ) )
163167 . with_retry ( self . retry_config . clone ( ) . unwrap_or_default ( ) )
164168 . build ( ) ;
@@ -167,7 +171,7 @@ impl ObjectStoreBuilder {
167171 } else {
168172 let store = MicrosoftAzureBuilder :: from_env ( )
169173 . with_url ( url. clone ( ) )
170- . with_options ( & self . options )
174+ . try_with_options ( & self . options ) ?
171175 . with_client_options ( self . client_options . unwrap_or_default ( ) )
172176 . with_retry ( self . retry_config . unwrap_or_default ( ) )
173177 . build ( ) ?;
@@ -177,7 +181,7 @@ impl ObjectStoreBuilder {
177181 ObjectStoreKind :: S3 => {
178182 let maybe_store = AmazonS3Builder :: new ( )
179183 . with_url ( url. clone ( ) )
180- . with_options ( & self . options )
184+ . try_with_options ( & self . options ) ?
181185 . with_client_options ( self . client_options . clone ( ) . unwrap_or_default ( ) )
182186 . with_retry ( self . retry_config . clone ( ) . unwrap_or_default ( ) )
183187 . build ( ) ;
@@ -186,7 +190,7 @@ impl ObjectStoreBuilder {
186190 } else {
187191 let store = AmazonS3Builder :: from_env ( )
188192 . with_url ( url. clone ( ) )
189- . with_options ( & self . options )
193+ . try_with_options ( & self . options ) ?
190194 . with_client_options ( self . client_options . unwrap_or_default ( ) )
191195 . with_retry ( self . retry_config . unwrap_or_default ( ) )
192196 . build ( ) ?;
@@ -196,7 +200,7 @@ impl ObjectStoreBuilder {
196200 ObjectStoreKind :: Google => {
197201 let maybe_store = GoogleCloudStorageBuilder :: new ( )
198202 . with_url ( url. clone ( ) )
199- . with_options ( & self . options )
203+ . try_with_options ( & self . options ) ?
200204 . with_client_options ( self . client_options . clone ( ) . unwrap_or_default ( ) )
201205 . with_retry ( self . retry_config . clone ( ) . unwrap_or_default ( ) )
202206 . build ( ) ;
@@ -205,7 +209,7 @@ impl ObjectStoreBuilder {
205209 } else {
206210 let store = GoogleCloudStorageBuilder :: from_env ( )
207211 . with_url ( url. clone ( ) )
208- . with_options ( & self . options )
212+ . try_with_options ( & self . options ) ?
209213 . with_client_options ( self . client_options . unwrap_or_default ( ) )
210214 . with_retry ( self . retry_config . unwrap_or_default ( ) )
211215 . build ( ) ?;
0 commit comments