1
1
use bson:: { Bson , Document } ;
2
- use json:: options:: FromJson ;
2
+ use json:: options:: FromValue ;
3
3
use mongodb:: coll:: options:: { AggregateOptions , CountOptions , FindOneAndDeleteOptions ,
4
4
FindOneAndUpdateOptions , FindOptions } ;
5
- use rustc_serialize :: json :: Object ;
5
+ use serde_json :: Map ;
6
6
7
7
pub enum Arguments {
8
8
Aggregate {
@@ -53,7 +53,7 @@ pub enum Arguments {
53
53
}
54
54
55
55
impl 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 > {
57
57
let options = AggregateOptions :: from_json ( object) ;
58
58
59
59
let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -84,7 +84,7 @@ impl Arguments {
84
84
} )
85
85
}
86
86
87
- pub fn count_from_json ( object : & Object ) -> Arguments {
87
+ pub fn count_from_json ( object : & Map < String , Value > ) -> Arguments {
88
88
let options = CountOptions :: from_json ( object) ;
89
89
90
90
let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -99,7 +99,7 @@ impl Arguments {
99
99
}
100
100
}
101
101
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 > {
103
103
let f = |x| Some ( Bson :: from_json ( x) ) ;
104
104
let document = val_or_err ! ( object. get( "filter" ) . and_then( f) ,
105
105
Some ( Bson :: Document ( doc) ) => doc,
@@ -111,7 +111,7 @@ impl Arguments {
111
111
} )
112
112
}
113
113
114
- pub fn distinct_from_json ( object : & Object ) -> Result < Arguments , String > {
114
+ pub fn distinct_from_json ( object : & Map < String , Value > ) -> Result < Arguments , String > {
115
115
let f = |x| Some ( Bson :: from_json ( x) ) ;
116
116
let field_name = val_or_err ! ( object. get( "fieldName" ) . and_then( f) ,
117
117
Some ( Bson :: String ( ref s) ) => s. to_owned( ) ,
@@ -129,7 +129,7 @@ impl Arguments {
129
129
} )
130
130
}
131
131
132
- pub fn find_from_json ( object : & Object ) -> Arguments {
132
+ pub fn find_from_json ( object : & Map < String , Value > ) -> Arguments {
133
133
let options = FindOptions :: from_json ( object) ;
134
134
135
135
let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -144,7 +144,7 @@ impl Arguments {
144
144
}
145
145
}
146
146
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 > {
148
148
let options = FindOneAndDeleteOptions :: from_json ( object) ;
149
149
150
150
let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -158,7 +158,7 @@ impl Arguments {
158
158
} )
159
159
}
160
160
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 > {
162
162
let options = FindOneAndUpdateOptions :: from_json ( object) ;
163
163
164
164
let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -178,7 +178,7 @@ impl Arguments {
178
178
} )
179
179
}
180
180
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 > {
182
182
let options = FindOneAndUpdateOptions :: from_json ( object) ;
183
183
184
184
let f = |x| Some ( Bson :: from_json ( x) ) ;
@@ -198,7 +198,7 @@ impl Arguments {
198
198
} )
199
199
}
200
200
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 > {
202
202
let f = |x| Some ( Bson :: from_json ( x) ) ;
203
203
204
204
let bsons = val_or_err ! ( object. get( "documents" ) . and_then( f) ,
@@ -217,7 +217,7 @@ impl Arguments {
217
217
Ok ( Arguments :: InsertMany { documents : docs } )
218
218
}
219
219
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 > {
221
221
let f = |x| Some ( Bson :: from_json ( x) ) ;
222
222
let document = val_or_err ! ( object. get( "document" ) . and_then( f) ,
223
223
Some ( Bson :: Document ( doc) ) => doc,
@@ -226,7 +226,7 @@ impl Arguments {
226
226
Ok ( Arguments :: InsertOne { document : document } )
227
227
}
228
228
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 > {
230
230
let f = |x| Some ( Bson :: from_json ( x) ) ;
231
231
let filter = val_or_err ! ( object. get( "filter" ) . and_then( f) ,
232
232
Some ( Bson :: Document ( doc) ) => doc,
@@ -248,7 +248,7 @@ impl Arguments {
248
248
} )
249
249
}
250
250
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 > {
252
252
let f = |x| Some ( Bson :: from_json ( x) ) ;
253
253
let filter = val_or_err ! ( object. get( "filter" ) . and_then( f) ,
254
254
Some ( Bson :: Document ( doc) ) => doc,
0 commit comments