Skip to content

Commit 7629a70

Browse files
committed
Change names of methods that emits events to reflect their purpose
1 parent 70f4a9c commit 7629a70

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/reader/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ macro_rules! read_until_open {
245245
$(.$await)?
246246
{
247247
// Return Text event with `bytes` content
248-
Ok(Some(bytes)) => $self.parser.read_text(bytes).map(Ok),
248+
Ok(Some(bytes)) => $self.parser.emit_text(bytes).map(Ok),
249249
Ok(None) => Ok(Ok(Event::Eof)),
250250
Err(e) => Err(e),
251251
}
@@ -287,7 +287,7 @@ macro_rules! read_until_close {
287287
$(.$await)?
288288
{
289289
Ok(None) => Ok(Event::Eof),
290-
Ok(Some((bang_type, bytes))) => $self.parser.read_bang(bang_type, bytes),
290+
Ok(Some((bang_type, bytes))) => $self.parser.emit_bang(bang_type, bytes),
291291
Err(e) => Err(e),
292292
},
293293
// `</` - closing tag
@@ -296,7 +296,7 @@ macro_rules! read_until_close {
296296
$(.$await)?
297297
{
298298
Ok(None) => Ok(Event::Eof),
299-
Ok(Some(bytes)) => $self.parser.read_end(bytes),
299+
Ok(Some(bytes)) => $self.parser.emit_end(bytes),
300300
Err(e) => Err(e),
301301
},
302302
// `<?` - processing instruction
@@ -305,7 +305,7 @@ macro_rules! read_until_close {
305305
$(.$await)?
306306
{
307307
Ok(None) => Ok(Event::Eof),
308-
Ok(Some(bytes)) => $self.parser.read_question_mark(bytes),
308+
Ok(Some(bytes)) => $self.parser.emit_question_mark(bytes),
309309
Err(e) => Err(e),
310310
},
311311
// `<...` - opening or self-closed tag
@@ -314,7 +314,7 @@ macro_rules! read_until_close {
314314
$(.$await)?
315315
{
316316
Ok(None) => Ok(Event::Eof),
317-
Ok(Some(bytes)) => $self.parser.read_start(bytes),
317+
Ok(Some(bytes)) => $self.parser.emit_start(bytes),
318318
Err(e) => Err(e),
319319
},
320320
Ok(None) => Ok(Event::Eof),

src/reader/parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Parser {
6565
/// - `bytes`: data from the start of stream to the first `<` or from `>` to `<`
6666
///
6767
/// [`Text`]: Event::Text
68-
pub fn read_text<'b>(&mut self, bytes: &'b [u8]) -> Result<Event<'b>> {
68+
pub fn emit_text<'b>(&mut self, bytes: &'b [u8]) -> Result<Event<'b>> {
6969
let mut content = bytes;
7070

7171
if self.trim_text_end {
@@ -82,7 +82,7 @@ impl Parser {
8282

8383
/// reads `BytesElement` starting with a `!`,
8484
/// return `Comment`, `CData` or `DocType` event
85-
pub fn read_bang<'b>(&mut self, bang_type: BangType, buf: &'b [u8]) -> Result<Event<'b>> {
85+
pub fn emit_bang<'b>(&mut self, bang_type: BangType, buf: &'b [u8]) -> Result<Event<'b>> {
8686
let uncased_starts_with = |string: &[u8], prefix: &[u8]| {
8787
string.len() >= prefix.len() && string[..prefix.len()].eq_ignore_ascii_case(prefix)
8888
};
@@ -131,7 +131,7 @@ impl Parser {
131131

132132
/// Wraps content of `buf` into the [`Event::End`] event. Does the check that
133133
/// end name matches the last opened start name if `self.check_end_names` is set.
134-
pub fn read_end<'b>(&mut self, buf: &'b [u8]) -> Result<Event<'b>> {
134+
pub fn emit_end<'b>(&mut self, buf: &'b [u8]) -> Result<Event<'b>> {
135135
// XML standard permits whitespaces after the markup name in closing tags.
136136
// Let's strip them from the buffer before comparing tag names.
137137
let name = if self.trim_markup_names_in_closing_tags {
@@ -182,7 +182,7 @@ impl Parser {
182182

183183
/// reads `BytesElement` starting with a `?`,
184184
/// return `Decl` or `PI` event
185-
pub fn read_question_mark<'b>(&mut self, buf: &'b [u8]) -> Result<Event<'b>> {
185+
pub fn emit_question_mark<'b>(&mut self, buf: &'b [u8]) -> Result<Event<'b>> {
186186
let len = buf.len();
187187
if len > 2 && buf[len - 1] == b'?' {
188188
if len > 5 && &buf[1..4] == b"xml" && is_whitespace(buf[4]) {
@@ -210,7 +210,7 @@ impl Parser {
210210
///
211211
/// # Parameters
212212
/// - `content`: Content of a tag between `<` and `>`
213-
pub fn read_start<'b>(&mut self, content: &'b [u8]) -> Result<Event<'b>> {
213+
pub fn emit_start<'b>(&mut self, content: &'b [u8]) -> Result<Event<'b>> {
214214
let len = content.len();
215215
let name_end = content
216216
.iter()

0 commit comments

Comments
 (0)