11use bson:: { Bson , Document } ;
2- use json:: options:: FromJson ;
2+ use json:: options:: FromValue ;
33use mongodb:: coll:: options:: { AggregateOptions , CountOptions , FindOneAndDeleteOptions ,
44 FindOneAndUpdateOptions , FindOptions } ;
5- use rustc_serialize :: json :: Object ;
5+ use serde_json :: Map ;
66
77pub enum Arguments {
88 Aggregate {
@@ -53,7 +53,7 @@ pub enum Arguments {
5353}
5454
5555impl Arguments {
56- pub fn aggregate_from_json ( object : & Object ) -> Result < Arguments , String > {
56+ pub fn aggregate_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
5757 let options = AggregateOptions :: from_json ( object) ;
5858
5959 let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -84,7 +84,7 @@ impl Arguments {
8484 } )
8585 }
8686
87- pub fn count_from_json ( object : & Object ) -> Arguments {
87+ pub fn count_from_json ( object : & Map < String , Value > ) -> Arguments {
8888 let options = CountOptions :: from_json ( object) ;
8989
9090 let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -99,7 +99,7 @@ impl Arguments {
9999 }
100100 }
101101
102- pub fn delete_from_json ( object : & Object , many : bool ) -> Result < Arguments , String > {
102+ pub fn delete_from_json ( object : & Map < String , Value > , many : bool ) -> Result < Arguments , String > {
103103 let f = |x| Some ( Bson :: from_json ( x) ) ;
104104 let document = val_or_err ! ( object. get( "filter" ) . and_then( f) ,
105105 Some ( Bson :: Document ( doc) ) => doc,
@@ -111,7 +111,7 @@ impl Arguments {
111111 } )
112112 }
113113
114- pub fn distinct_from_json ( object : & Object ) -> Result < Arguments , String > {
114+ pub fn distinct_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
115115 let f = |x| Some ( Bson :: from_json ( x) ) ;
116116 let field_name = val_or_err ! ( object. get( "fieldName" ) . and_then( f) ,
117117 Some ( Bson :: String ( ref s) ) => s. to_owned( ) ,
@@ -129,7 +129,7 @@ impl Arguments {
129129 } )
130130 }
131131
132- pub fn find_from_json ( object : & Object ) -> Arguments {
132+ pub fn find_from_json ( object : & Map < String , Value > ) -> Arguments {
133133 let options = FindOptions :: from_json ( object) ;
134134
135135 let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -144,7 +144,7 @@ impl Arguments {
144144 }
145145 }
146146
147- pub fn find_one_and_delete_from_json ( object : & Object ) -> Result < Arguments , String > {
147+ pub fn find_one_and_delete_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
148148 let options = FindOneAndDeleteOptions :: from_json ( object) ;
149149
150150 let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -158,7 +158,7 @@ impl Arguments {
158158 } )
159159 }
160160
161- pub fn find_one_and_replace_from_json ( object : & Object ) -> Result < Arguments , String > {
161+ pub fn find_one_and_replace_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
162162 let options = FindOneAndUpdateOptions :: from_json ( object) ;
163163
164164 let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -178,7 +178,7 @@ impl Arguments {
178178 } )
179179 }
180180
181- pub fn find_one_and_update_from_json ( object : & Object ) -> Result < Arguments , String > {
181+ pub fn find_one_and_update_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
182182 let options = FindOneAndUpdateOptions :: from_json ( object) ;
183183
184184 let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -198,7 +198,7 @@ impl Arguments {
198198 } )
199199 }
200200
201- pub fn insert_many_from_json ( object : & Object ) -> Result < Arguments , String > {
201+ pub fn insert_many_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
202202 let f = |x| Some ( Bson :: from_json ( x) ) ;
203203
204204 let bsons = val_or_err ! ( object. get( "documents" ) . and_then( f) ,
@@ -217,7 +217,7 @@ impl Arguments {
217217 Ok ( Arguments :: InsertMany { documents : docs } )
218218 }
219219
220- pub fn insert_one_from_json ( object : & Object ) -> Result < Arguments , String > {
220+ pub fn insert_one_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
221221 let f = |x| Some ( Bson :: from_json ( x) ) ;
222222 let document = val_or_err ! ( object. get( "document" ) . and_then( f) ,
223223 Some ( Bson :: Document ( doc) ) => doc,
@@ -226,7 +226,7 @@ impl Arguments {
226226 Ok ( Arguments :: InsertOne { document : document } )
227227 }
228228
229- pub fn replace_one_from_json ( object : & Object ) -> Result < Arguments , String > {
229+ pub fn replace_one_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
230230 let f = |x| Some ( Bson :: from_json ( x) ) ;
231231 let filter = val_or_err ! ( object. get( "filter" ) . and_then( f) ,
232232 Some ( Bson :: Document ( doc) ) => doc,
@@ -248,7 +248,7 @@ impl Arguments {
248248 } )
249249 }
250250
251- pub fn update_from_json ( object : & Object , many : bool ) -> Result < Arguments , String > {
251+ pub fn update_from_json ( object : & Map < String , Value > , many : bool ) -> Result < Arguments , String > {
252252 let f = |x| Some ( Bson :: from_json ( x) ) ;
253253 let filter = val_or_err ! ( object. get( "filter" ) . and_then( f) ,
254254 Some ( Bson :: Document ( doc) ) => doc,
0 commit comments