Api

Struct Api 

Source
pub struct Api { /* private fields */ }
Expand description

Top level API handler.

All network calls are handled through here.

Implementations§

Source§

impl Api

Source

pub fn new<S: Into<String>>(key: S) -> Self

Create a new wrapper with a personal API key.

Ideally should be checked with Api::validate right after:

§Examples
let api = Api::new("here is my custom key");
assert!(api.validate().await.is_ok());
Source§

impl Api

User related methods.

Source

pub async fn validate(&self) -> Result<Validate, ValidateError>

Validate API key and retrieve user details.

§Examples
let api = Api::new("...");
// I am a premium user!
assert!(api.validate().await?.is_premium());
Source

pub async fn tracked_mods(&self) -> Result<TrackedModsRaw, ValidateError>

Get a list of the user’s tracked mods.

§Notes

Consider converting to TrackedMods.

Source

pub async fn track_mod<T: Into<u64>>( &self, game: &str, id: T, ) -> Result<PostModStatus, TrackModError>

Track a mod based on a u64 mod ID.

Source

pub async fn untrack_mod<T: Into<ModId>>( &self, game: &str, id: T, ) -> Result<(), DeleteModError>

Untrack a mod.

§Notes

This function takes in a ModId, not a u64 because it is assumed that (unlike Api::track_mod) the caller knows of a valid mod ID.

Source

pub async fn endorsements(&self) -> Result<Endorsements, ValidateError>

Get a list of mods the user has endorsed.

Source§

impl Api

Mod related methods.

  • GET v1/games/{game_domain_name}/mods/updated
  • GET v1/games/{game_domain_name}/mods/{mod_id}/changelogs
  • GET v1/games/{game_domain_name}/mods/latest_added
  • GET v1/games/{game_domain_name}/mods/latest_updated
  • GET v1/games/{game_domain_name}/mods/trending
  • GET v1/games/{game_domain_name}/mods/{id}
  • GET v1/games/{game_domain_name}/mods/md5_search/{md5_hash}
  • POST v1/games/{game_domain_name}/mods/{id}/endorse
  • POST v1/games/{game_domain_name}/mods/{id}/abstain
Source

pub async fn updated_during( &self, game: &str, time: TimePeriod, ) -> Result<Vec<ModUpdated>, GameModError>

Get a list of mods updated within a timeframe.

Source

pub async fn changelogs<T: Into<ModId>>( &self, game: &str, id: T, ) -> Result<Changelog, GameModError>

Get changelogs for a mod.

Source

pub async fn mod_info<T: Into<ModId>>( &self, game: &str, id: T, ) -> Result<GameMod, GameModError>

Get specific mod information.

Source§

impl Api

Game related methods.

Source

pub async fn games(&self) -> Result<Vec<GameId>, GameModError>

Get a list of all games tracked by NexusMods.

Source

pub async fn game(&self, game: &str) -> Result<GameId, GameModError>

Get information about a single game.

Source§

impl Api

Mod file related methods.

Source

pub async fn mod_files<S: Into<ModId>>( &self, game: &str, mod_id: S, category: Option<CategoryName>, ) -> Result<ModFiles, GameModError>

Based on a game and a ModId, get data about the download files the mod provides.

Source

pub async fn mod_file<S: Into<ModId>>( &self, game: &str, mod_id: S, file_id: u64, ) -> Result<ModFile, GameModError>

Auto Trait Implementations§

§

impl Freeze for Api

§

impl !RefUnwindSafe for Api

§

impl Send for Api

§

impl Sync for Api

§

impl Unpin for Api

§

impl !UnwindSafe for Api

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

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>,

Source§

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