Crate modio[][src]

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.

Authentication

To access the API authentication is required and can be done via 3 ways:

Rate Limiting

For API requests using API key authentication are unlimited and for OAuth 2 authentication requests are limited to 120 requests per hour.

A special error ErrorKind::RateLimit will be return from api operations when the rate limit associated with credentials has been exhausted.

Example: Basic setup

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-api-key")),
    );

    // create some tasks and execute them
    // let result = rt.block_on(task)?;
    Ok(())
}

For testing purposes use Modio::host to create a client for the mod.io test environment.

Example: Downloading mods

extern crate modio;
extern crate tokio;

use std::fs::File;

use modio::download::ResolvePolicy;
use modio::{Credentials, DownloadAction, 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-api-key")),
    );
    let out = File::open("mod.zip")?;

    // Download the primary file of a mod.
    let action = DownloadAction::Primary {
        game_id: 5,
        mod_id: 19,
    };
    let (len, out) = rt.block_on(modio.download(action, out))?;

    // Download the specific file of a mod.
    let action = DownloadAction::File {
        game_id: 5,
        mod_id: 19,
        file_id: 101,
    };
    let (len, out) = rt.block_on(modio.download(action, out))?;

    // 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
    // `ErrorKind::Download(DownloadError::MultipleFilesFound)`.
    let action = DownloadAction::Version {
        game_id: 5,
        mod_id: 19,
        version: "0.1".to_string(),
        policy: ResolvePolicy::Latest,
    };
    let (len, out) = rt.block_on(modio.download(action, out))?;
    Ok(())
}

Re-exports

pub use auth::Credentials;
pub use download::DownloadAction;
pub use error::Error;
pub use error::Result;

Modules

auth

Authentication Flow interface

comments

Mod comments interface

download
error

Client errors

files

Modfile interface

filter
games

Games interface

me

Me interface

metadata

Mod metadata KVP interface

mods

Mods Interface

reports

Reports interface

teams

Team members interface

users

Users interface

Structs

Endpoint

Generic endpoint for sub-resources

Event

See the Event Object docs for more informations.

EventListOptions

Options used to filter event listings.

Modio

Endpoint interface to interacting with the mod.io API.

ModioErrorResponse

See the Error Object docs for more informations.

ModioListResponse

See the Multiple Item Response docs for more informations.

ModioMessage

See the Message Object docs for more informations.

Enums

EventType

Traits

AddOptions
DeleteOptions
QueryParams

Type Definitions

Future
Stream