feat: Refactor VibeTorrent v3 with shared crate, fine-grained updates, tracing, and middleware optimization
This commit is contained in:
7
shared/Cargo.toml
Normal file
7
shared/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "shared"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
58
shared/src/lib.rs
Normal file
58
shared/src/lib.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
pub struct Torrent {
|
||||
pub hash: String,
|
||||
pub name: String,
|
||||
pub size: i64,
|
||||
pub completed: i64,
|
||||
pub down_rate: i64,
|
||||
pub up_rate: i64,
|
||||
pub eta: i64,
|
||||
pub percent_complete: f64,
|
||||
pub status: TorrentStatus,
|
||||
pub error_message: String,
|
||||
pub added_date: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub enum TorrentStatus {
|
||||
Downloading,
|
||||
Seeding,
|
||||
Paused,
|
||||
Error,
|
||||
Checking,
|
||||
Queued,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(tag = "type", content = "data")]
|
||||
pub enum AppEvent {
|
||||
FullList(Vec<Torrent>, u64), // u64 is likely free_space_bytes
|
||||
Update(TorrentUpdate),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct TorrentUpdate {
|
||||
pub hash: String,
|
||||
pub down_rate: Option<i64>,
|
||||
pub up_rate: Option<i64>,
|
||||
pub percent_complete: Option<f64>,
|
||||
pub completed: Option<i64>,
|
||||
pub eta: Option<i64>,
|
||||
pub status: Option<TorrentStatus>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct TorrentActionRequest {
|
||||
pub hash: String,
|
||||
pub action: String, // "start", "stop", "delete"
|
||||
}
|
||||
|
||||
// Added Theme here to separate it from backend logic but allow frontend usage via shared
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub enum Theme {
|
||||
Midnight,
|
||||
Light,
|
||||
Amoled,
|
||||
}
|
||||
Reference in New Issue
Block a user