Module libpobsd::db

source ·
Expand description

Povides a GameDataBase, GameFilter and a QueryResult structs, each struct providing a set of methods to interrogate the PlayOnBSD database in a friendly manner, without having to deal with a SQL database.

The GameDataBase is created from a vector of [models::Game] usually obtained from the PlayOnBSD database using the [parsing::Parser].

§Examples

Create a GameDataBase from the PlayOnBSD database.

use libpobsd::{GameDataBase, Game, Parser, ParserResult, ParsingMode};
// loading the games from the PlayOnBSD database
let games = match Parser::new(ParsingMode::Strict)
       .load_from_file("games.db")
       .expect("Could not open the file")
   {
       ParserResult::WithoutError(games) => games,
       ParserResult::WithError(games, _) => games,
   };
GameDataBase::new(games);

Get a game by name.

use libpobsd::SearchType;
let st = SearchType::CaseSensitive;
if let Some(game) = db.get_game_by_name("My Game", &st){
    assert_eq!(&game.name, "My Game");
};

Get all games associated to a given tag.

let game_query = db.match_games_by_tag("indie");
// check the first element of the query
if let Some(game) = game_query.get(0) {
    if let Some(tags) = &game.tags {
        assert!(tags.join(" ").contains("indie"));
    };
};

Re-exports§

Modules§

Enums§

  • Define the type of search performed. It can be either case sensitive or cas insensitive (default).

Type Aliases§

  • Representation of items such as pub, tags, etc.