@@ -10,7 +10,7 @@ use crate::{
1010 DeleteContainerOptions , ItemOptions , PartitionKey , Query , QueryPartitionStrategy ,
1111} ;
1212
13- use azure_core:: { Context , Method , Pager , Request , Response } ;
13+ use azure_core:: { Method , Pager , Request , Response } ;
1414use serde:: { de:: DeserializeOwned , Serialize } ;
1515
1616/// A client for working with a specific container in a Cosmos DB account.
@@ -60,15 +60,16 @@ impl ContainerClient {
6060 /// ```
6161 pub async fn read (
6262 & self ,
63-
64- #[ allow( unused_variables) ]
65- // REASON: This is a documented public API so prefixing with '_' is undesirable.
66- options : Option < ReadContainerOptions > ,
63+ options : Option < ReadContainerOptions < ' _ > > ,
6764 ) -> azure_core:: Result < Response < ContainerProperties > > {
6865 let url = self . pipeline . url ( & self . link ) ;
6966 let mut req = Request :: new ( url, Method :: Get ) ;
7067 self . pipeline
71- . send ( Context :: new ( ) , & mut req, self . link . clone ( ) )
68+ . send (
69+ options. map ( |o| o. method_options . context ) ,
70+ & mut req,
71+ self . link . clone ( ) ,
72+ )
7273 . await
7374 }
7475
@@ -80,14 +81,16 @@ impl ContainerClient {
8081 /// * `options` - Optional parameters for the request.
8182 pub async fn delete (
8283 & self ,
83- #[ allow( unused_variables) ]
84- // REASON: This is a documented public API so prefixing with '_' is undesirable.
85- options : Option < DeleteContainerOptions > ,
84+ options : Option < DeleteContainerOptions < ' _ > > ,
8685 ) -> azure_core:: Result < Response > {
8786 let url = self . pipeline . url ( & self . link ) ;
8887 let mut req = Request :: new ( url, Method :: Delete ) ;
8988 self . pipeline
90- . send ( Context :: new ( ) , & mut req, self . link . clone ( ) )
89+ . send (
90+ options. map ( |o| o. method_options . context ) ,
91+ & mut req,
92+ self . link . clone ( ) ,
93+ )
9194 . await
9295 }
9396
@@ -130,17 +133,18 @@ impl ContainerClient {
130133 & self ,
131134 partition_key : impl Into < PartitionKey > ,
132135 item : T ,
133-
134- #[ allow( unused_variables) ]
135- // REASON: This is a documented public API so prefixing with '_' is undesirable.
136- options : Option < ItemOptions > ,
136+ options : Option < ItemOptions < ' _ > > ,
137137 ) -> azure_core:: Result < Response < Item < T > > > {
138138 let url = self . pipeline . url ( & self . items_link ) ;
139139 let mut req = Request :: new ( url, Method :: Post ) ;
140140 req. insert_headers ( & partition_key. into ( ) ) ?;
141141 req. set_json ( & item) ?;
142142 self . pipeline
143- . send ( Context :: new ( ) , & mut req, self . items_link . clone ( ) )
143+ . send (
144+ options. map ( |o| o. method_options . context ) ,
145+ & mut req,
146+ self . items_link . clone ( ) ,
147+ )
144148 . await
145149 }
146150
@@ -183,19 +187,21 @@ impl ContainerClient {
183187 pub async fn replace_item < T : Serialize > (
184188 & self ,
185189 partition_key : impl Into < PartitionKey > ,
186- item_id : impl AsRef < str > ,
190+ item_id : & str ,
187191 item : T ,
188192
189193 #[ allow( unused_variables) ]
190194 // REASON: This is a documented public API so prefixing with '_' is undesirable.
191- options : Option < ItemOptions > ,
195+ options : Option < ItemOptions < ' _ > > ,
192196 ) -> azure_core:: Result < Response < Item < T > > > {
193197 let link = self . items_link . item ( item_id) ;
194198 let url = self . pipeline . url ( & link) ;
195199 let mut req = Request :: new ( url, Method :: Put ) ;
196200 req. insert_headers ( & partition_key. into ( ) ) ?;
197201 req. set_json ( & item) ?;
198- self . pipeline . send ( Context :: new ( ) , & mut req, link) . await
202+ self . pipeline
203+ . send ( options. map ( |o| o. method_options . context ) , & mut req, link)
204+ . await
199205 }
200206
201207 /// Creates or replaces an item in the container.
@@ -240,18 +246,19 @@ impl ContainerClient {
240246 & self ,
241247 partition_key : impl Into < PartitionKey > ,
242248 item : T ,
243-
244- #[ allow( unused_variables) ]
245- // REASON: This is a documented public API so prefixing with '_' is undesirable.
246- options : Option < ItemOptions > ,
249+ options : Option < ItemOptions < ' _ > > ,
247250 ) -> azure_core:: Result < Response < Item < T > > > {
248251 let url = self . pipeline . url ( & self . items_link ) ;
249252 let mut req = Request :: new ( url, Method :: Post ) ;
250253 req. insert_header ( constants:: IS_UPSERT , "true" ) ;
251254 req. insert_headers ( & partition_key. into ( ) ) ?;
252255 req. set_json ( & item) ?;
253256 self . pipeline
254- . send ( Context :: new ( ) , & mut req, self . items_link . clone ( ) )
257+ . send (
258+ options. map ( |o| o. method_options . context ) ,
259+ & mut req,
260+ self . items_link . clone ( ) ,
261+ )
255262 . await
256263 }
257264
@@ -288,17 +295,16 @@ impl ContainerClient {
288295 pub async fn read_item < T : DeserializeOwned > (
289296 & self ,
290297 partition_key : impl Into < PartitionKey > ,
291- item_id : impl AsRef < str > ,
292-
293- #[ allow( unused_variables) ]
294- // REASON: This is a documented public API so prefixing with '_' is undesirable.
295- options : Option < ItemOptions > ,
298+ item_id : & str ,
299+ options : Option < ItemOptions < ' _ > > ,
296300 ) -> azure_core:: Result < Response < Item < T > > > {
297301 let link = self . items_link . item ( item_id) ;
298302 let url = self . pipeline . url ( & link) ;
299303 let mut req = Request :: new ( url, Method :: Get ) ;
300304 req. insert_headers ( & partition_key. into ( ) ) ?;
301- self . pipeline . send ( Context :: new ( ) , & mut req, link) . await
305+ self . pipeline
306+ . send ( options. map ( |o| o. method_options . context ) , & mut req, link)
307+ . await
302308 }
303309
304310 /// Deletes an item from the container.
@@ -323,17 +329,16 @@ impl ContainerClient {
323329 pub async fn delete_item (
324330 & self ,
325331 partition_key : impl Into < PartitionKey > ,
326- item_id : impl AsRef < str > ,
327-
328- #[ allow( unused_variables) ]
329- // REASON: This is a documented public API so prefixing with '_' is undesirable.
330- options : Option < ItemOptions > ,
332+ item_id : & str ,
333+ options : Option < ItemOptions < ' _ > > ,
331334 ) -> azure_core:: Result < Response > {
332335 let link = self . items_link . item ( item_id) ;
333336 let url = self . pipeline . url ( & link) ;
334337 let mut req = Request :: new ( url, Method :: Delete ) ;
335338 req. insert_headers ( & partition_key. into ( ) ) ?;
336- self . pipeline . send ( Context :: new ( ) , & mut req, link) . await
339+ self . pipeline
340+ . send ( options. map ( |o| o. method_options . context ) , & mut req, link)
341+ . await
337342 }
338343
339344 /// Executes a single-partition query against items in the container.
@@ -394,17 +399,18 @@ impl ContainerClient {
394399 & self ,
395400 query : impl Into < Query > ,
396401 partition_key : impl Into < QueryPartitionStrategy > ,
397-
398- #[ allow( unused_variables) ]
399- // REASON: This is a documented public API so prefixing with '_' is undesirable.
400- options : Option < QueryOptions > ,
402+ options : Option < QueryOptions < ' _ > > ,
401403 ) -> azure_core:: Result < Pager < QueryResults < T > > > {
402404 let url = self . pipeline . url ( & self . items_link ) ;
403405 let mut base_request = Request :: new ( url, Method :: Post ) ;
404406 let QueryPartitionStrategy :: SinglePartition ( partition_key) = partition_key. into ( ) ;
405407 base_request. insert_headers ( & partition_key) ?;
406408
407- self . pipeline
408- . send_query_request ( query. into ( ) , base_request, self . items_link . clone ( ) )
409+ self . pipeline . send_query_request (
410+ options. map ( |o| o. method_options . context ) ,
411+ query. into ( ) ,
412+ base_request,
413+ self . items_link . clone ( ) ,
414+ )
409415 }
410416}
0 commit comments