@@ -9,11 +9,11 @@ use crate::Bson;
9
9
#[ non_exhaustive]
10
10
pub enum Error {
11
11
/// A [`std::io::Error`](https://doc.rust-lang.org/std/io/struct.Error.html) encountered while deserializing.
12
- IoError ( Arc < io:: Error > ) ,
12
+ Io ( Arc < io:: Error > ) ,
13
13
14
14
/// A [`std::string::FromUtf8Error`](https://doc.rust-lang.org/std/string/struct.FromUtf8Error.html) encountered
15
15
/// while decoding a UTF-8 String from the input data.
16
- FromUtf8Error ( string:: FromUtf8Error ) ,
16
+ InvalidUtf8String ( string:: FromUtf8Error ) ,
17
17
18
18
/// While decoding a `Document` from bytes, an unexpected or unsupported element type was
19
19
/// encountered.
@@ -26,10 +26,6 @@ pub enum Error {
26
26
element_type : u8 ,
27
27
} ,
28
28
29
- /// There was an error with the syntactical structure of the BSON.
30
- #[ non_exhaustive]
31
- SyntaxError { message : String } ,
32
-
33
29
/// The end of the BSON input was reached too soon.
34
30
EndOfStream ,
35
31
@@ -54,21 +50,21 @@ pub enum Error {
54
50
55
51
impl From < io:: Error > for Error {
56
52
fn from ( err : io:: Error ) -> Error {
57
- Error :: IoError ( Arc :: new ( err) )
53
+ Error :: Io ( Arc :: new ( err) )
58
54
}
59
55
}
60
56
61
57
impl From < string:: FromUtf8Error > for Error {
62
58
fn from ( err : string:: FromUtf8Error ) -> Error {
63
- Error :: FromUtf8Error ( err)
59
+ Error :: InvalidUtf8String ( err)
64
60
}
65
61
}
66
62
67
63
impl fmt:: Display for Error {
68
64
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
69
65
match * self {
70
- Error :: IoError ( ref inner) => inner. fmt ( fmt) ,
71
- Error :: FromUtf8Error ( ref inner) => inner. fmt ( fmt) ,
66
+ Error :: Io ( ref inner) => inner. fmt ( fmt) ,
67
+ Error :: InvalidUtf8String ( ref inner) => inner. fmt ( fmt) ,
72
68
Error :: UnrecognizedDocumentElementType {
73
69
ref key,
74
70
element_type,
@@ -77,7 +73,6 @@ impl fmt::Display for Error {
77
73
"unrecognized element type for key \" {}\" : `{:#x}`" ,
78
74
key, element_type
79
75
) ,
80
- Error :: SyntaxError { ref message } => message. fmt ( fmt) ,
81
76
Error :: EndOfStream => fmt. write_str ( "end of stream" ) ,
82
77
Error :: DeserializationError { ref message } => message. fmt ( fmt) ,
83
78
Error :: InvalidDateTime { ref key, datetime } => {
@@ -90,8 +85,8 @@ impl fmt::Display for Error {
90
85
impl error:: Error for Error {
91
86
fn source ( & self ) -> Option < & ( dyn error:: Error + ' static ) > {
92
87
match * self {
93
- Error :: IoError ( ref inner) => Some ( inner. as_ref ( ) ) ,
94
- Error :: FromUtf8Error ( ref inner) => Some ( inner) ,
88
+ Error :: Io ( ref inner) => Some ( inner. as_ref ( ) ) ,
89
+ Error :: InvalidUtf8String ( ref inner) => Some ( inner) ,
95
90
_ => None ,
96
91
}
97
92
}
0 commit comments