@@ -4,6 +4,7 @@ use crate::escape::EscapeError;
44use crate :: events:: attributes:: AttrError ;
55use crate :: utils:: write_byte_string;
66use std:: str:: Utf8Error ;
7+ use std:: string:: FromUtf8Error ;
78
89/// The error type used by this crate.
910#[ derive( Debug ) ]
@@ -53,6 +54,14 @@ impl From<Utf8Error> for Error {
5354 }
5455}
5556
57+ impl From < FromUtf8Error > for Error {
58+ /// Creates a new `Error::Utf8` from the given error
59+ #[ inline]
60+ fn from ( error : FromUtf8Error ) -> Error {
61+ error. utf8_error ( ) . into ( )
62+ }
63+ }
64+
5665impl From < EscapeError > for Error {
5766 /// Creates a new `Error::EscapeError` from the given error
5867 #[ inline]
@@ -227,6 +236,7 @@ pub mod serialize {
227236 }
228237
229238 impl From < Error > for DeError {
239+ #[ inline]
230240 fn from ( e : Error ) -> Self {
231241 Self :: InvalidXml ( e)
232242 }
@@ -239,15 +249,17 @@ pub mod serialize {
239249 }
240250 }
241251
242- impl From < ParseIntError > for DeError {
243- fn from ( e : ParseIntError ) -> Self {
244- Self :: InvalidInt ( e)
252+ impl From < Utf8Error > for DeError {
253+ #[ inline]
254+ fn from ( e : Utf8Error ) -> Self {
255+ Self :: InvalidXml ( e. into ( ) )
245256 }
246257 }
247258
248- impl From < ParseFloatError > for DeError {
249- fn from ( e : ParseFloatError ) -> Self {
250- Self :: InvalidFloat ( e)
259+ impl From < FromUtf8Error > for DeError {
260+ #[ inline]
261+ fn from ( e : FromUtf8Error ) -> Self {
262+ Self :: InvalidXml ( e. into ( ) )
251263 }
252264 }
253265
@@ -257,4 +269,18 @@ pub mod serialize {
257269 Self :: InvalidXml ( e. into ( ) )
258270 }
259271 }
272+
273+ impl From < ParseIntError > for DeError {
274+ #[ inline]
275+ fn from ( e : ParseIntError ) -> Self {
276+ Self :: InvalidInt ( e)
277+ }
278+ }
279+
280+ impl From < ParseFloatError > for DeError {
281+ #[ inline]
282+ fn from ( e : ParseFloatError ) -> Self {
283+ Self :: InvalidFloat ( e)
284+ }
285+ }
260286}
0 commit comments