diff --git a/src/common.rs b/src/common.rs index 0b324f26..8c71f43b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -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}') } diff --git a/src/lib.rs b/src/lib.rs index 40a4f212..8f50eb75 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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)] diff --git a/src/reader.rs b/src/reader.rs index 20a790c6..d900dbeb 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -76,7 +76,14 @@ impl EventReader { 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. @@ -122,7 +129,14 @@ impl Events { 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 } } diff --git a/src/reader/config.rs b/src/reader/config.rs index 7b5b5f7f..7e00829d 100644 --- a/src/reader/config.rs +++ b/src/reader/config.rs @@ -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 @@ -242,6 +242,7 @@ impl Default for ParserConfig2 { } impl ParserConfig2 { + /// Create extended configuration struct #[inline] #[must_use] pub fn new() -> Self { diff --git a/src/reader/error.rs b/src/reader/error.rs index f1c59117..3095dc49 100644 --- a/src/reader/error.rs +++ b/src/reader/error.rs @@ -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, } @@ -166,6 +171,7 @@ impl Error { } } + /// Failure reason #[must_use] #[inline] pub fn kind(&self) -> &ErrorKind { diff --git a/src/reader/lexer.rs b/src/reader/lexer.rs index cfd45d61..820df3e3 100644 --- a/src/reader/lexer.rs +++ b/src/reader/lexer.rs @@ -137,7 +137,7 @@ enum State { DoctypeStarted(DoctypeStartedSubstate), /// Other items like ` From<&'a str> for XmlEvent<'a> { } } +/// A builder for a closing element event. pub struct EndElementBuilder<'a> { name: Option>, }