pub struct Ferinth { /* private fields */ }
Expand description
An instance of the API to invoke API calls on.
To initialise this container,
let modrinth = Ferinth::default();
// Use the instance to call the API
let sodium_mod = modrinth.get_project("sodium").await?;
Implementations
sourceimpl Ferinth
impl Ferinth
sourcepub async fn get_project(&self, project_id: &str) -> Result<Project, Error>
pub async fn get_project(&self, project_id: &str) -> Result<Project, Error>
Get a project with ID project_id
Example:
let sodium_mod = modrinth.get_project("AANobbMI").await?;
assert_eq!(
sodium_mod.title,
"Sodium",
);
// You can also use the project slug
let ok_zoomer_mod = modrinth.get_project("ok-zoomer").await?;
assert_eq!(
ok_zoomer_mod.title,
"Ok Zoomer",
);
sourcepub async fn get_multiple_projects(
&self,
project_ids: &[&str]
) -> Result<Vec<Project>, Error>
pub async fn get_multiple_projects(
&self,
project_ids: &[&str]
) -> Result<Vec<Project>, Error>
Get multiple projects with IDs project_ids
Example:
let mods = modrinth.get_multiple_projects(&[
"AANobbMI",
"P7dR8mSH",
"gvQqBUqZ",
"YL57xq9U",
]).await?;
assert!(mods.len() == 4);
sourcepub async fn get_project_dependencies(
&self,
project_id: &str
) -> Result<ProjectDependencies, Error>
pub async fn get_project_dependencies(
&self,
project_id: &str
) -> Result<ProjectDependencies, Error>
Get the dependencies of the project with ID project_id
Example:
let fabric_api = modrinth.get_project_dependencies("fabric-api").await?;
// The Fabric API should not have any dependencies
assert!(fabric_api.projects.is_empty());
sourcepub async fn resolve_id_slug(
&self,
id_slug: &str
) -> Result<ResolveIDSlugResponse, Error>
pub async fn resolve_id_slug(
&self,
id_slug: &str
) -> Result<ResolveIDSlugResponse, Error>
Check whether the given mod ID/slug is valid. Returns the exact mod ID.
Example:
assert!("AANobbMI".to_string() == modrinth.resolve_id_slug("sodium").await?.id);
sourceimpl Ferinth
impl Ferinth
sourcepub async fn list_categories(&self) -> Result<Vec<Category>, Error>
pub async fn list_categories(&self) -> Result<Vec<Category>, Error>
List the categories, their icons, and applicable project types
Example:
let categories = modrinth.list_categories().await?;
sourcepub async fn list_loaders(&self) -> Result<Vec<Loader>, Error>
pub async fn list_loaders(&self) -> Result<Vec<Loader>, Error>
List the loaders, their icons, and supported project types
Example:
let loaders = modrinth.list_loaders().await?;
sourcepub async fn list_game_versions(&self) -> Result<Vec<GameVersion>, Error>
pub async fn list_game_versions(&self) -> Result<Vec<GameVersion>, Error>
List the game versions and information about them
Example:
let game_versions = modrinth.list_game_versions().await?;
sourcepub async fn list_licenses(&self) -> Result<Vec<License>, Error>
pub async fn list_licenses(&self) -> Result<Vec<License>, Error>
List licenses and information about them
Example:
let licenses = modrinth.list_licenses().await?;
sourcepub async fn list_donation_platforms(
&self
) -> Result<Vec<DonationPlatform>, Error>
pub async fn list_donation_platforms(
&self
) -> Result<Vec<DonationPlatform>, Error>
List donation platforms and information about them
Example:
let donation_platforms = modrinth.list_donation_platforms().await?;
sourceimpl Ferinth
impl Ferinth
sourcepub async fn list_team_members(
&self,
team_id: &str
) -> Result<Vec<TeamMember>, Error>
pub async fn list_team_members(
&self,
team_id: &str
) -> Result<Vec<TeamMember>, Error>
List the members of team with ID team_id
Example:
let mod_menu_team = modrinth.list_team_members("VMz4FpgB").await?;
assert!(mod_menu_team.len() == 4);
sourcepub async fn list_project_team_members(
&self,
project_id: &str
) -> Result<Vec<TeamMember>, Error>
pub async fn list_project_team_members(
&self,
project_id: &str
) -> Result<Vec<TeamMember>, Error>
List the members of team with ID team_id
Example:
let mod_menu_team = modrinth.list_project_team_members("mOgUt4GM").await?;
assert!(mod_menu_team.len() == 4);
sourceimpl Ferinth
impl Ferinth
sourcepub async fn get_user(&self, user_id: &str) -> Result<User, Error>
pub async fn get_user(&self, user_id: &str) -> Result<User, Error>
Get user with ID user_id
Example:
let jellysquid = modrinth.get_user("TEZXhE2U").await?;
assert!(jellysquid.role == UserRole::Developer);
sourcepub async fn list_projects(&self, user_id: &str) -> Result<Vec<Project>, Error>
pub async fn list_projects(&self, user_id: &str) -> Result<Vec<Project>, Error>
Get a list of projects that the user owns
Example:
let jellysquid_projects = modrinth.list_projects("TEZXhE2U").await?;
assert!(jellysquid_projects.len() == 4);
sourcepub async fn get_multiple_users(
&self,
user_ids: &[&str]
) -> Result<Vec<User>, Error>
pub async fn get_multiple_users(
&self,
user_ids: &[&str]
) -> Result<Vec<User>, Error>
Get multiple users with IDs user_ids
Example:
let users = modrinth.get_multiple_users(&["TEZXhE2U", "7Azq6eD8"]).await?;
assert!(&users[0].username == "jellysquid3");
assert!(&users[1].username == "theRookieCoder");
sourceimpl Ferinth
impl Ferinth
sourcepub async fn list_versions(
&self,
project_id: &str
) -> Result<Vec<Version>, Error>
pub async fn list_versions(
&self,
project_id: &str
) -> Result<Vec<Version>, Error>
Get the versions of project with ID project_id
Example:
let sodium_versions = modrinth.list_versions("AANobbMI").await?;
assert!(sodium_versions[0].project_id == "AANobbMI");
sourcepub async fn list_versions_filtered(
&self,
project_id: &str,
loaders: Option<&[&str]>,
game_versions: Option<&[&str]>,
featured: Option<bool>
) -> Result<Vec<Version>, Error>
pub async fn list_versions_filtered(
&self,
project_id: &str,
loaders: Option<&[&str]>,
game_versions: Option<&[&str]>,
featured: Option<bool>
) -> Result<Vec<Version>, Error>
Get the versions of project with ID project_id
with filters
loaders
: The types of loaders to filter for
game_versions
: The game versions to filter for
featured
: Filter for featured or non-featured versions only
Example:
let sodium_forge_versions = modrinth.list_versions_filtered("AANobbMI", Some(&["forge"]), None, None).await?;
assert!(sodium_forge_versions.is_empty());
sourcepub async fn get_version(&self, version_id: &str) -> Result<Version, Error>
pub async fn get_version(&self, version_id: &str) -> Result<Version, Error>
Get version with ID version_id
Example:
let sodium_version = modrinth.get_version("xuWxRZPd").await?;
assert!(sodium_version.project_id == "AANobbMI");
sourcepub async fn get_multiple_versions(
&self,
version_ids: &[&str]
) -> Result<Vec<Version>, Error>
pub async fn get_multiple_versions(
&self,
version_ids: &[&str]
) -> Result<Vec<Version>, Error>
Get multiple versions with IDs version_ids
Example:
let versions = modrinth.get_multiple_versions(&[
"sxWTUZpD",
"mgPpe4NY",
]).await?;
for version in versions {
assert!(version.project_id == "of7wIinq");
}
sourceimpl Ferinth
impl Ferinth
sourcepub async fn get_version_from_hash(
&self,
file_hash: &str
) -> Result<Version, Error>
pub async fn get_version_from_hash(
&self,
file_hash: &str
) -> Result<Version, Error>
Get the version of a version file with hash file_hash
. Only supports SHA1 hashes for now
Example:
// A mod file has the hash `795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf`, so we can get the version it belongs to
let sodium_version = modrinth.get_version_from_hash("795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf").await?;
assert!(sodium_version.project_id == "AANobbMI");
sourcepub async fn get_versions_from_hashes(
&self,
file_hashes: Vec<String>
) -> Result<HashMap<String, Version>, Error>
pub async fn get_versions_from_hashes(
&self,
file_hashes: Vec<String>
) -> Result<HashMap<String, Version>, Error>
Get the versions of version files with hashes file_hashes
. Only supports SHA1 hashes for now
Example:
let sodium_hash = "795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf";
let snwylvspls_hash = "994ee99d172a5950a51ec2d08c158d270722d871";
let versions = modrinth.get_versions_from_hashes(vec![
sodium_hash.into(),
snwylvspls_hash.into()
]).await?;
assert!(versions[sodium_hash].project_id == "AANobbMI");
assert!(versions[snwylvspls_hash].project_id == "of7wIinq");
sourcepub async fn latest_version_from_hash(
&self,
file_hash: &str,
filters: &LatestVersionBody
) -> Result<Version, Error>
pub async fn latest_version_from_hash(
&self,
file_hash: &str,
filters: &LatestVersionBody
) -> Result<Version, Error>
Get the latest version of the given file_hash
based on some filters
sourcepub async fn latest_versions_from_hashes(
&self,
file_hashes: Vec<String>,
filters: LatestVersionBody
) -> Result<Vec<Version>, Error>
pub async fn latest_versions_from_hashes(
&self,
file_hashes: Vec<String>,
filters: LatestVersionBody
) -> Result<Vec<Version>, Error>
Get the latest versions of the given file_hashes
based on some filters
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Ferinth
impl Send for Ferinth
impl Sync for Ferinth
impl Unpin for Ferinth
impl !UnwindSafe for Ferinth
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more