@@ -5,7 +5,7 @@ use serde::de::{self, Deserialize, Deserializer, Visitor,
5
5
6
6
use bson:: Bson ;
7
7
use oid:: ObjectId ;
8
- use ordered:: { OrderedDocument , OrderedDocumentIntoIterator } ;
8
+ use ordered:: { OrderedDocument , OrderedDocumentIntoIterator , OrderedDocumentVisitor } ;
9
9
use super :: error:: { DecoderError , DecoderResult } ;
10
10
11
11
pub struct BsonVisitor ;
@@ -49,7 +49,7 @@ impl Deserialize for Bson {
49
49
50
50
impl Visitor for BsonVisitor {
51
51
type Value = Bson ;
52
-
52
+
53
53
#[ inline]
54
54
fn visit_bool < E > ( & mut self , value : bool ) -> Result < Bson , E > {
55
55
Ok ( Bson :: Boolean ( value) )
@@ -66,7 +66,7 @@ impl Visitor for BsonVisitor {
66
66
Ok ( Bson :: I32 ( value as i32 ) )
67
67
}
68
68
69
-
69
+
70
70
#[ inline]
71
71
fn visit_i32 < E > ( & mut self , value : i32 ) -> Result < Bson , E > {
72
72
Ok ( Bson :: I32 ( value) )
@@ -76,59 +76,59 @@ impl Visitor for BsonVisitor {
76
76
fn visit_i64 < E > ( & mut self , value : i64 ) -> Result < Bson , E > {
77
77
Ok ( Bson :: I64 ( value) )
78
78
}
79
-
79
+
80
80
#[ inline]
81
81
fn visit_u64 < E > ( & mut self , value : u64 ) -> Result < Bson , E > {
82
82
Ok ( Bson :: I64 ( value as i64 ) )
83
83
}
84
-
84
+
85
85
#[ inline]
86
86
fn visit_f64 < E > ( & mut self , value : f64 ) -> Result < Bson , E > {
87
87
Ok ( Bson :: FloatingPoint ( value) )
88
88
}
89
-
89
+
90
90
#[ inline]
91
91
fn visit_str < E > ( & mut self , value : & str ) -> Result < Bson , E >
92
92
where E : de:: Error
93
93
{
94
94
self . visit_string ( String :: from ( value) )
95
95
}
96
-
96
+
97
97
#[ inline]
98
98
fn visit_string < E > ( & mut self , value : String ) -> Result < Bson , E > {
99
99
Ok ( Bson :: String ( value) )
100
100
}
101
-
101
+
102
102
#[ inline]
103
103
fn visit_none < E > ( & mut self ) -> Result < Bson , E > {
104
104
Ok ( Bson :: Null )
105
105
}
106
-
106
+
107
107
#[ inline]
108
108
fn visit_some < D > ( & mut self , deserializer : & mut D ) -> Result < Bson , D :: Error >
109
109
where D : Deserializer ,
110
110
{
111
111
de:: Deserialize :: deserialize ( deserializer)
112
112
}
113
-
113
+
114
114
#[ inline]
115
115
fn visit_unit < E > ( & mut self ) -> Result < Bson , E > {
116
116
Ok ( Bson :: Null )
117
117
}
118
-
118
+
119
119
#[ inline]
120
120
fn visit_seq < V > ( & mut self , visitor : V ) -> Result < Bson , V :: Error >
121
121
where V : SeqVisitor ,
122
122
{
123
123
let values = try!( de:: impls:: VecVisitor :: new ( ) . visit_seq ( visitor) ) ;
124
124
Ok ( Bson :: Array ( values) )
125
125
}
126
-
126
+
127
127
#[ inline]
128
128
fn visit_map < V > ( & mut self , visitor : V ) -> Result < Bson , V :: Error >
129
129
where V : MapVisitor ,
130
130
{
131
- let values = try!( de :: impls :: BTreeMapVisitor :: new ( ) . visit_map ( visitor) ) ;
131
+ let values = try!( OrderedDocumentVisitor :: new ( ) . visit_map ( visitor) ) ;
132
132
Ok ( Bson :: from_extended_document ( values. into ( ) ) )
133
133
}
134
134
}
0 commit comments