File tree Expand file tree Collapse file tree 5 files changed +20
-10
lines changed
Expand file tree Collapse file tree 5 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ impl<T> Insert<T> {
129129 /// If called after the request is started, e.g., after [`Insert::write`].
130130 #[ track_caller]
131131 pub fn with_option ( mut self , name : impl Into < String > , value : impl Into < String > ) -> Self {
132- self . insert . expect_client_mut ( ) . add_option ( name, value) ;
132+ self . insert . expect_client_mut ( ) . set_option ( name, value) ;
133133 self
134134 }
135135
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ impl InsertFormatted {
195195 /// If called after the request is started, e.g., after [`InsertFormatted::send`].
196196 #[ track_caller]
197197 pub fn with_option ( mut self , name : impl Into < String > , value : impl Into < String > ) -> Self {
198- self . state . expect_client_mut ( ) . add_option ( name, value) ;
198+ self . state . expect_client_mut ( ) . set_option ( name, value) ;
199199 self
200200 }
201201
Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ where
213213 /// If you have already begun writing data, you may call [`Inserter::force_commit`]
214214 /// to end the current `INSERT` so this takes effect on the next call to [`Inserter::write`].
215215 pub fn with_option ( mut self , name : impl Into < String > , value : impl Into < String > ) -> Self {
216- self . client . add_option ( name, value) ;
216+ self . client . set_option ( name, value) ;
217217 self
218218 }
219219
Original file line number Diff line number Diff line change @@ -383,6 +383,22 @@ impl Client {
383383 self
384384 }
385385
386+ /// Set an option on this instance of [`Client`].
387+ ///
388+ /// Returns the previous value for the option, if one was set.
389+ pub fn set_option (
390+ & mut self ,
391+ name : impl Into < String > ,
392+ value : impl Into < String > ,
393+ ) -> Option < String > {
394+ self . options . insert ( name. into ( ) , value. into ( ) )
395+ }
396+
397+ /// Get an option that was previously set on this `Client`.
398+ pub fn get_option ( & mut self , name : impl AsRef < str > ) -> Option < & str > {
399+ self . options . get ( name. as_ref ( ) ) . map ( String :: as_str)
400+ }
401+
386402 /// Starts a new INSERT statement.
387403 ///
388404 /// # Validation
@@ -503,12 +519,6 @@ impl Client {
503519 self . validation
504520 }
505521
506- /// Used internally to modify the options map of an _already cloned_
507- /// [`Client`] instance.
508- pub ( crate ) fn add_option ( & mut self , name : impl Into < String > , value : impl Into < String > ) {
509- self . options . insert ( name. into ( ) , value. into ( ) ) ;
510- }
511-
512522 pub ( crate ) fn set_roles ( & mut self , roles : impl IntoIterator < Item = impl Into < String > > ) {
513523 self . clear_roles ( ) ;
514524 self . roles . extend ( roles. into_iter ( ) . map ( Into :: into) ) ;
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ impl Query {
236236
237237 /// Similar to [`Client::with_option`], but for this particular query only.
238238 pub fn with_option ( mut self , name : impl Into < String > , value : impl Into < String > ) -> Self {
239- self . client . add_option ( name, value) ;
239+ self . client . set_option ( name, value) ;
240240 self
241241 }
242242
You can’t perform that action at this time.
0 commit comments