@@ -4,22 +4,21 @@ use serde::{Deserialize, Serialize};
44// DB.
55use azure_core:: prelude:: * ;
66use azure_data_cosmos:: prelude:: * ;
7- use std:: borrow:: Cow ;
87use std:: error:: Error ;
98
109#[ derive( Clone , Serialize , Deserialize , Debug ) ]
11- struct MySampleStruct < ' a > {
12- id : Cow < ' a , str > ,
13- a_string : Cow < ' a , str > ,
10+ struct MySampleStruct {
11+ id : String ,
12+ a_string : String ,
1413 a_number : u64 ,
1514 a_timestamp : i64 ,
1615}
1716
18- impl < ' a > azure_data_cosmos:: CosmosEntity < ' a > for MySampleStruct < ' a > {
19- type Entity = & ' a str ;
17+ impl azure_data_cosmos:: CosmosEntity for MySampleStruct {
18+ type Entity = String ;
2019
21- fn partition_key ( & ' a self ) -> Self :: Entity {
22- self . id . as_ref ( )
20+ fn partition_key ( & self ) -> Self :: Entity {
21+ self . id . clone ( )
2322 }
2423}
2524
@@ -102,11 +101,8 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
102101 client
103102 . clone ( )
104103 . into_database_client ( database. id . clone ( ) )
105- . create_collection (
106- Context :: new ( ) ,
107- COLLECTION ,
108- CreateCollectionOptions :: new ( "/id" ) ,
109- )
104+ . create_collection ( COLLECTION , "/id" )
105+ . into_future ( )
110106 . await ?
111107 . collection
112108 }
@@ -118,8 +114,8 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
118114 // data in them. Let's create a Document. The only constraint
119115 // is that we need an id and an arbitrary, Serializable type.
120116 let doc = MySampleStruct {
121- id : Cow :: Owned ( "unique_id100" . to_owned ( ) ) ,
122- a_string : Cow :: Borrowed ( "Something here" ) ,
117+ id : "unique_id100" . into ( ) ,
118+ a_string : "Something here" . into ( ) ,
123119 a_number : 100 ,
124120 a_timestamp : chrono:: Utc :: now ( ) . timestamp ( ) ,
125121 } ;
@@ -135,7 +131,8 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
135131 // the document attributes.
136132
137133 let create_document_response = collection_client
138- . create_document ( Context :: new ( ) , & doc, CreateDocumentOptions :: new ( ) )
134+ . create_document ( doc. clone ( ) )
135+ . into_future ( )
139136 . await ?;
140137 println ! (
141138 "create_document_response == {:#?}" ,
@@ -191,14 +188,16 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
191188 . clone ( )
192189 . into_database_client ( DATABASE . to_owned ( ) )
193190 . into_collection_client ( COLLECTION . to_owned ( ) )
194- . delete_collection ( Context :: new ( ) , DeleteCollectionOptions :: new ( ) )
191+ . delete_collection ( )
192+ . into_future ( )
195193 . await ?;
196194 println ! ( "collection deleted" ) ;
197195
198196 // And then we delete the database.
199197 client
200198 . into_database_client ( database. id )
201- . delete_database ( Context :: new ( ) , DeleteDatabaseOptions :: new ( ) )
199+ . delete_database ( )
200+ . into_future ( )
202201 . await ?;
203202 println ! ( "database deleted" ) ;
204203
0 commit comments