8 unstable releases (3 breaking)

0.4.0 Oct 3, 2024
0.3.1 Jul 23, 2024
0.3.0 Jun 2, 2024
0.2.0 Mar 13, 2024
0.1.1 Apr 15, 2023

#510 in Database interfaces

Download history 14/week @ 2024-09-16 19/week @ 2024-09-23 153/week @ 2024-09-30 13/week @ 2024-10-07 13/week @ 2024-10-14

440 downloads per month
Used in pobsd-browser

MIT license

110KB
2.5K SLoC

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.

See documentation for more information.


lib.rs:

The PlayOnBSD database is a human readable database listing commercial games that can be played on OpenBSD. Currently, each game is represented by 17 lines (one for each field), in the following order:

  1. Game: string, leading "A " or "The " treated specially for alphabetic ordering
  2. Cover: path to cover art image file (.png, .jpg)
  3. Engine: string of valid engine entry
  4. Setup: string (package, command, text)
  5. Runtime: string; should correspond to an executable in packages
  6. Store: strings of URLs, whitespace-separated
  7. Hints: string
  8. Genre: strings, comma-separated
  9. Tags: strings, comma-separated
  10. Year: integer (release year)
  11. Dev: string (developer), comma-separated
  12. Pub: string (publisher), comma-separated
  13. Version: version number/string
  14. Status: numerical status with date when tested on -current in parentheses (doesn't apply to upstream bugs that have nothing to do with the OpenBSD platform); note highest numerical description reached applies
  • 0 = doesn't run
  • 1 = game launches (not enough information to comment meaningfully on status beyond launching the game)
  • 2 = major bugs: potentially game-breaking, making finishing the game impossible or a chore; noticeably degrading the enjoyment compared to running the game on other platforms
  • 3 = medium-impact bugs: noticeable, but not game-breaking
  • 4 = minor bugs: barely noticeable, or not relevant to core game
  • 5 = completable: game can be played through until the credits roll, without major bugs (category 2); doesn't (necessarily) include optional side content, DLC, optional multiplayer, achievements etc.
  • 6 = 100%: the complete game including optional content like DLC, side quests, multiplayer can be enjoyed
  1. Added: date (ISO 8601 format) when the entry was added (EPOCH when the information is not available)
  2. Updated: date (ISO 8601 format) when the entry was last updated
  3. IgdbId: id of the game in the IGDB database

The libpobsd provide a Parser to parse the PlayOnBSD database and a GameDataBase to query the PlayOnBSD database. The result of a GameDataBase query are returned as a QueryResult of Item or Game depending on the nature of the query. Game collections can also be filtered using a GameFilter.

Examples

Loading the games listed in the PlayOnBSD database in a vector:

use libpobsd::{Parser, ParserResult, Game};

let games: Vec<Game> = 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 listed in the PlayOnBSD database into the GameDataBase without dealing with parsing errors if any:

use libpobsd::{Parser, ParserResult, GameDataBase, Game};
let games: Vec<Game> = 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);

Perform a non case sensitive search of games by name using the GameDataBase, the query result being return in a form of a QueryResult:

let db = GameDataBase::new(games);
let st = SearchType::CaseSensitive;
let games: QueryResult<&Game> = db.search_games_by_name("Barrow", &st);

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

let db = GameDataBase::new(games);
let st = SearchType::CaseSensitive;
let games = db.search_games_by_name("Barrow", &st);
let games = games.filter_games_by_year("2018", &st);

List the games of a query result:

let db = GameDataBase::new(games);
let st = SearchType::CaseSensitive;
let games = db.search_games_by_name("Barrow", &st);
for game in games.into_inner() {
    println!("Game: {}", game.name);
}

More examples are available in each module documentation.

Dependencies

~4–5.5MB
~98K SLoC