Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add event handling structures and EventEmitter trait

Tonho1fe737fc1562
diff --git a/src-tauri/omniget-core/src/core/events.rs b/src-tauri/omniget-core/src/core/events.rs
new file mode 100644
index 00000000..a3ad992a
--- /dev/null
+++ b/src-tauri/omniget-core/src/core/events.rs
@@ -0,0 +1,44 @@
+use serde::Serialize;
+
+#[derive(Debug, Clone, Serialize, PartialEq)]
+#[serde(tag = "type", content = "data")]
+pub enum QueueStatus {
+ Queued,
+ Active,
+ Paused,
+ Complete { success: bool },
+ Error { message: String },
+}
+
+#[derive(Clone, Serialize)]
+pub struct QueueItemInfo {
+ pub id: u64,
+ pub url: String,
+ pub platform: String,
+ pub title: String,
+ pub status: QueueStatus,
+ pub percent: f64,
+ pub speed_bytes_per_sec: f64,
+ pub downloaded_bytes: u64,
+ pub total_bytes: Option<u64>,
+ pub file_path: Option<String>,
+ pub file_size_bytes: Option<u64>,
+ pub file_count: Option<u32>,
+}
+
+#[derive(Clone, Serialize)]
+pub struct QueueItemProgress {
+ pub id: u64,
+ pub title: String,
+ pub platform: String,
+ pub percent: f64,
+ pub speed_bytes_per_sec: f64,
+ pub downloaded_bytes: u64,
+ pub total_bytes: Option<u64>,
+ pub phase: String,
+}
+
+pub trait EventEmitter: Send + Sync + Clone + 'static {
+ fn emit_queue_state(&self, items: &[QueueItemInfo]);
+ fn emit_progress(&self, progress: &QueueItemProgress);
+}