pub struct Api { /* private fields */ }Expand description
Top level API handler.
All network calls are handled through here.
Implementations§
Source§impl Api
impl Api
Sourcepub fn new<S: Into<String>>(key: S) -> Self
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.
impl Api
User related methods.
§Status
-
GETv1/users/validate -
GETv1/user/tracked_mods -
POSTv1/user/tracked_mods -
DELETEv1/user/tracked_mods -
GETv1/user/endorsements
Sourcepub async fn validate(&self) -> Result<Validate, ValidateError>
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());Sourcepub async fn tracked_mods(&self) -> Result<TrackedModsRaw, ValidateError>
pub async fn tracked_mods(&self) -> Result<TrackedModsRaw, ValidateError>
Sourcepub async fn track_mod<T: Into<u64>>(
&self,
game: &str,
id: T,
) -> Result<PostModStatus, TrackModError>
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.
Sourcepub async fn untrack_mod<T: Into<ModId>>(
&self,
game: &str,
id: T,
) -> Result<(), DeleteModError>
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.
Sourcepub async fn endorsements(&self) -> Result<Endorsements, ValidateError>
pub async fn endorsements(&self) -> Result<Endorsements, ValidateError>
Get a list of mods the user has endorsed.
Source§impl Api
Mod related methods.
impl Api
Mod related methods.
-
GETv1/games/{game_domain_name}/mods/updated -
GETv1/games/{game_domain_name}/mods/{mod_id}/changelogs -
GETv1/games/{game_domain_name}/mods/latest_added -
GETv1/games/{game_domain_name}/mods/latest_updated -
GETv1/games/{game_domain_name}/mods/trending -
GETv1/games/{game_domain_name}/mods/{id} -
GETv1/games/{game_domain_name}/mods/md5_search/{md5_hash} -
POSTv1/games/{game_domain_name}/mods/{id}/endorse -
POSTv1/games/{game_domain_name}/mods/{id}/abstain
Sourcepub async fn updated_during(
&self,
game: &str,
time: TimePeriod,
) -> Result<Vec<ModUpdated>, GameModError>
pub async fn updated_during( &self, game: &str, time: TimePeriod, ) -> Result<Vec<ModUpdated>, GameModError>
Get a list of mods updated within a timeframe.
Sourcepub async fn changelogs<T: Into<ModId>>(
&self,
game: &str,
id: T,
) -> Result<Changelog, GameModError>
pub async fn changelogs<T: Into<ModId>>( &self, game: &str, id: T, ) -> Result<Changelog, GameModError>
Get changelogs for a mod.
Source§impl Api
Game related methods.
impl Api
Game related methods.
-
GETv1/games -
GETv1/games/{game_domain_name}
Source§impl Api
Mod file related methods.
impl Api
Mod file related methods.
-
GETv1/games/{game_domain_name}/mods/{mod_id}/files -
GETv1/games/{game_domain_name}/mods/{mod_id}/files/{file_id} -
GETv1/games/{game_domain_name}/mods/{mod_id}/files/{id}/download_link
Sourcepub async fn mod_files<S: Into<ModId>>(
&self,
game: &str,
mod_id: S,
category: Option<CategoryName>,
) -> Result<ModFiles, GameModError>
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more