modio
provides a set of building blocks for interacting with the mod.io API.
The client uses asynchronous I/O, backed by the futures
and tokio
crates, and requires both to be used alongside.
mod.io is a drop-in modding solution from the founders of ModDB.com, that facilitates the upload, upload, search, browsing, downloading and trading of mods in-game.
To use modio
, add this to your Cargo.toml
toml
[dependencies]
modio = "0.1"
```rust extern crate modio; extern crate tokio;
use modio::{Credentials, Error, Modio}; use tokio::runtime::Runtime;
fn main() -> Result<(), Error> { let mut rt = Runtime::new()?; let modio = Modio::new( "user-agent-name/1.0", Credentials::ApiKey(String::from("user-or-game-apikey")), );
// create some tasks and execute them
// let result = rt.block_on(task)?;
Ok(())
} ```
```rust // Request a security code be sent to the email address. rt.blockon(modio.auth().requestcode("john@example.com"))?;
// Wait for the 5-digit security code let token = rt.blockon(modio.auth().securitycode("QWERT"))?;
// Create an endpoint with the new credentials let modio = modio.with_credentials(Credentials::Token(token)); ``` See full example.
```rust use modio::filter::Operator; use modio::games::GamesListOptions;
// List games with filter name_id = "0ad"
let task = modio.games().list(
&GamesListOptions::new()
.name_id(Operator::Equals, "0ad"),
);
let games = rt.block_on(task)?; ```
```rust // List all mods for 0 A.D. let mods = rt.block_on(modio.game(5).mods().list(&Default::default))?;
// Get the details of the balancing-mod
mod
let balancingmod = rt.blockon(modio.mod_(5, 110).get())?;
```
See examples directory for some getting started examples.
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.