Rust library for accessing the latest LoL patch's ddragon data.
serde_jsoncacache-syncureq agents (which can use the exposed cache middleware)http-cache-reqwest rather than a custom middlewarereqwest or reqwest-middleware clients```rust use ddragon::{cache_middleware::CacheMiddleware, DDragonClientError, DDragonClient};
fn main() -> Result<(), DDragonClientError> { let client = DDragonClient::new("/path/to/your/cache/dir")?;
// If you want to use an existing agent
let my_agent = ureq::AgentBuilder::new()
.middleware(CacheMiddleware::new("/path/to/your/cache/dir"))
.build();
let client = DDragonClient::with_agent(my_agent)?;
// See available options on the client and in the models folder.
let champions = client.champions()?;
let runes = client.runes()?;
Ok(())
} ```
The following crate features are available:
sync (on by default) enables the synchronous client.
ddragon::client and ddragon::cache_middleware module.ddragon::DDragonClient client.cacache-sync, url, thiserror, and ureq with the json feature enabled as dependencies.async enables the asynchronous client.
ddragon::async_client module.ddragon::AsyncDDragonClient client.reqwest with the json feature, reqwest-middleware and http-cache-reqwest as dependencies.To use the library with just the synchronous version, it should be as simple as adding any other dependency:
toml
[dependencies]
ddragon = "<version>"
If you want the asynchronous client only, you probably don't want to pull in the dependencies related to the synchronous code, so you can do this:
toml
[dependencies]
ddragon = { version = "<version>", default-features = false, features = ["async"] }
If you only want the DDragon models (none of the client code), you can use
toml
[dependencies]
ddragon = { version = "<version>", default-features = false }
.json endpoints related to League of Legendsreqwest as the backend