pub struct ModPortalClient { /* private fields */ }
Expand description

A simple caching client for the Factorio mod portal API.

Implementations§

Creates a new client with default configuration.

Creates a new client with a pre-configured reqwest::Client.

Get the full spec of a Factorio mod. Request results are cached in memory.

Example
use factorio_mod_api::ModPortalClient;

let client = ModPortalClient::new()?;
let spec = client.get_mod_spec("my_mod").await?;
println!("{}", spec.created_at);

Get a login token needed to invoke authenticated APIs.

Example
use factorio_mod_api::ModPortalClient;
use semver::Version;

let client = ModPortalClient::new()?;
let token = client.login("my_user", "my_password").await?;
client.download_mod("my_mod", &Version::parse("1.0.0")?, &token);

Download a mod from the mod portal.

This is an authenticated endpoint that needs a login token to be obtained with ModPortalClient::login first.

Example
use factorio_mod_api::ModPortalClient;
use semver::Version;

let client = ModPortalClient::new()?;
let token = client.login("my_user", "my_password").await?;
let bytes = client.download_mod("my_mod", &Version::parse("1.0.0")?, &token).await?;
std::fs::write("my_mod_1.0.0.zip", bytes)?;

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more