libpobsd 0.1.2

Library to interact with the PlayOnBSD database
Documentation

check test codecov Crates.io (latest) Docs.rs

libpobsd

The PlayOnBSD database is a human readable database listing commercial games that can be played on OpenBSD.

The libpobsd provides a Parser to parse the PlayOnBSD database and a GameDataBase to query the PlayOnBSD database.

Examples

Loading the games (represented by the Game struct) from the database:

use libpobsd::{Parser, ParserResult};
let games = match Parser::default()
           .load_from_file("openbsd-games.db")
           .expect("Failed to load database") {
    ParserResult::WithoutError(games) => games,
    ParserResult::WithError(games, _) => games,
};

Loading the games into the GameDataBase:

use libpobsd::{Parser, ParserResult, GameDataBase};
let games = match Parser::default()
           .load_from_file("openbsd-games.db")
           .expect("Failed to load database") {
    ParserResult::WithoutError(games) => games,
    ParserResult::WithError(games, _) => games,
};
let db = GameDataBase::new(games);

Search games by name:

use libpobsd::{Parser, ParserResult, GameDataBase};
let games = match Parser::default()
           .load_from_file("openbsd-games.db")
           .expect("Failed to load database") {
    ParserResult::WithoutError(games) => games,
    ParserResult::WithError(games, _) => games,
};
let db = GameDataBase::new(games);
let games = db.search_game_by_name("Barrow");

Filter a query result (represented by the QueryResult struct) by year:

use libpobsd::{Parser, ParserResult, GameDataBase};
let games = match Parser::default()
           .load_from_file("openbsd-games.db")
           .expect("Failed to load database") {
    ParserResult::WithoutError(games) => games,
    ParserResult::WithError(games, _) => games,
};
let db = GameDataBase::new(games);
let games = db.search_game_by_name("Barrow");
let games = games.get_game_by_year("2018");

List the games of a query result:

use libpobsd::{Parser, ParserResult, GameDataBase};
let games = match Parser::default()
           .load_from_file("openbsd-games.db")
           .expect("Failed to load database") {
    ParserResult::WithoutError(games) => games,
    ParserResult::WithError(games, _) => games,
};
let db = GameDataBase::new(games);
let games = db.search_game_by_name("Barrow");
for game in games.into_inner() {
    println!("Game: {}", game.name);
}

More examples are available in the documentation of each module.