@@ -221,6 +221,7 @@ pub use crate::errors::serialize::DeError;
221221use crate :: {
222222 errors:: Error ,
223223 events:: { BytesCData , BytesEnd , BytesStart , BytesText , Event } ,
224+ name:: QName ,
224225 reader:: Decoder ,
225226 Reader ,
226227} ;
@@ -646,7 +647,7 @@ where
646647 }
647648 DeEvent :: Eof => return Err ( DeError :: UnexpectedEof ) ,
648649 } ;
649- self . read_to_end ( e. name ( ) . as_ref ( ) ) ?;
650+ self . read_to_end ( e. name ( ) ) ?;
650651 Ok ( t)
651652 }
652653 DeEvent :: Start ( e) => Err ( DeError :: UnexpectedStart ( e. name ( ) . as_ref ( ) . to_owned ( ) ) ) ,
@@ -664,14 +665,14 @@ where
664665 /// Drops all events until event with [name](BytesEnd::name()) `name` won't be
665666 /// dropped. This method should be called after [`Self::next()`]
666667 #[ cfg( feature = "overlapped-lists" ) ]
667- fn read_to_end ( & mut self , name : & [ u8 ] ) -> Result < ( ) , DeError > {
668+ fn read_to_end ( & mut self , name : QName ) -> Result < ( ) , DeError > {
668669 let mut depth = 0 ;
669670 loop {
670671 match self . read . pop_front ( ) {
671- Some ( DeEvent :: Start ( e) ) if e. name ( ) . as_ref ( ) == name => {
672+ Some ( DeEvent :: Start ( e) ) if e. name ( ) == name => {
672673 depth += 1 ;
673674 }
674- Some ( DeEvent :: End ( e) ) if e. name ( ) . as_ref ( ) == name => {
675+ Some ( DeEvent :: End ( e) ) if e. name ( ) == name => {
675676 if depth == 0 {
676677 return Ok ( ( ) ) ;
677678 }
@@ -688,11 +689,11 @@ where
688689 }
689690 }
690691 #[ cfg( not( feature = "overlapped-lists" ) ) ]
691- fn read_to_end ( & mut self , name : & [ u8 ] ) -> Result < ( ) , DeError > {
692+ fn read_to_end ( & mut self , name : QName ) -> Result < ( ) , DeError > {
692693 // First one might be in self.peek
693694 match self . next ( ) ? {
694- DeEvent :: Start ( e) => self . reader . read_to_end ( e. name ( ) . as_ref ( ) ) ?,
695- DeEvent :: End ( e) if e. name ( ) . as_ref ( ) == name => return Ok ( ( ) ) ,
695+ DeEvent :: Start ( e) => self . reader . read_to_end ( e. name ( ) ) ?,
696+ DeEvent :: End ( e) if e. name ( ) == name => return Ok ( ( ) ) ,
696697 _ => ( ) ,
697698 }
698699 self . reader . read_to_end ( name)
@@ -760,7 +761,7 @@ where
760761 let name = e. name ( ) . as_ref ( ) . to_vec ( ) ;
761762 let map = map:: MapAccess :: new ( self , e, fields) ?;
762763 let value = visitor. visit_map ( map) ?;
763- self . read_to_end ( & name) ?;
764+ self . read_to_end ( QName ( & name) ) ?;
764765 Ok ( value)
765766 } else {
766767 Err ( DeError :: ExpectedStart )
@@ -791,7 +792,7 @@ where
791792 {
792793 match self . next ( ) ? {
793794 DeEvent :: Start ( s) => {
794- self . read_to_end ( s. name ( ) . as_ref ( ) ) ?;
795+ self . read_to_end ( s. name ( ) ) ?;
795796 visitor. visit_unit ( )
796797 }
797798 DeEvent :: Text ( _) | DeEvent :: CData ( _) => visitor. visit_unit ( ) ,
@@ -898,7 +899,7 @@ where
898899 V : Visitor < ' de > ,
899900 {
900901 match self . next ( ) ? {
901- DeEvent :: Start ( e) => self . read_to_end ( e. name ( ) . as_ref ( ) ) ?,
902+ DeEvent :: Start ( e) => self . read_to_end ( e. name ( ) ) ?,
902903 DeEvent :: End ( e) => return Err ( DeError :: UnexpectedEnd ( e. name ( ) . as_ref ( ) . to_owned ( ) ) ) ,
903904 DeEvent :: Eof => return Err ( DeError :: UnexpectedEof ) ,
904905 _ => ( ) ,
@@ -931,7 +932,7 @@ pub trait XmlRead<'i> {
931932
932933 /// Skips until end element is found. Unlike `next()` it will not allocate
933934 /// when it cannot satisfy the lifetime.
934- fn read_to_end ( & mut self , name : & [ u8 ] ) -> Result < ( ) , DeError > ;
935+ fn read_to_end ( & mut self , name : QName ) -> Result < ( ) , DeError > ;
935936
936937 /// A copy of the reader's decoder used to decode strings.
937938 fn decoder ( & self ) -> Decoder ;
@@ -966,7 +967,7 @@ impl<'i, R: BufRead> XmlRead<'i> for IoReader<R> {
966967 event
967968 }
968969
969- fn read_to_end ( & mut self , name : & [ u8 ] ) -> Result < ( ) , DeError > {
970+ fn read_to_end ( & mut self , name : QName ) -> Result < ( ) , DeError > {
970971 match self . reader . read_to_end ( name, & mut self . buf ) {
971972 Err ( Error :: UnexpectedEof ( _) ) => Err ( DeError :: UnexpectedEof ) ,
972973 other => Ok ( other?) ,
@@ -1002,7 +1003,7 @@ impl<'de> XmlRead<'de> for SliceReader<'de> {
10021003 }
10031004 }
10041005
1005- fn read_to_end ( & mut self , name : & [ u8 ] ) -> Result < ( ) , DeError > {
1006+ fn read_to_end ( & mut self , name : QName ) -> Result < ( ) , DeError > {
10061007 match self . reader . read_to_end_unbuffered ( name) {
10071008 Err ( Error :: UnexpectedEof ( _) ) => Err ( DeError :: UnexpectedEof ) ,
10081009 other => Ok ( other?) ,
@@ -1218,7 +1219,7 @@ mod tests {
12181219 de. next( ) . unwrap( ) ,
12191220 Start ( BytesStart :: borrowed_name( b"target" ) )
12201221 ) ;
1221- de. read_to_end ( b"target" ) . unwrap ( ) ;
1222+ de. read_to_end ( QName ( b"target" ) ) . unwrap ( ) ;
12221223 assert_eq ! ( de. read, vec![ ] ) ;
12231224 assert_eq ! (
12241225 de. write,
@@ -1258,7 +1259,7 @@ mod tests {
12581259 de. next( ) . unwrap( ) ,
12591260 Start ( BytesStart :: borrowed_name( b"skip" ) )
12601261 ) ;
1261- de. read_to_end ( b"skip" ) . unwrap ( ) ;
1262+ de. read_to_end ( QName ( b"skip" ) ) . unwrap ( ) ;
12621263
12631264 assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b"root" ) ) ) ;
12641265 }
@@ -1319,7 +1320,7 @@ mod tests {
13191320 de. next( ) . unwrap( ) ,
13201321 Start ( BytesStart :: borrowed( br#"tag a="1""# , 3 ) )
13211322 ) ;
1322- assert_eq ! ( de. read_to_end( b"tag" ) . unwrap( ) , ( ) ) ;
1323+ assert_eq ! ( de. read_to_end( QName ( b"tag" ) ) . unwrap( ) , ( ) ) ;
13231324
13241325 assert_eq ! (
13251326 de. next( ) . unwrap( ) ,
@@ -1335,7 +1336,7 @@ mod tests {
13351336 de. next( ) . unwrap( ) ,
13361337 Start ( BytesStart :: borrowed( b"self-closed" , 11 ) )
13371338 ) ;
1338- assert_eq ! ( de. read_to_end( b"self-closed" ) . unwrap( ) , ( ) ) ;
1339+ assert_eq ! ( de. read_to_end( QName ( b"self-closed" ) ) . unwrap( ) , ( ) ) ;
13391340
13401341 assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b"root" ) ) ) ;
13411342 assert_eq ! ( de. next( ) . unwrap( ) , Eof ) ;
@@ -1438,7 +1439,7 @@ mod tests {
14381439 reader. next( ) . unwrap( ) ,
14391440 DeEvent :: Start ( BytesStart :: borrowed( b"item " , 4 ) )
14401441 ) ;
1441- reader. read_to_end ( b"item" ) . unwrap ( ) ;
1442+ reader. read_to_end ( QName ( b"item" ) ) . unwrap ( ) ;
14421443 assert_eq ! ( reader. next( ) . unwrap( ) , DeEvent :: Eof ) ;
14431444 }
14441445
0 commit comments