@@ -14,11 +14,11 @@ use std::{borrow::Cow, ops::Range};
1414/// A struct representing a key/value XML attribute.
1515///
1616/// Field `value` stores raw bytes, possibly containing escape-sequences. Most users will likely
17- /// want to access the value using one of the [`unescaped_value`] and [`unescape_and_decode_value `]
17+ /// want to access the value using one of the [`unescaped_value`] and [`decode_and_unescape_value `]
1818/// functions.
1919///
2020/// [`unescaped_value`]: Self::unescaped_value
21- /// [`unescape_and_decode_value `]: Self::unescape_and_decode_value
21+ /// [`decode_and_unescape_value `]: Self::decode_and_unescape_value
2222#[ derive( Clone , PartialEq ) ]
2323pub struct Attribute < ' a > {
2424 /// The key to uniquely define the attribute.
@@ -37,32 +37,33 @@ impl<'a> Attribute<'a> {
3737 ///
3838 /// This will allocate if the value contains any escape sequences.
3939 ///
40- /// See also [`unescaped_value_with_custom_entities ()`](Self::unescaped_value_with_custom_entities )
40+ /// See also [`unescaped_value_with ()`](Self::unescaped_value_with )
4141 pub fn unescaped_value ( & self ) -> XmlResult < Cow < [ u8 ] > > {
42- self . unescaped_value_with_custom_entities ( |_| None )
42+ self . unescaped_value_with ( |_| None )
4343 }
4444
4545 /// Returns the unescaped value, using custom entities.
4646 ///
4747 /// This is normally the value you are interested in. Escape sequences such as `>` are
4848 /// replaced with their unescaped equivalents such as `>`.
49- /// Additional entities can be provided in `custom_entities`.
49+ /// A fallback resolver for additional custom entities can be provided via
50+ /// `resolve_entities`.
5051 ///
5152 /// This will allocate if the value contains any escape sequences.
5253 ///
5354 /// See also [`unescaped_value()`](Self::unescaped_value)
5455 ///
5556 /// # Pre-condition
5657 ///
57- /// The keys and values of `custom_entities`, if any, must be valid UTF-8.
58- pub fn unescaped_value_with_custom_entities < ' s , ' entity > (
58+ /// The implementation of `resolve_entity` is expected to operate over UTF-8 inputs .
59+ pub fn unescaped_value_with < ' s , ' entity > (
5960 & ' s self ,
6061 resolve_entity : impl Fn ( & [ u8 ] ) -> Option < & ' entity str > ,
6162 ) -> XmlResult < Cow < ' s , [ u8 ] > > {
6263 unescape_with ( & * self . value , resolve_entity) . map_err ( Error :: EscapeError )
6364 }
6465
65- /// Decode then unescapes the value
66+ /// Decodes then unescapes the value
6667 ///
6768 /// This allocates a `String` in all cases. For performance reasons it might be a better idea to
6869 /// instead use one of:
@@ -72,25 +73,25 @@ impl<'a> Attribute<'a> {
7273 ///
7374 /// [`unescaped_value()`]: Self::unescaped_value
7475 /// [`Reader::decoder().decode()`]: crate::reader::Decoder::decode
75- pub fn unescape_and_decode_value < B > ( & self , reader : & Reader < B > ) -> XmlResult < String > {
76- self . unescape_and_decode_value_with_custom_entities ( reader, |_| None )
76+ pub fn decode_and_unescape_value < B > ( & self , reader : & Reader < B > ) -> XmlResult < String > {
77+ self . decode_and_unescape_value_with ( reader, |_| None )
7778 }
7879
79- /// Decode then unescapes the value with custom entities
80+ /// Decodes then unescapes the value with custom entities
8081 ///
8182 /// This allocates a `String` in all cases. For performance reasons it might be a better idea to
8283 /// instead use one of:
8384 ///
8485 /// * [`Reader::decoder().decode()`], as it only allocates when the decoding can't be performed otherwise.
85- /// * [`unescaped_value_with_custom_entities ()`], as it doesn't allocate when no escape sequences are used.
86+ /// * [`unescaped_value_with ()`], as it doesn't allocate when no escape sequences are used.
8687 ///
87- /// [`unescaped_value_with_custom_entities ()`]: Self::unescaped_value_with_custom_entities
88+ /// [`unescaped_value_with ()`]: Self::unescaped_value_with
8889 /// [`Reader::decoder().decode()`]: crate::reader::Decoder::decode
8990 ///
9091 /// # Pre-condition
9192 ///
92- /// The keys and values of `custom_entities`, if any, must be valid UTF-8.
93- pub fn unescape_and_decode_value_with_custom_entities < ' entity , B > (
93+ /// The implementation of `resolve_entity` is expected to operate over UTF-8 inputs .
94+ pub fn decode_and_unescape_value_with < ' entity , B > (
9495 & self ,
9596 reader : & Reader < B > ,
9697 resolve_entity : impl Fn ( & [ u8 ] ) -> Option < & ' entity str > ,
0 commit comments