Crates.io | jpdb |
lib.rs | jpdb |
version | 0.5.0 |
source | src |
created_at | 2023-02-10 19:04:54.373193 |
updated_at | 2023-02-16 22:42:10.497779 |
description | Wrapper for jpdb.io's API |
homepage | https://www.jpdb.io/ |
repository | https://github.com/sdbversini/jpdb-rs |
max_upload_size | |
id | 782038 |
size | 38,353 |
This is a Rust wrapper for jpdb.io's API.
It uses ureq and offers syncronous api calls by design, mainly because no client would make enough calls at the same time for it to reasonably matter. This also simplifies use, reduces compile time/executable size, and massively simplifies the dependency tree. If you need to make calls in an async function, you can turn to your executor's function of choice (eg. tokio's spawn_blocking
) instead.
use jpdb::client::Client;
fn main() {
// First, we create a client
let client = Client::new("my_jpdb_token"); //token is stored in the settings page
// Next, we can call upon the api easily
let response = client.ping();
//Every function returns a result, with any error type jpdb can return
if let Err(jpdb::error::Error::BadKey(__)) = response {
println!("your error handling here, because the token was bad");
}
// That's about it! Read the docs for all available endpoints, and the error they'd return.
// Some endpoints are a little more complicated, so they take in a struct as argument
client.set_card_sentence(&SetCardSentenceOptions{
vid: Vid(12),
sid: Sid(10),
clear_audio: Some(true),
..Default::default()
});
}
For more info, refer to this project for practical use.
Like all rust crates are advised to, jpdb
uses semantic versioning. The rationale is the following, for X.Y.Z: