@@ -612,16 +612,15 @@ where
612
612
unescape : bool ,
613
613
allow_start : bool ,
614
614
) -> Result < Cow < ' de , str > , DeError > {
615
- let decoder = self . reader . decoder ( ) ;
616
615
match self . next ( ) ? {
617
- DeEvent :: Text ( e) => Ok ( e. decode ( decoder , unescape) ?) ,
618
- DeEvent :: CData ( e) => Ok ( e. decode ( decoder ) ?) ,
616
+ DeEvent :: Text ( e) => Ok ( e. decode ( unescape) ?) ,
617
+ DeEvent :: CData ( e) => Ok ( e. decode ( ) ?) ,
619
618
DeEvent :: Start ( e) if allow_start => {
620
619
// allow one nested level
621
620
let inner = self . next ( ) ?;
622
621
let t = match inner {
623
- DeEvent :: Text ( t) => t. decode ( decoder , unescape) ?,
624
- DeEvent :: CData ( t) => t. decode ( decoder ) ?,
622
+ DeEvent :: Text ( t) => t. decode ( unescape) ?,
623
+ DeEvent :: CData ( t) => t. decode ( ) ?,
625
624
DeEvent :: Start ( s) => {
626
625
return Err ( DeError :: UnexpectedStart ( s. name ( ) . as_ref ( ) . to_owned ( ) ) )
627
626
}
@@ -1042,13 +1041,10 @@ mod tests {
1042
1041
assert_eq ! ( de. read, vec![ ] ) ;
1043
1042
assert_eq ! ( de. write, vec![ ] ) ;
1044
1043
1045
- assert_eq ! (
1046
- de. next( ) . unwrap( ) ,
1047
- Start ( BytesStart :: borrowed_name( b"root" ) )
1048
- ) ;
1044
+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name( "root" ) ) ) ;
1049
1045
assert_eq ! (
1050
1046
de. peek( ) . unwrap( ) ,
1051
- & Start ( BytesStart :: borrowed_name( b "inner") )
1047
+ & Start ( BytesStart :: borrowed_name( "inner" ) )
1052
1048
) ;
1053
1049
1054
1050
// Should skip first <inner> tree
@@ -1057,11 +1053,11 @@ mod tests {
1057
1053
assert_eq ! (
1058
1054
de. write,
1059
1055
vec![
1060
- Start ( BytesStart :: borrowed_name( b "inner") ) ,
1056
+ Start ( BytesStart :: borrowed_name( "inner" ) ) ,
1061
1057
Text ( BytesText :: from_escaped_str( "text" ) ) ,
1062
- Start ( BytesStart :: borrowed_name( b "inner") ) ,
1063
- End ( BytesEnd :: borrowed( b "inner") ) ,
1064
- End ( BytesEnd :: borrowed( b "inner") ) ,
1058
+ Start ( BytesStart :: borrowed_name( "inner" ) ) ,
1059
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1060
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1065
1061
]
1066
1062
) ;
1067
1063
@@ -1073,11 +1069,8 @@ mod tests {
1073
1069
// </inner>
1074
1070
// <target/>
1075
1071
// </root>
1076
- assert_eq ! (
1077
- de. next( ) . unwrap( ) ,
1078
- Start ( BytesStart :: borrowed_name( b"next" ) )
1079
- ) ;
1080
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b"next" ) ) ) ;
1072
+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name( "next" ) ) ) ;
1073
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "next" ) ) ) ;
1081
1074
1082
1075
// We finish writing. Next call to `next()` should start replay that messages:
1083
1076
//
@@ -1094,27 +1087,27 @@ mod tests {
1094
1087
assert_eq ! (
1095
1088
de. read,
1096
1089
vec![
1097
- Start ( BytesStart :: borrowed_name( b "inner") ) ,
1090
+ Start ( BytesStart :: borrowed_name( "inner" ) ) ,
1098
1091
Text ( BytesText :: from_escaped_str( "text" ) ) ,
1099
- Start ( BytesStart :: borrowed_name( b "inner") ) ,
1100
- End ( BytesEnd :: borrowed( b "inner") ) ,
1101
- End ( BytesEnd :: borrowed( b "inner") ) ,
1092
+ Start ( BytesStart :: borrowed_name( "inner" ) ) ,
1093
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1094
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1102
1095
]
1103
1096
) ;
1104
1097
assert_eq ! ( de. write, vec![ ] ) ;
1105
1098
assert_eq ! (
1106
1099
de. next( ) . unwrap( ) ,
1107
- Start ( BytesStart :: borrowed_name( b "inner") )
1100
+ Start ( BytesStart :: borrowed_name( "inner" ) )
1108
1101
) ;
1109
1102
1110
1103
// Skip `#text` node and consume <inner/> after it
1111
1104
de. skip ( ) . unwrap ( ) ;
1112
1105
assert_eq ! (
1113
1106
de. read,
1114
1107
vec![
1115
- Start ( BytesStart :: borrowed_name( b "inner") ) ,
1116
- End ( BytesEnd :: borrowed( b "inner") ) ,
1117
- End ( BytesEnd :: borrowed( b "inner") ) ,
1108
+ Start ( BytesStart :: borrowed_name( "inner" ) ) ,
1109
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1110
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1118
1111
]
1119
1112
) ;
1120
1113
assert_eq ! (
@@ -1128,9 +1121,9 @@ mod tests {
1128
1121
1129
1122
assert_eq ! (
1130
1123
de. next( ) . unwrap( ) ,
1131
- Start ( BytesStart :: borrowed_name( b "inner") )
1124
+ Start ( BytesStart :: borrowed_name( "inner" ) )
1132
1125
) ;
1133
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "inner") ) ) ;
1126
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "inner" ) ) ) ;
1134
1127
1135
1128
// We finish writing. Next call to `next()` should start replay messages:
1136
1129
//
@@ -1146,21 +1139,21 @@ mod tests {
1146
1139
de. read,
1147
1140
vec![
1148
1141
Text ( BytesText :: from_escaped_str( "text" ) ) ,
1149
- End ( BytesEnd :: borrowed( b "inner") ) ,
1142
+ End ( BytesEnd :: borrowed( "inner" ) ) ,
1150
1143
]
1151
1144
) ;
1152
1145
assert_eq ! ( de. write, vec![ ] ) ;
1153
1146
assert_eq ! (
1154
1147
de. next( ) . unwrap( ) ,
1155
1148
Text ( BytesText :: from_escaped_str( "text" ) )
1156
1149
) ;
1157
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "inner") ) ) ;
1150
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "inner" ) ) ) ;
1158
1151
assert_eq ! (
1159
1152
de. next( ) . unwrap( ) ,
1160
- Start ( BytesStart :: borrowed_name( b "target") )
1153
+ Start ( BytesStart :: borrowed_name( "target" ) )
1161
1154
) ;
1162
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "target") ) ) ;
1163
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "root") ) ) ;
1155
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "target" ) ) ) ;
1156
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "root" ) ) ) ;
1164
1157
}
1165
1158
1166
1159
/// Checks that `read_to_end()` behaves correctly after `skip()`
@@ -1184,22 +1177,19 @@ mod tests {
1184
1177
assert_eq ! ( de. read, vec![ ] ) ;
1185
1178
assert_eq ! ( de. write, vec![ ] ) ;
1186
1179
1187
- assert_eq ! (
1188
- de. next( ) . unwrap( ) ,
1189
- Start ( BytesStart :: borrowed_name( b"root" ) )
1190
- ) ;
1180
+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name( "root" ) ) ) ;
1191
1181
1192
1182
// Skip the <skip> tree
1193
1183
de. skip ( ) . unwrap ( ) ;
1194
1184
assert_eq ! ( de. read, vec![ ] ) ;
1195
1185
assert_eq ! (
1196
1186
de. write,
1197
1187
vec![
1198
- Start ( BytesStart :: borrowed_name( b "skip") ) ,
1188
+ Start ( BytesStart :: borrowed_name( "skip" ) ) ,
1199
1189
Text ( BytesText :: from_escaped_str( "text" ) ) ,
1200
- Start ( BytesStart :: borrowed_name( b "skip") ) ,
1201
- End ( BytesEnd :: borrowed( b "skip") ) ,
1202
- End ( BytesEnd :: borrowed( b "skip") ) ,
1190
+ Start ( BytesStart :: borrowed_name( "skip" ) ) ,
1191
+ End ( BytesEnd :: borrowed( "skip" ) ) ,
1192
+ End ( BytesEnd :: borrowed( "skip" ) ) ,
1203
1193
]
1204
1194
) ;
1205
1195
@@ -1212,18 +1202,18 @@ mod tests {
1212
1202
// </root>
1213
1203
assert_eq ! (
1214
1204
de. next( ) . unwrap( ) ,
1215
- Start ( BytesStart :: borrowed_name( b "target") )
1205
+ Start ( BytesStart :: borrowed_name( "target" ) )
1216
1206
) ;
1217
1207
de. read_to_end ( QName ( b"target" ) ) . unwrap ( ) ;
1218
1208
assert_eq ! ( de. read, vec![ ] ) ;
1219
1209
assert_eq ! (
1220
1210
de. write,
1221
1211
vec![
1222
- Start ( BytesStart :: borrowed_name( b "skip") ) ,
1212
+ Start ( BytesStart :: borrowed_name( "skip" ) ) ,
1223
1213
Text ( BytesText :: from_escaped_str( "text" ) ) ,
1224
- Start ( BytesStart :: borrowed_name( b "skip") ) ,
1225
- End ( BytesEnd :: borrowed( b "skip") ) ,
1226
- End ( BytesEnd :: borrowed( b "skip") ) ,
1214
+ Start ( BytesStart :: borrowed_name( "skip" ) ) ,
1215
+ End ( BytesEnd :: borrowed( "skip" ) ) ,
1216
+ End ( BytesEnd :: borrowed( "skip" ) ) ,
1227
1217
]
1228
1218
) ;
1229
1219
@@ -1241,22 +1231,19 @@ mod tests {
1241
1231
assert_eq ! (
1242
1232
de. read,
1243
1233
vec![
1244
- Start ( BytesStart :: borrowed_name( b "skip") ) ,
1234
+ Start ( BytesStart :: borrowed_name( "skip" ) ) ,
1245
1235
Text ( BytesText :: from_escaped_str( "text" ) ) ,
1246
- Start ( BytesStart :: borrowed_name( b "skip") ) ,
1247
- End ( BytesEnd :: borrowed( b "skip") ) ,
1248
- End ( BytesEnd :: borrowed( b "skip") ) ,
1236
+ Start ( BytesStart :: borrowed_name( "skip" ) ) ,
1237
+ End ( BytesEnd :: borrowed( "skip" ) ) ,
1238
+ End ( BytesEnd :: borrowed( "skip" ) ) ,
1249
1239
]
1250
1240
) ;
1251
1241
assert_eq ! ( de. write, vec![ ] ) ;
1252
1242
1253
- assert_eq ! (
1254
- de. next( ) . unwrap( ) ,
1255
- Start ( BytesStart :: borrowed_name( b"skip" ) )
1256
- ) ;
1243
+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name( "skip" ) ) ) ;
1257
1244
de. read_to_end ( QName ( b"skip" ) ) . unwrap ( ) ;
1258
1245
1259
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "root") ) ) ;
1246
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "root" ) ) ) ;
1260
1247
}
1261
1248
1262
1249
/// Checks that limiting buffer size works correctly
@@ -1306,34 +1293,31 @@ mod tests {
1306
1293
"# ,
1307
1294
) ;
1308
1295
1309
- assert_eq ! (
1310
- de. next( ) . unwrap( ) ,
1311
- Start ( BytesStart :: borrowed_name( b"root" ) )
1312
- ) ;
1296
+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name( "root" ) ) ) ;
1313
1297
1314
1298
assert_eq ! (
1315
1299
de. next( ) . unwrap( ) ,
1316
- Start ( BytesStart :: borrowed( br #"tag a="1""#, 3 ) )
1300
+ Start ( BytesStart :: borrowed( r #"tag a="1""#, 3 ) )
1317
1301
) ;
1318
1302
assert_eq ! ( de. read_to_end( QName ( b"tag" ) ) . unwrap( ) , ( ) ) ;
1319
1303
1320
1304
assert_eq ! (
1321
1305
de. next( ) . unwrap( ) ,
1322
- Start ( BytesStart :: borrowed( br #"tag a="2""#, 3 ) )
1306
+ Start ( BytesStart :: borrowed( r #"tag a="2""#, 3 ) )
1323
1307
) ;
1324
1308
assert_eq ! (
1325
1309
de. next( ) . unwrap( ) ,
1326
1310
CData ( BytesCData :: from_str( "cdata content" ) )
1327
1311
) ;
1328
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "tag") ) ) ;
1312
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "tag" ) ) ) ;
1329
1313
1330
1314
assert_eq ! (
1331
1315
de. next( ) . unwrap( ) ,
1332
- Start ( BytesStart :: borrowed ( b "self-closed", 11 ) )
1316
+ Start ( BytesStart :: borrowed_name ( "self-closed" ) )
1333
1317
) ;
1334
1318
assert_eq ! ( de. read_to_end( QName ( b"self-closed" ) ) . unwrap( ) , ( ) ) ;
1335
1319
1336
- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( b "root") ) ) ;
1320
+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "root" ) ) ) ;
1337
1321
assert_eq ! ( de. next( ) . unwrap( ) , Eof ) ;
1338
1322
}
1339
1323
@@ -1402,17 +1386,17 @@ mod tests {
1402
1386
events,
1403
1387
vec![
1404
1388
Start ( BytesStart :: borrowed(
1405
- br #"item name="hello" source="world.rs""#,
1389
+ r #"item name="hello" source="world.rs""#,
1406
1390
4
1407
1391
) ) ,
1408
1392
Text ( BytesText :: from_escaped_str( "Some text" ) ) ,
1409
- End ( BytesEnd :: borrowed( b "item") ) ,
1410
- Start ( BytesStart :: borrowed( b "item2", 5 ) ) ,
1411
- End ( BytesEnd :: borrowed( b "item2") ) ,
1412
- Start ( BytesStart :: borrowed( b "item3", 5 ) ) ,
1413
- End ( BytesEnd :: borrowed( b "item3") ) ,
1414
- Start ( BytesStart :: borrowed( br #"item4 value="world" "#, 5 ) ) ,
1415
- End ( BytesEnd :: borrowed( b "item4") ) ,
1393
+ End ( BytesEnd :: borrowed( "item" ) ) ,
1394
+ Start ( BytesStart :: borrowed( "item2" , 5 ) ) ,
1395
+ End ( BytesEnd :: borrowed( "item2" ) ) ,
1396
+ Start ( BytesStart :: borrowed( "item3" , 5 ) ) ,
1397
+ End ( BytesEnd :: borrowed( "item3" ) ) ,
1398
+ Start ( BytesStart :: borrowed( r #"item4 value="world" "#, 5 ) ) ,
1399
+ End ( BytesEnd :: borrowed( "item4" ) ) ,
1416
1400
]
1417
1401
)
1418
1402
}
@@ -1432,7 +1416,7 @@ mod tests {
1432
1416
1433
1417
assert_eq ! (
1434
1418
reader. next( ) . unwrap( ) ,
1435
- DeEvent :: Start ( BytesStart :: borrowed( b "item ", 4 ) )
1419
+ DeEvent :: Start ( BytesStart :: borrowed( "item " , 4 ) )
1436
1420
) ;
1437
1421
reader. read_to_end ( QName ( b"item" ) ) . unwrap ( ) ;
1438
1422
assert_eq ! ( reader. next( ) . unwrap( ) , DeEvent :: Eof ) ;
0 commit comments