[][src]Struct modio::Modio

pub struct Modio { /* fields omitted */ }

Endpoint interface to interacting with the mod.io API.

Implementations

impl Modio[src]

pub fn builder<C: Into<Credentials>>(credentials: C) -> Builder[src]

Constructs a new Builder to configure a Modio client.

This is the same as Builder::new(credentials).

pub fn new<C>(credentials: C) -> Result<Self> where
    C: Into<Credentials>, 
[src]

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

pub fn host<H, C>(host: H, credentials: C) -> Result<Self> where
    H: Into<String>,
    C: Into<Credentials>, 
[src]

Create an endpoint to a different host.

pub fn with_credentials<CR>(&self, credentials: CR) -> Self where
    CR: Into<Credentials>, 
[src]

Return an endpoint with new credentials.

pub fn with_token<T>(&self, token: T) -> Self where
    T: Into<Token>, 
[src]

Return an endpoint with a new token.

pub fn auth(&self) -> Auth[src]

Return a reference to an interface for requesting access tokens.

pub fn games(&self) -> Games[src]

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

pub fn game(&self, game_id: u32) -> GameRef[src]

Return a reference to a game.

pub fn mod_(&self, game_id: u32, mod_id: u32) -> ModRef[src]

Return a reference to a mod.

pub fn download<A>(&self, action: A) -> Downloader where
    DownloadAction: From<A>, 
[src]

Returns Downloader for saving to file or retrieving the data via Stream.

The download fails with modio::download::Error as source if a primary file, a specific file or a specific version is not found.

Example

use futures_util::{future, TryStreamExt};
use modio::download::{DownloadAction, ResolvePolicy};

// Download the primary file of a mod.
let action = DownloadAction::Primary {
    game_id: 5,
    mod_id: 19,
};
modio.download(action).save_to_file("mod.zip").await?;

// Download the specific file of a mod.
let action = DownloadAction::File {
    game_id: 5,
    mod_id: 19,
    file_id: 101,
};
modio.download(action).save_to_file("mod.zip").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 = DownloadAction::Version {
    game_id: 5,
    mod_id: 19,
    version: "0.1".to_string(),
    policy: ResolvePolicy::Latest,
};
modio
    .download(action)
    .stream()
    .try_for_each(|bytes| {
        println!("Bytes: {:?}", bytes);
        future::ok(())
    })
    .await?;

pub fn user(&self) -> Me[src]

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

pub fn reports(&self) -> Reports[src]

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

Trait Implementations

impl Clone for Modio[src]

impl Debug for Modio[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.