| Crates.io | ddragon |
| lib.rs | ddragon |
| version | 0.9.2 |
| created_at | 2023-01-19 23:52:36.960811+00 |
| updated_at | 2025-03-22 19:03:18.370542+00 |
| description | Library for pulling data from ddragon, with caching support. |
| homepage | https://github.com/kade-robertson/ddragon |
| repository | https://github.com/kade-robertson/ddragon |
| max_upload_size | |
| id | 763022 |
| size | 178,133 |
Rust library for accessing the latest League of Legends patch's ddragon data.
cacacheureq agents (which can use the exposed cache middleware)http-cache-reqwest rather than a custom middlewarereqwest or reqwest-middleware clientsimageuse ddragon::{cache_middleware::CacheMiddleware, Client, ClientBuilder, ClientError};
fn main() -> Result<(), ClientError> {
let client = Client::new("/path/to/your/cache/dir")?;
// If you want to use an existing agent
let my_agent = ureq::Agent::config_builder()
.middleware(CacheMiddleware::new("/path/to/your/cache/dir"))
.build()
.into();
let client = ClientBuilder::new().agent(my_agent).build()?;
// See available options on the client and in the models folder.
let champions = client.champions()?;
let runes = client.runes()?;
let tft_items = client.tft_items()?;
Ok(())
}
The following crate features are available:
sync (on by default) enables the synchronous client.
ddragon::client and ddragon::cache_middleware module.ddragon::Client and ddragon::ClientBuilder impls.cacache, url, thiserror, and ureq with the json feature enabled as dependencies.async enables the asynchronous client.
ddragon::async_client module.ddragon::AsyncClient and ddragon::AsyncClientBuilder impls.reqwest with the json feature, reqwest-middleware and http-cache-reqwest as dependencies.rustls, use the async-rustls feature instead.image enables image fetching and caching.
image_of and sprite_of for any model which implements HasImage.image dependency.cdragon enables support for sourcing data from CommunityDragon.
To use the library with just the synchronous version, it should be as simple as adding any other dependency:
[dependencies]
ddragon = "<version>"
[dependencies]
ddragon = { version = "<version>", features = ["image"] }
[dependencies]
ddragon = { version = "<version>", default-features = false, features = ["async"] }
rustls (and you want ddragon to generate the client), you can use:[dependencies]
ddragon = { version = "<version>", default-features = false, features = ["async-rustls"] }
Note that if you are providing your own client (via AsyncClientBuilder::new().agent()) you can use either async feature set.
[dependencies]
ddragon = { version = "<version>", default-features = false }
Currently, this crate support Rust >= 1.71.1.