Struct modio::Modio

source ·
pub struct Modio { /* private fields */ }
Expand description

Endpoint interface to interacting with the mod.io API.

Implementations§

source§

impl Modio

source

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

Constructs a new Builder to configure a Modio client.

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

source

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

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

source

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

Create an endpoint to a different host.

source

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

Return an endpoint with new credentials.

source

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

Return an endpoint with a new token.

source

pub fn auth(&self) -> Auth

Return a reference to an interface for requesting access tokens.

source

pub fn games(&self) -> Games

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

source

pub fn game(&self, game_id: GameId) -> GameRef

Return a reference to a game.

source

pub fn mod_(&self, game_id: GameId, mod_id: ModId) -> ModRef

Return a reference to a mod.

source

pub async fn download<A>(&self, action: A) -> Result<Downloader>
where DownloadAction: From<A>,

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};
use modio::types::id::Id;

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

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

pub fn user(&self) -> Me

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

source

pub fn reports(&self) -> Reports

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

Trait Implementations§

source§

impl Clone for Modio

source§

fn clone(&self) -> Modio

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Modio

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Modio

§

impl !RefUnwindSafe for Modio

§

impl Send for Modio

§

impl Sync for Modio

§

impl Unpin for Modio

§

impl !UnwindSafe for Modio

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more