pub struct Ferinth { /* private fields */ }
Expand description
An instance of the API to invoke API calls on.
To initialise this container,
let modrinth = Ferinth::new();
// Use the instance to call the API
let sodium_mod = modrinth.get_project("sodium");
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_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());
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 a project can take
sourcepub async fn list_game_versions(&self) -> Result<Vec<GameVersion>, Error>
pub async fn list_game_versions(&self) -> Result<Vec<GameVersion>, Error>
List the Minecraft versions
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
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 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);
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 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_version_from_file_hash(
&self,
file_hash: &str
) -> Result<Version, Error>
pub async fn get_version_from_file_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 version file has the hash `795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf`, so we can get the version it belongs to
let sodium_version = modrinth.get_version_from_file_hash("795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf").await?;
// That version file belongs to (surprise, surprise) the Sodium mod!
assert!(sodium_version.project_id == "AANobbMI");
sourcepub async fn download_version_file(
&self,
version_file: &VersionFile
) -> Result<Bytes, Error>
pub async fn download_version_file(
&self,
version_file: &VersionFile
) -> Result<Bytes, Error>
Download version_file
’s contents
Example:
let sodium_versions = modrinth.list_versions("AANobbMI").await?;
let version_file = &sodium_versions[0].files[0];
// You can write this to a file and load it using a mod loader (Fabric in this case)
let file_contents = modrinth.download_version_file(version_file).await?;
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> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
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