aboutsummaryrefslogtreecommitdiff
path: root/src/raw
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-05-02 15:08:59 +0200
committerDaniel Schadt <kingdread@gmx.de>2020-05-02 15:08:59 +0200
commite0e9481b6edccfb6292e1842f6e330d07388010c (patch)
tree44e841cbe88f2b86fecc4f48acaf655960dd9d80 /src/raw
parente54b6aa3a1dc6cbdcde07c075b2d7bd18cc2e729 (diff)
downloadevtclib-e0e9481b6edccfb6292e1842f6e330d07388010c.tar.gz
evtclib-e0e9481b6edccfb6292e1842f6e330d07388010c.tar.bz2
evtclib-e0e9481b6edccfb6292e1842f6e330d07388010c.zip
add docs about parse_events and the parser
Diffstat (limited to 'src/raw')
-rw-r--r--src/raw/parser.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/raw/parser.rs b/src/raw/parser.rs
index 00ca85e..bf61f8c 100644
--- a/src/raw/parser.rs
+++ b/src/raw/parser.rs
@@ -284,6 +284,25 @@ pub fn parse_skill<R: Read>(mut input: R) -> ParseResult<Skill> {
///
/// * `input` - Input stream.
/// * `parser` - The parse function to use.
+///
+/// The `parser` should be one of [`parse_event_rev0`][parse_event_rev0] or
+/// [`parse_event_rev1`][parse_event_rev1], depending on the revision of the file you are dealing
+/// with. Note that you might have to pass them as a closure, otherwise the type conversion might
+/// not succeed:
+///
+/// ```no_run
+/// # use evtclib::raw::parser::{parse_events, parse_event_rev0};
+/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
+/// use std::fs::File;
+/// let file = File::open("the-log.evtc")?;
+/// // other parsing here
+/// let events = parse_events(file, |i| parse_event_rev0(i))?;
+/// # Ok(())
+/// # }
+/// ```
+///
+/// If you use one of the higher-level functions, such as [`parse_file`][parse_file] or
+/// [`finish_parsing`][finish_parsing], you do not have to concern yourself with that detail.
pub fn parse_events<R: Read>(
mut input: R,
parser: fn(&mut R) -> ParseResult<CbtEvent>,