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 |
#500 in Database interfaces
Used in pobsd-browser
110KB
2.5K
SLoC
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:
- Game: string, leading "A " or "The " treated specially for alphabetic ordering
- Cover: path to cover art image file (
.png
,.jpg
) - Engine: string of valid engine entry
- Setup: string (package, command, text)
- Runtime: string; should correspond to an executable in packages
- Store: strings of URLs, whitespace-separated
- Hints: string
- Genre: strings, comma-separated
- Tags: strings, comma-separated
- Year: integer (release year)
- Dev: string (developer), comma-separated
- Pub: string (publisher), comma-separated
- Version: version number/string
- 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
- Added: date (ISO 8601 format) when the entry was added (EPOCH when the information is not available)
- Updated: date (ISO 8601 format) when the entry was last updated
- 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
~3.5–5.5MB
~96K SLoC