@@ -16,7 +16,7 @@ use serde::de::{self, MapAccess, Visitor};
16
16
#[ cfg( feature = "decimal128" ) ]
17
17
use crate :: decimal128:: Decimal128 ;
18
18
use crate :: {
19
- bson:: { Array , Binary , Bson , Document , TimeStamp } ,
19
+ bson:: { Array , Binary , Bson , TimeStamp } ,
20
20
oid:: ObjectId ,
21
21
spec:: BinarySubtype ,
22
22
} ;
@@ -62,17 +62,17 @@ impl error::Error for ValueAccessError {
62
62
63
63
/// A BSON document represented as an associative HashMap with insertion ordering.
64
64
#[ derive( Clone , PartialEq ) ]
65
- pub struct OrderedDocument {
65
+ pub struct Document {
66
66
inner : LinkedHashMap < String , Bson > ,
67
67
}
68
68
69
- impl Default for OrderedDocument {
69
+ impl Default for Document {
70
70
fn default ( ) -> Self {
71
71
Document :: new ( )
72
72
}
73
73
}
74
74
75
- impl Display for OrderedDocument {
75
+ impl Display for Document {
76
76
fn fmt ( & self , fmt : & mut Formatter ) -> fmt:: Result {
77
77
fmt. write_str ( "{" ) ?;
78
78
@@ -92,30 +92,30 @@ impl Display for OrderedDocument {
92
92
}
93
93
}
94
94
95
- impl Debug for OrderedDocument {
95
+ impl Debug for Document {
96
96
fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
97
- write ! ( f, "OrderedDocument ({:?})" , self . inner)
97
+ write ! ( f, "Document ({:?})" , self . inner)
98
98
}
99
99
}
100
100
101
- /// An iterator over OrderedDocument entries.
102
- pub struct OrderedDocumentIntoIterator {
101
+ /// An iterator over Document entries.
102
+ pub struct DocumentIntoIterator {
103
103
inner : LinkedHashMap < String , Bson > ,
104
104
}
105
105
106
- /// An owning iterator over OrderedDocument entries.
107
- pub struct OrderedDocumentIterator < ' a > {
106
+ /// An owning iterator over Document entries.
107
+ pub struct DocumentIterator < ' a > {
108
108
inner : linked_hash_map:: Iter < ' a , String , Bson > ,
109
109
}
110
110
111
- type DocumentMap < ' a , T > = Map < OrderedDocumentIterator < ' a > , fn ( ( & ' a String , & ' a Bson ) ) -> T > ;
111
+ type DocumentMap < ' a , T > = Map < DocumentIterator < ' a > , fn ( ( & ' a String , & ' a Bson ) ) -> T > ;
112
112
113
- /// An iterator over an OrderedDocument 's keys.
113
+ /// An iterator over an Document 's keys.
114
114
pub struct Keys < ' a > {
115
115
inner : DocumentMap < ' a , & ' a String > ,
116
116
}
117
117
118
- /// An iterator over an OrderedDocument 's values.
118
+ /// An iterator over an Document 's values.
119
119
pub struct Values < ' a > {
120
120
inner : DocumentMap < ' a , & ' a Bson > ,
121
121
}
@@ -136,62 +136,62 @@ impl<'a> Iterator for Values<'a> {
136
136
}
137
137
}
138
138
139
- impl IntoIterator for OrderedDocument {
139
+ impl IntoIterator for Document {
140
140
type Item = ( String , Bson ) ;
141
- type IntoIter = OrderedDocumentIntoIterator ;
141
+ type IntoIter = DocumentIntoIterator ;
142
142
143
143
fn into_iter ( self ) -> Self :: IntoIter {
144
- OrderedDocumentIntoIterator { inner : self . inner }
144
+ DocumentIntoIterator { inner : self . inner }
145
145
}
146
146
}
147
147
148
- impl < ' a > IntoIterator for & ' a OrderedDocument {
148
+ impl < ' a > IntoIterator for & ' a Document {
149
149
type Item = ( & ' a String , & ' a Bson ) ;
150
- type IntoIter = OrderedDocumentIterator < ' a > ;
150
+ type IntoIter = DocumentIterator < ' a > ;
151
151
152
152
fn into_iter ( self ) -> Self :: IntoIter {
153
- OrderedDocumentIterator {
153
+ DocumentIterator {
154
154
inner : self . inner . iter ( ) ,
155
155
}
156
156
}
157
157
}
158
158
159
- impl FromIterator < ( String , Bson ) > for OrderedDocument {
159
+ impl FromIterator < ( String , Bson ) > for Document {
160
160
fn from_iter < T : IntoIterator < Item = ( String , Bson ) > > ( iter : T ) -> Self {
161
- let mut doc = OrderedDocument :: new ( ) ;
161
+ let mut doc = Document :: new ( ) ;
162
162
for ( k, v) in iter {
163
163
doc. insert ( k, v) ;
164
164
}
165
165
doc
166
166
}
167
167
}
168
168
169
- impl < ' a > Iterator for OrderedDocumentIntoIterator {
169
+ impl < ' a > Iterator for DocumentIntoIterator {
170
170
type Item = ( String , Bson ) ;
171
171
172
172
fn next ( & mut self ) -> Option < ( String , Bson ) > {
173
173
self . inner . pop_front ( )
174
174
}
175
175
}
176
176
177
- impl < ' a > Iterator for OrderedDocumentIterator < ' a > {
177
+ impl < ' a > Iterator for DocumentIterator < ' a > {
178
178
type Item = ( & ' a String , & ' a Bson ) ;
179
179
180
180
fn next ( & mut self ) -> Option < ( & ' a String , & ' a Bson ) > {
181
181
self . inner . next ( )
182
182
}
183
183
}
184
184
185
- impl OrderedDocument {
186
- /// Creates a new empty OrderedDocument .
187
- pub fn new ( ) -> OrderedDocument {
188
- OrderedDocument {
185
+ impl Document {
186
+ /// Creates a new empty Document .
187
+ pub fn new ( ) -> Document {
188
+ Document {
189
189
inner : LinkedHashMap :: new ( ) ,
190
190
}
191
191
}
192
192
193
193
/// Gets an iterator over the entries of the map.
194
- pub fn iter ( & self ) -> OrderedDocumentIterator {
194
+ pub fn iter ( & self ) -> DocumentIterator {
195
195
self . into_iter ( )
196
196
}
197
197
@@ -526,42 +526,42 @@ impl<'a> Entry<'a> {
526
526
}
527
527
}
528
528
529
- impl From < LinkedHashMap < String , Bson > > for OrderedDocument {
530
- fn from ( tree : LinkedHashMap < String , Bson > ) -> OrderedDocument {
531
- OrderedDocument { inner : tree }
529
+ impl From < LinkedHashMap < String , Bson > > for Document {
530
+ fn from ( tree : LinkedHashMap < String , Bson > ) -> Document {
531
+ Document { inner : tree }
532
532
}
533
533
}
534
534
535
- pub struct OrderedDocumentVisitor {
536
- marker : PhantomData < OrderedDocument > ,
535
+ pub struct DocumentVisitor {
536
+ marker : PhantomData < Document > ,
537
537
}
538
538
539
- impl OrderedDocumentVisitor {
539
+ impl DocumentVisitor {
540
540
#[ allow( clippy:: new_without_default) ]
541
- pub fn new ( ) -> OrderedDocumentVisitor {
542
- OrderedDocumentVisitor {
541
+ pub fn new ( ) -> DocumentVisitor {
542
+ DocumentVisitor {
543
543
marker : PhantomData ,
544
544
}
545
545
}
546
546
}
547
547
548
- impl < ' de > Visitor < ' de > for OrderedDocumentVisitor {
549
- type Value = OrderedDocument ;
548
+ impl < ' de > Visitor < ' de > for DocumentVisitor {
549
+ type Value = Document ;
550
550
551
551
fn expecting ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
552
552
write ! ( f, "expecting ordered document" )
553
553
}
554
554
555
555
#[ inline]
556
- fn visit_unit < E > ( self ) -> Result < OrderedDocument , E >
556
+ fn visit_unit < E > ( self ) -> Result < Document , E >
557
557
where
558
558
E : de:: Error ,
559
559
{
560
- Ok ( OrderedDocument :: new ( ) )
560
+ Ok ( Document :: new ( ) )
561
561
}
562
562
563
563
#[ inline]
564
- fn visit_map < V > ( self , mut visitor : V ) -> Result < OrderedDocument , V :: Error >
564
+ fn visit_map < V > ( self , mut visitor : V ) -> Result < Document , V :: Error >
565
565
where
566
566
V : MapAccess < ' de > ,
567
567
{
@@ -578,7 +578,7 @@ impl<'de> Visitor<'de> for OrderedDocumentVisitor {
578
578
}
579
579
}
580
580
581
- impl Extend < ( String , Bson ) > for OrderedDocument {
581
+ impl Extend < ( String , Bson ) > for Document {
582
582
fn extend < T : IntoIterator < Item = ( String , Bson ) > > ( & mut self , iter : T ) {
583
583
for ( k, v) in iter {
584
584
self . insert ( k, v) ;
0 commit comments