Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Mar 31, 2024
1 parent 910a499 commit 068b50d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ pub fn is_whitespace_str(s: &str) -> bool {
s.chars().all(is_whitespace_char)
}

/// Is it a valid character in XML 1.0
#[must_use] pub fn is_xml10_char(c: char) -> bool {
matches!(c, '\u{09}' | '\u{0A}' | '\u{0D}' | '\u{20}'..='\u{D7FF}' | '\u{E000}'..='\u{FFFD}' | '\u{10000}'..)
}

/// Is it a valid character in XML 1.1
#[must_use] pub fn is_xml11_char(c: char) -> bool {
matches!(c, '\u{01}'..='\u{D7FF}' | '\u{E000}'..='\u{FFFD}' | '\u{10000}'..)
}

/// Is it a valid character in XML 1.1 but not part of the restricted character set
#[must_use] pub fn is_xml11_char_not_restricted(c: char) -> bool {
is_xml11_char(c) && !matches!(c, '\u{01}'..='\u{08}' | '\u{0B}'..='\u{0C}' | '\u{0E}'..='\u{1F}' | '\u{7F}'..='\u{84}' | '\u{86}'..='\u{9F}')
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#![warn(missing_doc)]
#![warn(missing_docs)]
#![forbid(non_camel_case_types)]
#![forbid(unsafe_code)]
#![allow(clippy::redundant_closure_for_method_calls)]
Expand Down
14 changes: 14 additions & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ impl<R: Read> EventReader<R> {
Ok(())
}

/// Access underlying reader
///
/// Using it directly while the event reader is parsing is not recommended
pub fn source(&self) -> &R { &self.source }

/// Access underlying reader
///
/// Using it directly while the event reader is parsing is not recommended
pub fn source_mut(&mut self) -> &mut R { &mut self.source }

/// Unwraps this `EventReader`, returning the underlying reader.
Expand Down Expand Up @@ -122,7 +129,14 @@ impl<R: Read> Events<R> {
self.reader
}

/// Access the underlying reader
///
/// It's not recommended to use it while the events are still being parsed
pub fn source(&self) -> &R { &self.reader.source }

/// Access the underlying reader
///
/// It's not recommended to use it while the events are still being parsed
pub fn source_mut(&mut self) -> &mut R { &mut self.reader.source }

}
Expand Down
3 changes: 2 additions & 1 deletion src/reader/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct ParserConfig {
/// By default the parser will either error out when it encounters a premature end of
/// stream or complete normally if the end of stream was expected. If you want to continue
/// reading from a stream whose input is supplied progressively, you can set this option to true.
/// In this case the parser will allow you to invoke the next() method even if a supposed end
/// In this case the parser will allow you to invoke the `next()` method even if a supposed end
/// of stream has happened.
///
/// Note that support for this functionality is incomplete; for example, the parser will fail if
Expand Down Expand Up @@ -242,6 +242,7 @@ impl Default for ParserConfig2 {
}

impl ParserConfig2 {
/// Create extended configuration struct
#[inline]
#[must_use]
pub fn new() -> Self {
Expand Down
6 changes: 6 additions & 0 deletions src/reader/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ use std::str;
use crate::common::{Position, TextPosition};
use crate::util;

/// Failure reason
#[derive(Debug)]
pub enum ErrorKind {
/// This is an ill-formed XML document
Syntax(Cow<'static, str>),
/// Reader/writer reported an error
Io(io::Error),
/// The document contains bytes that are not allowed in UTF-8 strings
Utf8(str::Utf8Error),
/// The document ended while they were elements/comments/etc. still open
UnexpectedEof,
}

Expand Down Expand Up @@ -166,6 +171,7 @@ impl Error {
}
}

/// Failure reason
#[must_use]
#[inline]
pub fn kind(&self) -> &ErrorKind {
Expand Down
2 changes: 1 addition & 1 deletion src/reader/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ enum State {
DoctypeStarted(DoctypeStartedSubstate),
/// Other items like `<!ELEMENT` in DTD
InsideMarkupDeclaration,
/// Triggered after DoctypeStarted to handle sub elements
/// Triggered after `DoctypeStarted` to handle sub elements
InsideDoctype,
/// Triggered on '<![' up to '<![CDATA'
CDataStarted(CDataStartedSubstate),
Expand Down
1 change: 1 addition & 0 deletions src/writer/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ impl<'a> From<&'a str> for XmlEvent<'a> {
}
}

/// A builder for a closing element event.
pub struct EndElementBuilder<'a> {
name: Option<Name<'a>>,
}
Expand Down

0 comments on commit 068b50d

Please sign in to comment.