🔨 chore: format
This commit is contained in:
parent
3d638e28ce
commit
72c2f42c16
4 changed files with 59 additions and 48 deletions
|
|
@ -174,29 +174,34 @@ pub fn get_program_info() -> ProgramInfo {
|
|||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_users() -> Result<Vec<MinecraftCredentials>, String> {
|
||||
minecraft::users().await.map_err(|err| err.into())
|
||||
minecraft::users().await.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn get_user(uuid: Uuid) -> Result<MinecraftCredentials, String> {
|
||||
minecraft::get_user(uuid).await.map_err(|err| err.into())
|
||||
minecraft::get_user(uuid).await.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn begin_msa() -> Result<MinecraftLogin, String> {
|
||||
minecraft::begin().await.map_err(|err| err.into())
|
||||
minecraft::begin().await.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn finish_msa(code: String, login: MinecraftLogin) -> Result<MinecraftCredentials, String> {
|
||||
minecraft::finish(code.as_str(), login).await.map_err(|err| err.into())
|
||||
pub async fn finish_msa(
|
||||
code: String,
|
||||
login: MinecraftLogin,
|
||||
) -> Result<MinecraftCredentials, String> {
|
||||
minecraft::finish(code.as_str(), login)
|
||||
.await
|
||||
.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
#[specta::specta]
|
||||
#[tauri::command]
|
||||
pub async fn remove_user(uuid: Uuid) -> Result<(), String> {
|
||||
minecraft::remove_user(uuid).await.map_err(|err| err.into())
|
||||
minecraft::remove_user(uuid).await.map_err(|err| err.into())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,7 @@ pub use interpulse::api::modded::Manifest;
|
|||
#[tracing::instrument]
|
||||
pub async fn get_minecraft_versions() -> crate::Result<VersionManifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.minecraft
|
||||
.clone();
|
||||
let meta = state.metadata.read().await.minecraft.clone();
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -22,12 +17,7 @@ pub async fn get_minecraft_versions() -> crate::Result<VersionManifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_fabric_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.fabric
|
||||
.clone();
|
||||
let meta = state.metadata.read().await.fabric.clone();
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -36,12 +26,7 @@ pub async fn get_fabric_versions() -> crate::Result<Manifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_quilt_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.quilt
|
||||
.clone();
|
||||
let meta = state.metadata.read().await.quilt.clone();
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -50,12 +35,7 @@ pub async fn get_quilt_versions() -> crate::Result<Manifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_forge_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.forge
|
||||
.clone();
|
||||
let meta = state.metadata.read().await.forge.clone();
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
@ -64,12 +44,7 @@ pub async fn get_forge_versions() -> crate::Result<Manifest> {
|
|||
#[tracing::instrument]
|
||||
pub async fn get_neoforge_versions() -> crate::Result<Manifest> {
|
||||
let state = State::get().await?;
|
||||
let meta = state
|
||||
.metadata
|
||||
.read()
|
||||
.await
|
||||
.neoforge
|
||||
.clone();
|
||||
let meta = state.metadata.read().await.neoforge.clone();
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ pub async fn download_version_info(
|
|||
info = ip::api::modded::merge_partial_version(partial, info);
|
||||
}
|
||||
|
||||
info.id = version_id.clone();
|
||||
info.id.clone_from(&version_id);
|
||||
|
||||
write(&path, &serde_json::to_vec(&info)?, &st.io_semaphore).await?;
|
||||
Ok(info)
|
||||
|
|
@ -96,11 +96,19 @@ pub async fn download_version_info(
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn fetch_version_info(version: &ip::api::minecraft::Version, semaphore: &FetchSemaphore) -> crate::Result<ip::api::minecraft::VersionInfo> {
|
||||
Ok(serde_json::from_slice(&fetch(&version.url, Some(&version.sha1), semaphore).await?)?)
|
||||
pub async fn fetch_version_info(
|
||||
version: &ip::api::minecraft::Version,
|
||||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<ip::api::minecraft::VersionInfo> {
|
||||
Ok(serde_json::from_slice(
|
||||
&fetch(&version.url, Some(&version.sha1), semaphore).await?,
|
||||
)?)
|
||||
}
|
||||
|
||||
pub async fn fetch_partial_version(url: &str, semaphore: &FetchSemaphore) -> crate::Result<ip::api::modded::PartialVersionInfo> {
|
||||
pub async fn fetch_partial_version(
|
||||
url: &str,
|
||||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<ip::api::modded::PartialVersionInfo> {
|
||||
Ok(serde_json::from_slice(&fetch(url, None, semaphore).await?)?)
|
||||
}
|
||||
|
||||
|
|
@ -139,8 +147,18 @@ pub async fn download_assets_index(
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn fetch_assets_index(version: &ip::api::minecraft::VersionInfo, semaphore: &FetchSemaphore) -> crate::Result<AssetsIndex> {
|
||||
Ok(serde_json::from_slice(&fetch(&version.asset_index.url, Some(&version.asset_index.sha1), semaphore).await?)?)
|
||||
pub async fn fetch_assets_index(
|
||||
version: &ip::api::minecraft::VersionInfo,
|
||||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<AssetsIndex> {
|
||||
Ok(serde_json::from_slice(
|
||||
&fetch(
|
||||
&version.asset_index.url,
|
||||
Some(&version.asset_index.sha1),
|
||||
semaphore,
|
||||
)
|
||||
.await?,
|
||||
)?)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(st, index))]
|
||||
|
|
|
|||
|
|
@ -50,15 +50,15 @@ impl Metadata {
|
|||
},
|
||||
async {
|
||||
let url = Self::get_manifest("quilt", interpulse::api::modded::CURRENT_QUILT_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, &semaphore).await
|
||||
fetch_modded_manifest(&url, semaphore).await
|
||||
},
|
||||
async {
|
||||
let url = Self::get_manifest("neo", interpulse::api::modded::CURRENT_NEOFORGE_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, &semaphore).await
|
||||
fetch_modded_manifest(&url, semaphore).await
|
||||
},
|
||||
async {
|
||||
let url = Self::get_manifest("forge", interpulse::api::modded::CURRENT_FORGE_FORMAT_VERSION);
|
||||
fetch_modded_manifest(&url, &semaphore).await
|
||||
fetch_modded_manifest(&url, semaphore).await
|
||||
},
|
||||
}?;
|
||||
|
||||
|
|
@ -165,10 +165,23 @@ impl Metadata {
|
|||
}
|
||||
}
|
||||
|
||||
async fn fetch_version_manifest(url: Option<&str>, semaphore: &FetchSemaphore) -> crate::Result<MinecraftManifest> {
|
||||
Ok(serde_json::from_slice(&fetch(url.unwrap_or(interpulse::api::minecraft::VERSION_MANIFEST_URL), None, semaphore).await?)?)
|
||||
async fn fetch_version_manifest(
|
||||
url: Option<&str>,
|
||||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<MinecraftManifest> {
|
||||
Ok(serde_json::from_slice(
|
||||
&fetch(
|
||||
url.unwrap_or(interpulse::api::minecraft::VERSION_MANIFEST_URL),
|
||||
None,
|
||||
semaphore,
|
||||
)
|
||||
.await?,
|
||||
)?)
|
||||
}
|
||||
|
||||
async fn fetch_modded_manifest(url: &str, semaphore: &FetchSemaphore) -> crate::Result<ModdedManifest> {
|
||||
async fn fetch_modded_manifest(
|
||||
url: &str,
|
||||
semaphore: &FetchSemaphore,
|
||||
) -> crate::Result<ModdedManifest> {
|
||||
Ok(serde_json::from_slice(&fetch(url, None, semaphore).await?)?)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue