3 releases

new 0.1.2 Nov 28, 2024
0.1.1 Nov 27, 2024
0.1.0 Nov 27, 2024

#1131 in Web programming

Download history 76/week @ 2024-09-12 48/week @ 2024-09-19 10/week @ 2024-09-26 3/week @ 2024-10-03

75 downloads per month

MIT license

100KB
3K SLoC

vn

Rust wrapper for the VNDB API.

[dependencies]
vn = 0.1

Usage

Create a new VNDB client:

use vn::Vndb;
use std::time::Duration;

let vndb = Vndb::builder()
  .max_concurrent_requests(5)
  .timeout(Duration::from_secs(10))
  .token("abcd-efghi-jklmn-opqrs-tuvx-z1234-5678")
  .user_agent("the-user-agent/v5.0")
  .build();

Find a visual novel by its id:

use vn::{Vndb, VisualNovelField};

let vndb = Vndb::new();
let results = vndb
  .find_visual_novel(1194)
  .fields(VisualNovelField::Title)
  .send()
  .await
  .unwrap()
  .results;

let visual_novel = results.first().unwrap();
let title = visual_novel.title.as_deref().unwrap();
assert!(title.eq_ignore_ascii_case("Yosuga no Sora"));

Search characters by their name:

use vn::{Vndb, CharacterField, SortCharacterBy};

let vndb = Vndb::new();
let results = vndb
  .search_character("Minazuki Shigure")
  .fields([CharacterField::Name, CharacterField::Original])
  .results(10)
  .sort(SortCharacterBy::Name)
  .send()
  .await
  .unwrap()
  .results;

let character = results.first().unwrap();
let name = character.name.as_deref().unwrap();
let original = character.original.as_deref().unwrap();

assert!(name.eq_ignore_ascii_case("Minazuki Shigure"));
assert_eq!(original, "水無月 時雨");

Dependencies

~9–21MB
~280K SLoC