Skip to content

Commit 6894362

Browse files
committed
Explicitly recommend using xml_content() instead of decode() in events
1 parent d064697 commit 6894362

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/events/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ impl<'a> BytesText<'a> {
582582
///
583583
/// This will allocate if the value contains any escape sequences or in
584584
/// non-UTF-8 encoding.
585+
///
586+
/// This method does not normalizes end-of-line characters as required by [specification].
587+
/// Usually you need [`xml_content()`](Self::xml_content) instead of this method.
588+
///
589+
/// [specification]: https://www.w3.org/TR/xml11/#sec-line-ends
585590
pub fn decode(&self) -> Result<Cow<'a, str>, EncodingError> {
586591
self.decoder.decode_cow(&self.content)
587592
}
@@ -870,6 +875,11 @@ impl<'a> BytesCData<'a> {
870875
/// When this event produced by the XML reader, it uses the encoding information
871876
/// associated with that reader to interpret the raw bytes contained within this
872877
/// CDATA event.
878+
///
879+
/// This method does not normalizes end-of-line characters as required by [specification].
880+
/// Usually you need [`xml_content()`](Self::xml_content) instead of this method.
881+
///
882+
/// [specification]: https://www.w3.org/TR/xml11/#sec-line-ends
873883
pub fn decode(&self) -> Result<Cow<'a, str>, EncodingError> {
874884
self.decoder.decode_cow(&self.content)
875885
}
@@ -1524,6 +1534,11 @@ impl<'a> BytesRef<'a> {
15241534
///
15251535
/// This will allocate if the value contains any escape sequences or in
15261536
/// non-UTF-8 encoding.
1537+
///
1538+
/// This method does not normalizes end-of-line characters as required by [specification].
1539+
/// Usually you need [`xml_content()`](Self::xml_content) instead of this method.
1540+
///
1541+
/// [specification]: https://www.w3.org/TR/xml11/#sec-line-ends
15271542
pub fn decode(&self) -> Result<Cow<'a, str>, EncodingError> {
15281543
self.decoder.decode_cow(&self.content)
15291544
}

0 commit comments

Comments
 (0)