Module pobsd_parser::parser

source ·
Expand description

This parser provides a simplistic Parser that converts the PlayOnBSD Database (either provided as a string or as a file) into a vector of Game objects.

Parser

A new parser can be create using the Parser::new method and proving a ParsingMode enum as only argument. The parsing supports two modes representend by the two variants of the ParsingMode enum:

  • strict mode (ParsingMode::Strict) in which the parsing will stop if a parsing error occurs returning the games processed before the error as well as the line in the input (file or string) where the error occured;
  • relaxed mode (ParsingMode::Relaxed) where the parsing will continue even after an error is encountered, the parsing resuming when reaching the next game after the parsing error ; it returns all the games that have been parsed as well as the lines that were ignored due to parsing errors.

The database can be provided as a string using the Parser::load_from_string method or as a file using the Parser::load_from_file method.

Returned value

The returned value depend on the method used to parse the PlayOnBSD database.

The Parser::load_from_string method returns an ParserResult enum. It has to variants:

The Parser::load_from_file method returns Result<ParserResult, std::io::Error>.

Structs

Enums

Traits