File tree Expand file tree Collapse file tree 4 files changed +10
-7
lines changed Expand file tree Collapse file tree 4 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ pub enum Error {
17
17
18
18
/// While decoding a `Document` from bytes, an unexpected or unsupported element type was
19
19
/// encountered.
20
+ #[ non_exhaustive]
20
21
UnrecognizedDocumentElementType {
21
22
/// The key at which an unexpected/unsupported element type was encountered.
22
23
key : String ,
@@ -26,12 +27,14 @@ pub enum Error {
26
27
} ,
27
28
28
29
/// There was an error with the syntactical structure of the BSON.
30
+ #[ non_exhaustive]
29
31
SyntaxError { message : String } ,
30
32
31
33
/// The end of the BSON input was reached too soon.
32
34
EndOfStream ,
33
35
34
36
/// An invalid datetime was encountered while decoding.
37
+ #[ non_exhaustive]
35
38
InvalidDateTime {
36
39
/// The key at which an unexpected/unsupported datetime was encountered.
37
40
key : String ,
@@ -42,6 +45,7 @@ pub enum Error {
42
45
43
46
/// A general error encountered during deserialization.
44
47
/// See: https://docs.serde.rs/serde/de/trait.Error.html
48
+ #[ non_exhaustive]
45
49
DeserializationError {
46
50
/// A message describing the error.
47
51
message : String ,
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ use crate::{
23
23
spec:: BinarySubtype ,
24
24
} ;
25
25
26
- pub struct BsonVisitor ;
26
+ pub ( crate ) struct BsonVisitor ;
27
27
28
28
impl < ' de > Deserialize < ' de > for ObjectId {
29
29
fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
Original file line number Diff line number Diff line change @@ -12,16 +12,14 @@ pub enum Error {
12
12
IoError ( Arc < io:: Error > ) ,
13
13
14
14
/// A key could not be serialized to a BSON string.
15
- InvalidMapKeyType {
16
- /// The value that could not be used as a key.
17
- key : Bson ,
18
- } ,
15
+ InvalidDocumentKey ( Bson ) ,
19
16
20
17
/// Attempted to serialize a sub-millisecond precision datetime, which BSON does not support.
21
18
SubMillisecondPrecisionDateTime ( crate :: DateTime ) ,
22
19
23
20
/// A general error that ocurred during serialization.
24
21
/// See: https://docs.rs/serde/1.0.110/serde/ser/trait.Error.html#tymethod.custom
22
+ #[ non_exhaustive]
25
23
SerializationError {
26
24
/// A message describing the error.
27
25
message : String ,
@@ -50,7 +48,7 @@ impl fmt::Display for Error {
50
48
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
51
49
match * self {
52
50
Error :: IoError ( ref inner) => inner. fmt ( fmt) ,
53
- Error :: InvalidMapKeyType { ref key } => write ! ( fmt, "Invalid map key type: {}" , key) ,
51
+ Error :: InvalidDocumentKey ( ref key) => write ! ( fmt, "Invalid map key type: {}" , key) ,
54
52
Error :: SerializationError { ref message } => message. fmt ( fmt) ,
55
53
#[ cfg( not( feature = "u2i" ) ) ]
56
54
Error :: UnsupportedUnsignedInteger ( value) => write ! (
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ impl Serialize for Bson {
84
84
}
85
85
86
86
/// Serde Serializer
87
+ #[ non_exhaustive]
87
88
pub struct Serializer ;
88
89
89
90
impl Serializer {
@@ -440,7 +441,7 @@ impl SerializeMap for MapSerializer {
440
441
fn serialize_key < T : ?Sized + Serialize > ( & mut self , key : & T ) -> crate :: ser:: Result < ( ) > {
441
442
self . next_key = match to_bson ( & key) ? {
442
443
Bson :: String ( s) => Some ( s) ,
443
- other => return Err ( Error :: InvalidMapKeyType { key : other } ) ,
444
+ other => return Err ( Error :: InvalidDocumentKey ( other) ) ,
444
445
} ;
445
446
Ok ( ( ) )
446
447
}
You can’t perform that action at this time.
0 commit comments