@@ -107,47 +107,48 @@ impl DbError {
107
107
let mut routine =None ;
108
108
109
109
while let Some ( field) = fields. next ( ) ?{
110
+ let value =String :: from_utf8_lossy ( field. value_bytes ( ) ) ;
110
111
match field. type_ ( ) {
111
- b'S' => severity =Some ( field . value ( ) . to_owned ( ) ) ,
112
- b'C' => code =Some ( SqlState :: from_code ( field . value ( ) ) ) ,
113
- b'M' => message =Some ( field . value ( ) . to_owned ( ) ) ,
114
- b'D' => detail =Some ( field . value ( ) . to_owned ( ) ) ,
115
- b'H' => hint =Some ( field . value ( ) . to_owned ( ) ) ,
112
+ b'S' => severity =Some ( value. into_owned ( ) ) ,
113
+ b'C' => code =Some ( SqlState :: from_code ( & value) ) ,
114
+ b'M' => message =Some ( value. into_owned ( ) ) ,
115
+ b'D' => detail =Some ( value. into_owned ( ) ) ,
116
+ b'H' => hint =Some ( value. into_owned ( ) ) ,
116
117
b'P' =>{
117
- normal_position =Some ( field . value ( ) . parse :: < u32 > ( ) . map_err ( |_|{
118
+ normal_position =Some ( value. parse :: < u32 > ( ) . map_err ( |_|{
118
119
io:: Error :: new (
119
120
io:: ErrorKind :: InvalidInput ,
120
121
"`P` field did not contain an integer" ,
121
122
)
122
123
} ) ?) ;
123
124
}
124
125
b'p' =>{
125
- internal_position =Some ( field . value ( ) . parse :: < u32 > ( ) . map_err ( |_|{
126
+ internal_position =Some ( value. parse :: < u32 > ( ) . map_err ( |_|{
126
127
io:: Error :: new (
127
128
io:: ErrorKind :: InvalidInput ,
128
129
"`p` field did not contain an integer" ,
129
130
)
130
131
} ) ?) ;
131
132
}
132
- b'q' => internal_query =Some ( field . value ( ) . to_owned ( ) ) ,
133
- b'W' => where_ =Some ( field . value ( ) . to_owned ( ) ) ,
134
- b's' => schema =Some ( field . value ( ) . to_owned ( ) ) ,
135
- b't' => table =Some ( field . value ( ) . to_owned ( ) ) ,
136
- b'c' => column =Some ( field . value ( ) . to_owned ( ) ) ,
137
- b'd' => datatype =Some ( field . value ( ) . to_owned ( ) ) ,
138
- b'n' => constraint =Some ( field . value ( ) . to_owned ( ) ) ,
139
- b'F' => file =Some ( field . value ( ) . to_owned ( ) ) ,
133
+ b'q' => internal_query =Some ( value. into_owned ( ) ) ,
134
+ b'W' => where_ =Some ( value. into_owned ( ) ) ,
135
+ b's' => schema =Some ( value. into_owned ( ) ) ,
136
+ b't' => table =Some ( value. into_owned ( ) ) ,
137
+ b'c' => column =Some ( value. into_owned ( ) ) ,
138
+ b'd' => datatype =Some ( value. into_owned ( ) ) ,
139
+ b'n' => constraint =Some ( value. into_owned ( ) ) ,
140
+ b'F' => file =Some ( value. into_owned ( ) ) ,
140
141
b'L' =>{
141
- line =Some ( field . value ( ) . parse :: < u32 > ( ) . map_err ( |_|{
142
+ line =Some ( value. parse :: < u32 > ( ) . map_err ( |_|{
142
143
io:: Error :: new (
143
144
io:: ErrorKind :: InvalidInput ,
144
145
"`L` field did not contain an integer" ,
145
146
)
146
147
} ) ?) ;
147
148
}
148
- b'R' => routine =Some ( field . value ( ) . to_owned ( ) ) ,
149
+ b'R' => routine =Some ( value. into_owned ( ) ) ,
149
150
b'V' =>{
150
- parsed_severity =Some ( Severity :: from_str ( field . value ( ) ) . ok_or_else ( ||{
151
+ parsed_severity =Some ( Severity :: from_str ( & value) . ok_or_else ( ||{
151
152
io:: Error :: new (
152
153
io:: ErrorKind :: InvalidInput ,
153
154
"`V` field contained an invalid value" ,