aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/downloader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/core/downloader.rs')
-rw-r--r--src-tauri/src/core/downloader.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/src-tauri/src/core/downloader.rs b/src-tauri/src/core/downloader.rs
index 26f6ebd..a6b11c5 100644
--- a/src-tauri/src/core/downloader.rs
+++ b/src-tauri/src/core/downloader.rs
@@ -2,13 +2,16 @@ use futures::StreamExt;
use serde::{Deserialize, Serialize};
use sha1::Digest as Sha1Digest;
use std::path::PathBuf;
-use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::sync::Arc;
+use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use tauri::{AppHandle, Emitter, Manager, Window};
use tokio::io::{AsyncSeekExt, AsyncWriteExt};
use tokio::sync::Semaphore;
+use ts_rs::TS;
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct DownloadTask {
pub url: String,
pub path: PathBuf,
@@ -19,7 +22,9 @@ pub struct DownloadTask {
}
/// Metadata for resumable downloads stored in .part.meta file
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct DownloadMetadata {
pub url: String,
pub file_name: String,
@@ -31,7 +36,9 @@ pub struct DownloadMetadata {
}
/// A download segment for multi-segment parallel downloading
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct DownloadSegment {
pub start: u64,
pub end: u64,
@@ -40,7 +47,9 @@ pub struct DownloadSegment {
}
/// Progress event for Java download
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct JavaDownloadProgress {
pub file_name: String,
pub downloaded_bytes: u64,
@@ -52,7 +61,9 @@ pub struct JavaDownloadProgress {
}
/// Pending download task for queue persistence
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct PendingJavaDownload {
pub major_version: u32,
pub image_type: String,
@@ -65,7 +76,9 @@ pub struct PendingJavaDownload {
}
/// Download queue for persistence
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Serialize, Deserialize, Default, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct DownloadQueue {
pub pending_downloads: Vec<PendingJavaDownload>,
}
@@ -419,7 +432,9 @@ fn create_new_metadata(
}
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "downloader.ts")]
pub struct ProgressEvent {
pub file: String,
pub downloaded: u64,