Struct modio::Modio[][src]

pub struct Modio<C> where
    C: Clone + Connect + 'static, 
{ /* fields omitted */ }

Endpoint interface to interacting with the mod.io API.

Methods

impl Modio<HttpsConnector<HttpConnector>>
[src]

Create an endpoint to https://api.mod.io/v1.

Create an endpoint to a different host.

impl<C> Modio<C> where
    C: Clone + Connect + 'static, 
[src]

Create an endpoint with a custom hyper client.

Consume the endpoint and create an endpoint with new credentials.

Return a reference to an interface for requesting access tokens.

Return a reference to an interface that provides access to game informations.

Return a reference to a game.

Return a reference to a mod.

Performs a download into a writer.

Fails with ErrorKind::Download if a primary file, a specific file or a specific version is not found.

Example

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(())
}

Return a reference to an interface that provides access to resources owned by the user associated with the current authentication credentials.

Return a reference to an interface that provides access to user informations.

Return a reference to an interface to report games, mods and users.

Trait Implementations

impl<C: Clone> Clone for Modio<C> where
    C: Clone + Connect + 'static, 
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<C: Debug> Debug for Modio<C> where
    C: Clone + Connect + 'static, 
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<C> Send for Modio<C>

impl<C> Sync for Modio<C>