17 releases
new 0.8.4 | Dec 8, 2024 |
---|---|
0.8.3 | Nov 29, 2024 |
0.8.2 | Apr 5, 2024 |
0.8.1 | Oct 31, 2023 |
0.7.1 | Mar 17, 2023 |
#1 in #lol
478 downloads per month
Used in 2 crates
74KB
1.5K
SLoC
ddragon
Rust library for accessing the latest League of Legends patch's ddragon data.
- Fully (de)serializable, well-typed structs
- Supports TFT data
- Provides a synchronous API by default
- Local caching via
cacache
- Accepts custom
ureq
agents (which can use the exposed cache middleware)
- Local caching via
- Optionally, an asynchronous API can be used that maintains the same featureset
- Local caching is handled by
http-cache-reqwest
rather than a custom middleware - Also accepts custom
reqwest
orreqwest-middleware
clients
- Local caching is handled by
- Optionally, some useful functions to fetch and decode images, via
image
Usage
use 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::AgentBuilder::new()
.middleware(CacheMiddleware::new("/path/to/your/cache/dir"))
.build();
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(())
}
Features
The following crate features are available:
-
sync
(on by default) enables the synchronous client.- Provides the
ddragon::client
andddragon::cache_middleware
module. - Provides the re-exported
ddragon::Client
andddragon::ClientBuilder
impls. - Adds
cacache
,url
,thiserror
, andureq
with thejson
feature enabled as dependencies.
- Provides the
-
async
enables the asynchronous client.- Provides the
ddragon::async_client
module. - Provides the re-exported
ddragon::AsyncClient
andddragon::AsyncClientBuilder
impls. - Adds
reqwest
with thejson
feature,reqwest-middleware
andhttp-cache-reqwest
as dependencies. - If you would like the client to use
rustls
, use theasync-rustls
feature instead.
- Provides the
-
image
enables image fetching and caching.- Both clients will receive
image_of
andsprite_of
for any model which implementsHasImage
. - Adds the
image
dependency.
- Both clients will receive
-
To use the library with just the synchronous version, it should be as simple as adding any other dependency:
[dependencies]
ddragon = "<version>"
- If you would also like to have the image fetching support, use:
[dependencies]
ddragon = { version = "<version>", features = ["image"] }
- 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:
[dependencies]
ddragon = { version = "<version>", default-features = false, features = ["async"] }
- If you want the async client and you want to use
rustls
(and you wantddragon
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.
- If you only want the DDragon models (none of the client code), you can use
[dependencies]
ddragon = { version = "<version>", default-features = false }
MSRV
Currently, this crate support Rust >= 1.67.1.
Dependencies
~0.3–34MB
~558K SLoC