From e0e9481b6edccfb6292e1842f6e330d07388010c Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 2 May 2020 15:08:59 +0200 Subject: add docs about parse_events and the parser --- src/raw/parser.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/raw') 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(mut input: R) -> ParseResult { /// /// * `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> { +/// 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( mut input: R, parser: fn(&mut R) -> ParseResult, -- cgit v1.2.3