@@ -136,11 +136,9 @@ impl MetadataClient<'_> {
136136 /// This function returns an error when it fails to communicate with the Databento API
137137 /// or the API indicates there's an issue with the request.
138138 pub async fn get_record_count ( & mut self , params : & GetRecordCountParams ) -> crate :: Result < u64 > {
139- let resp = self
140- . get ( "get_record_count" ) ?
141- . add_to_query ( params)
142- . send ( )
143- . await ?;
139+ let mut form = Vec :: new ( ) ;
140+ params. add_to_form ( & mut form) ;
141+ let resp = self . post ( "get_record_count" ) ?. form ( & form) . send ( ) . await ?;
144142 handle_response ( resp) . await
145143 }
146144
@@ -154,11 +152,9 @@ impl MetadataClient<'_> {
154152 & mut self ,
155153 params : & GetBillableSizeParams ,
156154 ) -> crate :: Result < u64 > {
157- let resp = self
158- . get ( "get_billable_size" ) ?
159- . add_to_query ( params)
160- . send ( )
161- . await ?;
155+ let mut form = Vec :: new ( ) ;
156+ params. add_to_form ( & mut form) ;
157+ let resp = self . post ( "get_billable_size" ) ?. form ( & form) . send ( ) . await ?;
162158 handle_response ( resp) . await
163159 }
164160
@@ -169,13 +165,19 @@ impl MetadataClient<'_> {
169165 /// This function returns an error when it fails to communicate with the Databento API
170166 /// or the API indicates there's an issue with the request.
171167 pub async fn get_cost ( & mut self , params : & GetCostParams ) -> crate :: Result < f64 > {
172- let resp = self . get ( "get_cost" ) ?. add_to_query ( params) . send ( ) . await ?;
168+ let mut form = Vec :: new ( ) ;
169+ params. add_to_form ( & mut form) ;
170+ let resp = self . post ( "get_cost" ) ?. form ( & form) . send ( ) . await ?;
173171 handle_response ( resp) . await
174172 }
175173
176174 fn get ( & mut self , slug : & str ) -> crate :: Result < RequestBuilder > {
177175 self . inner . get ( & format ! ( "metadata.{slug}" ) )
178176 }
177+
178+ fn post ( & mut self , slug : & str ) -> crate :: Result < RequestBuilder > {
179+ self . inner . post ( & format ! ( "metadata.{slug}" ) )
180+ }
179181}
180182
181183/// A type of data feed.
@@ -284,7 +286,6 @@ pub struct DatasetRange {
284286 pub end : time:: OffsetDateTime ,
285287}
286288
287- #[ allow( deprecated) ]
288289impl < ' de > Deserialize < ' de > for DatasetRange {
289290 fn deserialize < D > ( deserializer : D ) -> std:: result:: Result < Self , D :: Error >
290291 where
@@ -430,20 +431,16 @@ fn deserialize_date<'de, D: serde::Deserializer<'de>>(
430431 let dt_str = String :: deserialize ( deserializer) ?;
431432 time:: Date :: parse ( & dt_str, super :: DATE_FORMAT ) . map_err ( serde:: de:: Error :: custom)
432433}
433- impl AddToQuery < GetQueryParams > for reqwest:: RequestBuilder {
434- fn add_to_query ( mut self , params : & GetQueryParams ) -> Self {
435- self = self
436- . query ( & [
437- ( "dataset" , params. dataset . as_str ( ) ) ,
438- ( "schema" , params. schema . as_str ( ) ) ,
439- ( "stype_in" , params. stype_in . as_str ( ) ) ,
440- ] )
441- . add_to_query ( & params. symbols )
442- . add_to_query ( & params. date_time_range ) ;
443- if let Some ( limit) = params. limit {
444- self = self . query ( & [ ( "limit" , & limit. to_string ( ) ) ] ) ;
434+ impl GetQueryParams {
435+ fn add_to_form ( & self , form : & mut Vec < ( & ' static str , String ) > ) {
436+ form. push ( ( "dataset" , self . dataset . to_string ( ) ) ) ;
437+ form. push ( ( "schema" , self . schema . to_string ( ) ) ) ;
438+ form. push ( ( "stype_in" , self . stype_in . to_string ( ) ) ) ;
439+ form. push ( ( "symbols" , self . symbols . to_api_string ( ) ) ) ;
440+ self . date_time_range . add_to_form ( form) ;
441+ if let Some ( limit) = self . limit {
442+ form. push ( ( "limit" , limit. get ( ) . to_string ( ) ) )
445443 }
446- self
447444 }
448445}
449446
@@ -650,7 +647,6 @@ mod tests {
650647 }
651648
652649 #[ tokio:: test]
653- #[ allow( deprecated) ]
654650 async fn test_get_dataset_range ( ) {
655651 const DATASET : & str = "XNAS.ITCH" ;
656652 let mock_server = MockServer :: start ( ) . await ;
@@ -679,7 +675,6 @@ mod tests {
679675 }
680676
681677 #[ tokio:: test]
682- #[ allow( deprecated) ]
683678 async fn test_get_dataset_range_no_dates ( ) {
684679 const DATASET : & str = "XNAS.ITCH" ;
685680 let mock_server = MockServer :: start ( ) . await ;
0 commit comments