Skip to content

Commit

Permalink
Change names of methods that emits events to reflect their purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Jun 12, 2023
1 parent 70f4a9c commit 7629a70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ macro_rules! read_until_open {
$(.$await)?
{
// Return Text event with `bytes` content
Ok(Some(bytes)) => $self.parser.read_text(bytes).map(Ok),
Ok(Some(bytes)) => $self.parser.emit_text(bytes).map(Ok),
Ok(None) => Ok(Ok(Event::Eof)),
Err(e) => Err(e),
}
Expand Down Expand Up @@ -287,7 +287,7 @@ macro_rules! read_until_close {
$(.$await)?
{
Ok(None) => Ok(Event::Eof),
Ok(Some((bang_type, bytes))) => $self.parser.read_bang(bang_type, bytes),
Ok(Some((bang_type, bytes))) => $self.parser.emit_bang(bang_type, bytes),
Err(e) => Err(e),
},
// `</` - closing tag
Expand All @@ -296,7 +296,7 @@ macro_rules! read_until_close {
$(.$await)?
{
Ok(None) => Ok(Event::Eof),
Ok(Some(bytes)) => $self.parser.read_end(bytes),
Ok(Some(bytes)) => $self.parser.emit_end(bytes),
Err(e) => Err(e),
},
// `<?` - processing instruction
Expand All @@ -305,7 +305,7 @@ macro_rules! read_until_close {
$(.$await)?
{
Ok(None) => Ok(Event::Eof),
Ok(Some(bytes)) => $self.parser.read_question_mark(bytes),
Ok(Some(bytes)) => $self.parser.emit_question_mark(bytes),
Err(e) => Err(e),
},
// `<...` - opening or self-closed tag
Expand All @@ -314,7 +314,7 @@ macro_rules! read_until_close {
$(.$await)?
{
Ok(None) => Ok(Event::Eof),
Ok(Some(bytes)) => $self.parser.read_start(bytes),
Ok(Some(bytes)) => $self.parser.emit_start(bytes),
Err(e) => Err(e),
},
Ok(None) => Ok(Event::Eof),
Expand Down
10 changes: 5 additions & 5 deletions src/reader/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Parser {
/// - `bytes`: data from the start of stream to the first `<` or from `>` to `<`
///
/// [`Text`]: Event::Text
pub fn read_text<'b>(&mut self, bytes: &'b [u8]) -> Result<Event<'b>> {
pub fn emit_text<'b>(&mut self, bytes: &'b [u8]) -> Result<Event<'b>> {
let mut content = bytes;

if self.trim_text_end {
Expand All @@ -82,7 +82,7 @@ impl Parser {

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

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

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

0 comments on commit 7629a70

Please sign in to comment.