6 releases (breaking)
0.5.0 | Feb 16, 2023 |
---|---|
0.4.0 | Feb 16, 2023 |
0.3.0 | Feb 14, 2023 |
0.2.1 | Feb 13, 2023 |
0.1.0 | Feb 10, 2023 |
#582 in #io
23 downloads per month
33KB
864 lines
jpdb-rs
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.
How to use
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.
Semantic Versioning
Like all rust crates are advised to, jpdb
uses semantic versioning. The rationale is the following, for X.Y.Z:
- X represents the jpdb api version, eg. "/api/vX/ping". Expect this to stay at 1 indefinitely.
- Y represents breaking or semi-breaking changes, for instance, new or changed error types, new struct fields, renamed functions, and so on. A Changelog will be updated to reflect changes and help transition.
- Z will denote any minor update, to docs or internals.
Dependencies
~2.3–3.5MB
~93K SLoC