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
mod.io is a drop-in modding solution from the founders of ModDB.com, that facilitates the upload, search, browsing, downloading and trading of mods in-game.
Usage
To use modio
, add this to your Cargo.toml
[]
= "0.6"
Basic Setup
use ;
async
Authentication
// Request a security code be sent to the email address.
modio.auth.request_code.await?;
// Wait for the 5-digit security code
let token = modio.auth.security_code.await?;
// Create an endpoint with the new credentials
let modio = modio.with_credentials;
See full example.
Games
use *;
// List games with filter `name_id = "0ad"`
let games = modio.games.search.collect.await?;
Mods
// List all mods for 0 A.D.
let mods = modio.game.mods.search.collect.await?;
// Get the details of the `balancing-mod` mod
let balancing_mod = modio.mod_.get.await?;
Streaming search result
use TryStreamExt;
let filter = eq.limit;
let mut st = modio.game.mods.search.paged.await?;
let = st.size_hint;
// Stream of paged results `Page<Mod>` with page size = 10
while let Some = st.try_next.await?
let filter = eq;
let mut st = modio.game.mods.search.iter.await?;
let = st.size_hint;
// Stream of `Mod`
while let Some = st.try_next.await?
Download
use ;
use ;
// Download the primary file of a mod.
let action = Primary ;
modio.download.save_to_file.await?;
// Download the specific file of a mod.
let action = File ;
modio.download.save_to_file.await?;
// Download the specific version of a mod.
// if multiple files are found then the latest file is downloaded.
// Set policy to `ResolvePolicy::Fail` to return with `modio::download::Error::MultipleFilesFound`
// as source error.
let action = Version ;
modio.download
.stream
.try_for_each
.await?;
Examples
See examples directory for some getting started examples.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Contribution
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.