Giter Club home page Giter Club logo

ddragon's Introduction

ddragon

latest version health check status downloads of latest version latest docs

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)
  • 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 or reqwest-middleware clients
  • 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 and ddragon::cache_middleware module.
    • Provides the re-exported ddragon::Client and ddragon::ClientBuilder impls.
    • Adds cacache, url, thiserror, and ureq with the json feature enabled as dependencies.
  • async enables the asynchronous client.

    • Provides the ddragon::async_client module.
    • Provides the re-exported ddragon::AsyncClient and ddragon::AsyncClientBuilder impls.
    • Adds reqwest with the json feature, reqwest-middleware and http-cache-reqwest as dependencies.
    • If you would like the client to use rustls, use the async-rustls feature instead.
  • image enables image fetching and caching.

    • Both clients will receive image_of and sprite_of for any model which implements HasImage.
    • Adds the image dependency.
  • 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 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.

  • 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.

ddragon's People

Contributors

github-actions[bot] avatar kade-robertson avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.