#openbsd #play-on-bsd

pobsd-db

Primitive database to query the PlayOnBSD database

5 releases

0.1.4 Mar 29, 2023
0.1.3 Mar 27, 2023
0.1.2 Mar 27, 2023
0.1.1 Mar 26, 2023
0.1.0 Mar 26, 2023

#1784 in Database interfaces

Download history 22/week @ 2024-09-21 1/week @ 2024-09-28

112 downloads per month
Used in wcip

MIT license

19KB
361 lines

Build Clippy Crates.io (latest) Docs.rs

pobsd-db

pobsd-db provides a primitive database relying on HashMap and providing a set of methods to interogate and filter the PlayOnBSD database.

See docs.rs for the details.


lib.rs:

This library provides a set of methods to interrogate the PlayOnBSD database in a friendly manner, without having to deal with a SQL database.

Examples

Create a GameDataBase from the PlayOnBSD database.

extern crate pobsd_db;
extern crate pobsd_parser;
use pobsd_db::GameDataBase;
use pobsd_parser::{Game, Parser, ParserResult, ParsingMode};
// loading the games from the 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.

if let Some(game) = db.get_game_by_name("My Game"){
    assert_eq!(&game.name, "My Game");
};

Get all games associated to a given tag.

let game_query = db.get_game_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"));
    };
};

Dependencies

~3–5MB
~92K SLoC