otqa 1.0.2

A simple, no-API wrapper around the OpenTriviaQA database
Documentation
  • Coverage
  • 5.88%
    2 out of 34 items documented0 out of 6 items with examples
  • Size
  • Source code size: 6.75 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.33 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • breynard0/otqa
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • breynard0

A Rust wrapper around the OpenTriviaQA database

https://github.com/uberspot/OpenTriviaQA

This is a wrapper around the OpenTriviaQA database. This library has the questions built into the binary (they are ~8mb), so it's useful where other trivia libraries cannot function (e.g. WASM).

Code Example

// Create the context, loading all trivia questions. Here is also where you specify whether or not you would like questions to repeat themselves
let mut ctx = otqa::TriviaContext::new(false);

// Pick a question at random of a specified category. There are twenty to choose from.
let question = ctx.get_question(otqa::Category::Animals, otqa::Seeding::Random);

// If you wanted to pick a specific question (e.g. if you wanted a custom seeding algorithm), the syntax would look like this:
// let question = ctx.get_question(otqa::Category::Animals, otqa::Seeding::Specific(0));
// It will pick the question of that category at that index, applying a modulo should it overflow the amount of questions

// Here are all fields of questions
println!("{}", question.question);
println!("Category: {:?}", question.category);
for answer in question.answers {
    println!("{}", answer);
}
println!("Correct answer: {}", question.correct_answer);