mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-02-06 15:10:20 +00:00
feat: downloader update
This commit is contained in:
22
rust/Cargo.lock
generated
22
rust/Cargo.lock
generated
@@ -2994,7 +2994,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit"
|
||||
version = "9.0.0-beta.1"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
@@ -3058,7 +3058,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-bencode"
|
||||
version = "3.1.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrayvec",
|
||||
@@ -3074,7 +3074,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-buffers"
|
||||
version = "4.2.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"librqbit-clone-to-owned",
|
||||
@@ -3085,7 +3085,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-clone-to-owned"
|
||||
version = "3.0.1"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
]
|
||||
@@ -3093,7 +3093,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-core"
|
||||
version = "5.0.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@@ -3122,7 +3122,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-dht"
|
||||
version = "5.3.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"backon",
|
||||
@@ -3169,7 +3169,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-lsd"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"atoi",
|
||||
@@ -3189,7 +3189,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-peer-protocol"
|
||||
version = "4.3.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitvec",
|
||||
@@ -3209,7 +3209,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-sha1-wrapper"
|
||||
version = "4.1.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"assert_cfg",
|
||||
"aws-lc-rs",
|
||||
@@ -3218,7 +3218,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-tracker-comms"
|
||||
version = "3.0.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-stream",
|
||||
@@ -3246,7 +3246,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "librqbit-upnp"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.1#e5ac0ac75cceffe017e247ea265dc7402c226638"
|
||||
source = "git+https://github.com/StarCitizenToolBox/rqbit?tag=webseed-v0.0.2#7a9b4d7db84b7b9cccc424e294610cc800a9baa4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bstr",
|
||||
|
||||
@@ -35,7 +35,7 @@ unp4k_rs = { git = "https://github.com/StarCitizenToolBox/unp4k_rs", tag = "V0.0
|
||||
uuid = { version = "1.19.0", features = ["v4"] }
|
||||
parking_lot = "0.12.5"
|
||||
crossbeam-channel = "0.5.15"
|
||||
librqbit = { git = "https://github.com/StarCitizenToolBox/rqbit", tag = "webseed-v0.0.1" }
|
||||
librqbit = { git = "https://github.com/StarCitizenToolBox/rqbit", tag = "webseed-v0.0.2" }
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
bytes = "1.10"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use std::num::NonZeroU32;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -7,9 +8,11 @@ use bytes::Bytes;
|
||||
use flutter_rust_bridge::frb;
|
||||
use librqbit::{
|
||||
AddTorrent, AddTorrentOptions, AddTorrentResponse, Session, SessionOptions,
|
||||
TorrentStats, ManagedTorrent, TorrentStatsState,
|
||||
SessionPersistenceConfig, TorrentStats, ManagedTorrent, TorrentStatsState,
|
||||
api::TorrentIdOrHash,
|
||||
dht::PersistentDhtConfig,
|
||||
limits::LimitsConfig,
|
||||
};
|
||||
use once_cell::sync::OnceCell;
|
||||
use parking_lot::RwLock;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::Mutex;
|
||||
@@ -17,8 +20,9 @@ use tokio::sync::Mutex;
|
||||
// Type alias for ManagedTorrentHandle
|
||||
type ManagedTorrentHandle = Arc<ManagedTorrent>;
|
||||
|
||||
// Global session instance
|
||||
static SESSION: OnceCell<Arc<Session>> = OnceCell::new();
|
||||
// Global session instance - using RwLock to allow restart
|
||||
static SESSION: once_cell::sync::Lazy<RwLock<Option<Arc<Session>>>> =
|
||||
once_cell::sync::Lazy::new(|| RwLock::new(None));
|
||||
static SESSION_INIT_LOCK: once_cell::sync::Lazy<Mutex<()>> =
|
||||
once_cell::sync::Lazy::new(|| Mutex::new(()));
|
||||
|
||||
@@ -31,7 +35,7 @@ static TASK_OUTPUT_FOLDERS: once_cell::sync::Lazy<RwLock<HashMap<usize, String>>
|
||||
once_cell::sync::Lazy::new(|| RwLock::new(HashMap::new()));
|
||||
|
||||
/// Download task status
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum DownloadTaskStatus {
|
||||
Initializing,
|
||||
Live,
|
||||
@@ -65,11 +69,22 @@ pub struct DownloadGlobalStat {
|
||||
pub num_waiting: usize,
|
||||
}
|
||||
|
||||
/// Initialize the download manager session
|
||||
/// Initialize the download manager session with persistence enabled
|
||||
///
|
||||
/// Parameters:
|
||||
/// - working_dir: The directory to store session data (persistence, DHT, etc.)
|
||||
/// - default_download_dir: The default directory to store downloads
|
||||
/// - upload_limit_bps: Upload speed limit in bytes per second (0 = unlimited)
|
||||
/// - download_limit_bps: Download speed limit in bytes per second (0 = unlimited)
|
||||
#[frb(sync)]
|
||||
pub fn downloader_init(download_dir: String) -> Result<()> {
|
||||
pub fn downloader_init(
|
||||
working_dir: String,
|
||||
default_download_dir: String,
|
||||
upload_limit_bps: Option<u32>,
|
||||
download_limit_bps: Option<u32>,
|
||||
) -> Result<()> {
|
||||
// Already initialized
|
||||
if SESSION.get().is_some() {
|
||||
if SESSION.read().is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -78,28 +93,52 @@ pub fn downloader_init(download_dir: String) -> Result<()> {
|
||||
let _lock = SESSION_INIT_LOCK.lock().await;
|
||||
|
||||
// Double check after acquiring lock
|
||||
if SESSION.get().is_some() {
|
||||
if SESSION.read().is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let output_folder = PathBuf::from(&download_dir);
|
||||
// Working directory for persistence and session data
|
||||
let working_folder = PathBuf::from(&working_dir);
|
||||
std::fs::create_dir_all(&working_folder)?;
|
||||
|
||||
// Default download folder
|
||||
let output_folder = PathBuf::from(&default_download_dir);
|
||||
std::fs::create_dir_all(&output_folder)?;
|
||||
|
||||
// Create persistence folder for session state in working directory
|
||||
let persistence_folder = working_folder.join("rqbit-session");
|
||||
std::fs::create_dir_all(&persistence_folder)?;
|
||||
|
||||
// DHT persistence file in working directory
|
||||
let dht_persistence_file = working_folder.join("dht.json");
|
||||
|
||||
let session = Session::new_with_opts(
|
||||
output_folder,
|
||||
SessionOptions {
|
||||
disable_dht: false,
|
||||
disable_dht_persistence: true,
|
||||
persistence: None,
|
||||
disable_dht_persistence: false,
|
||||
// Configure DHT persistence to use working directory
|
||||
dht_config: Some(PersistentDhtConfig {
|
||||
config_filename: Some(dht_persistence_file),
|
||||
..Default::default()
|
||||
}),
|
||||
// Enable JSON-based session persistence for task recovery
|
||||
persistence: Some(SessionPersistenceConfig::Json {
|
||||
folder: Some(persistence_folder),
|
||||
}),
|
||||
fastresume: false,
|
||||
// Configure rate limits
|
||||
ratelimits: LimitsConfig {
|
||||
upload_bps: upload_limit_bps.and_then(NonZeroU32::new),
|
||||
download_bps: download_limit_bps.and_then(NonZeroU32::new),
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.context("Failed to create rqbit session")?;
|
||||
|
||||
SESSION
|
||||
.set(session)
|
||||
.map_err(|_| anyhow::anyhow!("Session already initialized"))?;
|
||||
*SESSION.write() = Some(session);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
@@ -108,7 +147,14 @@ pub fn downloader_init(download_dir: String) -> Result<()> {
|
||||
/// Check if the downloader is initialized
|
||||
#[frb(sync)]
|
||||
pub fn downloader_is_initialized() -> bool {
|
||||
SESSION.get().is_some()
|
||||
SESSION.read().is_some()
|
||||
}
|
||||
|
||||
/// Helper function to get session
|
||||
fn get_session() -> Result<Arc<Session>> {
|
||||
SESSION.read()
|
||||
.clone()
|
||||
.context("Downloader not initialized. Call downloader_init first.")
|
||||
}
|
||||
|
||||
/// Add a torrent from bytes (e.g., .torrent file content)
|
||||
@@ -117,9 +163,7 @@ pub async fn downloader_add_torrent(
|
||||
output_folder: Option<String>,
|
||||
trackers: Option<Vec<String>>,
|
||||
) -> Result<usize> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized. Call downloader_init first.")?;
|
||||
let session = get_session()?;
|
||||
|
||||
let bytes = Bytes::from(torrent_bytes);
|
||||
let add_torrent = AddTorrent::from_bytes(bytes);
|
||||
@@ -171,9 +215,7 @@ pub async fn downloader_add_magnet(
|
||||
output_folder: Option<String>,
|
||||
trackers: Option<Vec<String>>,
|
||||
) -> Result<usize> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized. Call downloader_init first.")?;
|
||||
let session = get_session()?;
|
||||
|
||||
// Check if it's a magnet link
|
||||
if !magnet_link.starts_with("magnet:") {
|
||||
@@ -260,9 +302,7 @@ pub async fn downloader_add_url(
|
||||
|
||||
/// Pause a download task
|
||||
pub async fn downloader_pause(task_id: usize) -> Result<()> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized")?;
|
||||
let session = get_session()?;
|
||||
|
||||
let handle = {
|
||||
let handles = TORRENT_HANDLES.read();
|
||||
@@ -279,9 +319,7 @@ pub async fn downloader_pause(task_id: usize) -> Result<()> {
|
||||
|
||||
/// Resume a download task
|
||||
pub async fn downloader_resume(task_id: usize) -> Result<()> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized")?;
|
||||
let session = get_session()?;
|
||||
|
||||
let handle = {
|
||||
let handles = TORRENT_HANDLES.read();
|
||||
@@ -298,9 +336,7 @@ pub async fn downloader_resume(task_id: usize) -> Result<()> {
|
||||
|
||||
/// Remove a download task
|
||||
pub async fn downloader_remove(task_id: usize, delete_files: bool) -> Result<()> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized")?;
|
||||
let session = get_session()?;
|
||||
|
||||
session
|
||||
.delete(librqbit::api::TorrentIdOrHash::Id(task_id), delete_files)
|
||||
@@ -382,11 +418,12 @@ fn get_task_status(stats: &TorrentStats) -> DownloadTaskStatus {
|
||||
|
||||
/// Get all tasks
|
||||
pub async fn downloader_get_all_tasks() -> Result<Vec<DownloadTaskInfo>> {
|
||||
let session = SESSION.get();
|
||||
if session.is_none() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
let session = session.unwrap();
|
||||
let session_guard = SESSION.read();
|
||||
let session = match session_guard.as_ref() {
|
||||
Some(s) => s.clone(),
|
||||
None => return Ok(vec![]),
|
||||
};
|
||||
drop(session_guard);
|
||||
|
||||
// Use RwLock to collect tasks since with_torrents takes Fn (not FnMut)
|
||||
let tasks: RwLock<Vec<DownloadTaskInfo>> = RwLock::new(Vec::new());
|
||||
@@ -474,9 +511,7 @@ pub async fn downloader_is_name_in_task(name: String) -> bool {
|
||||
|
||||
/// Pause all tasks
|
||||
pub async fn downloader_pause_all() -> Result<()> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized")?;
|
||||
let session = get_session()?;
|
||||
|
||||
let handles: Vec<_> = TORRENT_HANDLES.read().values().cloned().collect();
|
||||
|
||||
@@ -489,9 +524,7 @@ pub async fn downloader_pause_all() -> Result<()> {
|
||||
|
||||
/// Resume all tasks
|
||||
pub async fn downloader_resume_all() -> Result<()> {
|
||||
let session = SESSION
|
||||
.get()
|
||||
.context("Downloader not initialized")?;
|
||||
let session = get_session()?;
|
||||
|
||||
let handles: Vec<_> = TORRENT_HANDLES.read().values().cloned().collect();
|
||||
|
||||
@@ -502,12 +535,80 @@ pub async fn downloader_resume_all() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Stop the downloader session
|
||||
/// Stop the downloader session (pauses all tasks but keeps session)
|
||||
pub async fn downloader_stop() -> Result<()> {
|
||||
if let Some(session) = SESSION.get() {
|
||||
let session = SESSION.read().clone();
|
||||
if let Some(session) = session {
|
||||
session.stop().await;
|
||||
}
|
||||
TORRENT_HANDLES.write().clear();
|
||||
TASK_OUTPUT_FOLDERS.write().clear();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Shutdown the downloader session completely (allows restart with new settings)
|
||||
pub async fn downloader_shutdown() -> Result<()> {
|
||||
let session_opt = {
|
||||
let mut guard = SESSION.write();
|
||||
guard.take()
|
||||
};
|
||||
|
||||
if let Some(session) = session_opt {
|
||||
session.stop().await;
|
||||
}
|
||||
|
||||
TORRENT_HANDLES.write().clear();
|
||||
TASK_OUTPUT_FOLDERS.write().clear();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update global speed limits
|
||||
/// Note: rqbit Session doesn't support runtime limit changes,
|
||||
/// this function is a placeholder that returns an error.
|
||||
/// Speed limits should be set during downloader_init.
|
||||
pub async fn downloader_update_speed_limits(
|
||||
_upload_limit_bps: Option<u32>,
|
||||
_download_limit_bps: Option<u32>,
|
||||
) -> Result<()> {
|
||||
// rqbit Session is created with limits but doesn't support runtime updates
|
||||
// To change limits, the session needs to be recreated
|
||||
anyhow::bail!("Runtime speed limit changes not supported. Please restart the downloader.")
|
||||
}
|
||||
|
||||
/// Remove all completed tasks (equivalent to aria2's --seed-time=0 behavior)
|
||||
pub async fn downloader_remove_completed_tasks() -> Result<u32> {
|
||||
let session = get_session()?;
|
||||
|
||||
let tasks = downloader_get_all_tasks().await?;
|
||||
let mut removed_count = 0u32;
|
||||
|
||||
for task in tasks {
|
||||
if task.status == DownloadTaskStatus::Finished {
|
||||
// Check if handle exists (drop lock before await)
|
||||
let has_handle = TORRENT_HANDLES.read().contains_key(&task.id);
|
||||
if has_handle {
|
||||
// Use TorrentIdOrHash::Id for deletion (TorrentId is just usize)
|
||||
if session.delete(TorrentIdOrHash::Id(task.id), false).await.is_ok() {
|
||||
TORRENT_HANDLES.write().remove(&task.id);
|
||||
TASK_OUTPUT_FOLDERS.write().remove(&task.id);
|
||||
removed_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(removed_count)
|
||||
}
|
||||
|
||||
/// Check if there are any active (non-completed) tasks
|
||||
pub async fn downloader_has_active_tasks() -> bool {
|
||||
if let Ok(tasks) = downloader_get_all_tasks().await {
|
||||
for task in tasks {
|
||||
if task.status != DownloadTaskStatus::Finished
|
||||
&& task.status != DownloadTaskStatus::Error {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
|
||||
default_rust_auto_opaque = RustAutoOpaqueNom,
|
||||
);
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.11.1";
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1465039096;
|
||||
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -641930410;
|
||||
|
||||
// Section: executor
|
||||
|
||||
@@ -376,8 +376,35 @@ fn wire__crate__api__downloader_api__downloader_get_task_info_impl(
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_has_active_tasks_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "downloader_has_active_tasks",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
move |context| async move {
|
||||
transform_result_dco::<_, _, ()>(
|
||||
(move || async move {
|
||||
let output_ok = Result::<_, ()>::Ok(
|
||||
crate::api::downloader_api::downloader_has_active_tasks().await,
|
||||
)?;
|
||||
Ok(output_ok)
|
||||
})()
|
||||
.await,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_init_impl(
|
||||
download_dir: impl CstDecode<String>,
|
||||
working_dir: impl CstDecode<String>,
|
||||
default_download_dir: impl CstDecode<String>,
|
||||
upload_limit_bps: impl CstDecode<Option<u32>>,
|
||||
download_limit_bps: impl CstDecode<Option<u32>>,
|
||||
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::<flutter_rust_bridge::for_generated::DcoCodec, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
@@ -386,10 +413,18 @@ fn wire__crate__api__downloader_api__downloader_init_impl(
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync,
|
||||
},
|
||||
move || {
|
||||
let api_download_dir = download_dir.cst_decode();
|
||||
let api_working_dir = working_dir.cst_decode();
|
||||
let api_default_download_dir = default_download_dir.cst_decode();
|
||||
let api_upload_limit_bps = upload_limit_bps.cst_decode();
|
||||
let api_download_limit_bps = download_limit_bps.cst_decode();
|
||||
transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>(
|
||||
(move || {
|
||||
let output_ok = crate::api::downloader_api::downloader_init(api_download_dir)?;
|
||||
let output_ok = crate::api::downloader_api::downloader_init(
|
||||
api_working_dir,
|
||||
api_default_download_dir,
|
||||
api_upload_limit_bps,
|
||||
api_download_limit_bps,
|
||||
)?;
|
||||
Ok(output_ok)
|
||||
})(),
|
||||
)
|
||||
@@ -516,6 +551,29 @@ fn wire__crate__api__downloader_api__downloader_remove_impl(
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_remove_completed_tasks_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "downloader_remove_completed_tasks",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
move |context| async move {
|
||||
transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>(
|
||||
(move || async move {
|
||||
let output_ok =
|
||||
crate::api::downloader_api::downloader_remove_completed_tasks().await?;
|
||||
Ok(output_ok)
|
||||
})()
|
||||
.await,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_resume_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
task_id: impl CstDecode<usize>,
|
||||
@@ -563,6 +621,28 @@ fn wire__crate__api__downloader_api__downloader_resume_all_impl(
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_shutdown_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "downloader_shutdown",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
move |context| async move {
|
||||
transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>(
|
||||
(move || async move {
|
||||
let output_ok = crate::api::downloader_api::downloader_shutdown().await?;
|
||||
Ok(output_ok)
|
||||
})()
|
||||
.await,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_stop_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
) {
|
||||
@@ -585,6 +665,36 @@ fn wire__crate__api__downloader_api__downloader_stop_impl(
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__downloader_api__downloader_update_speed_limits_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
_upload_limit_bps: impl CstDecode<Option<u32>>,
|
||||
_download_limit_bps: impl CstDecode<Option<u32>>,
|
||||
) {
|
||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||
flutter_rust_bridge::for_generated::TaskInfo {
|
||||
debug_name: "downloader_update_speed_limits",
|
||||
port: Some(port_),
|
||||
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
|
||||
},
|
||||
move || {
|
||||
let api__upload_limit_bps = _upload_limit_bps.cst_decode();
|
||||
let api__download_limit_bps = _download_limit_bps.cst_decode();
|
||||
move |context| async move {
|
||||
transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>(
|
||||
(move || async move {
|
||||
let output_ok = crate::api::downloader_api::downloader_update_speed_limits(
|
||||
api__upload_limit_bps,
|
||||
api__download_limit_bps,
|
||||
)
|
||||
.await?;
|
||||
Ok(output_ok)
|
||||
})()
|
||||
.await,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
fn wire__crate__api__http_api__fetch_impl(
|
||||
port_: flutter_rust_bridge::for_generated::MessagePort,
|
||||
method: impl CstDecode<crate::api::http_api::MyMethod>,
|
||||
@@ -2152,6 +2262,17 @@ impl SseDecode for Option<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for Option<u32> {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
if (<bool>::sse_decode(deserializer)) {
|
||||
return Some(<u32>::sse_decode(deserializer));
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SseDecode for Option<u64> {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||
@@ -3081,6 +3202,16 @@ impl SseEncode for Option<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for Option<u32> {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
<bool>::sse_encode(self.is_some(), serializer);
|
||||
if let Some(value) = self {
|
||||
<u32>::sse_encode(value, serializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SseEncode for Option<u64> {
|
||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||
@@ -3374,6 +3505,12 @@ mod io {
|
||||
CstDecode::<crate::api::asar_api::RsiLauncherAsarData>::cst_decode(*wrap).into()
|
||||
}
|
||||
}
|
||||
impl CstDecode<u32> for *mut u32 {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> u32 {
|
||||
unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }
|
||||
}
|
||||
}
|
||||
impl CstDecode<u64> for *mut u64 {
|
||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||
fn cst_decode(self) -> u64 {
|
||||
@@ -3947,11 +4084,26 @@ mod io {
|
||||
wire__crate__api__downloader_api__downloader_get_task_info_impl(port_, task_id)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_has_active_tasks(
|
||||
port_: i64,
|
||||
) {
|
||||
wire__crate__api__downloader_api__downloader_has_active_tasks_impl(port_)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_init(
|
||||
download_dir: *mut wire_cst_list_prim_u_8_strict,
|
||||
working_dir: *mut wire_cst_list_prim_u_8_strict,
|
||||
default_download_dir: *mut wire_cst_list_prim_u_8_strict,
|
||||
upload_limit_bps: *mut u32,
|
||||
download_limit_bps: *mut u32,
|
||||
) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco {
|
||||
wire__crate__api__downloader_api__downloader_init_impl(download_dir)
|
||||
wire__crate__api__downloader_api__downloader_init_impl(
|
||||
working_dir,
|
||||
default_download_dir,
|
||||
upload_limit_bps,
|
||||
download_limit_bps,
|
||||
)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
@@ -3992,6 +4144,13 @@ mod io {
|
||||
wire__crate__api__downloader_api__downloader_remove_impl(port_, task_id, delete_files)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_remove_completed_tasks(
|
||||
port_: i64,
|
||||
) {
|
||||
wire__crate__api__downloader_api__downloader_remove_completed_tasks_impl(port_)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_resume(
|
||||
port_: i64,
|
||||
@@ -4007,6 +4166,13 @@ mod io {
|
||||
wire__crate__api__downloader_api__downloader_resume_all_impl(port_)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_shutdown(
|
||||
port_: i64,
|
||||
) {
|
||||
wire__crate__api__downloader_api__downloader_shutdown_impl(port_)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_stop(
|
||||
port_: i64,
|
||||
@@ -4014,6 +4180,19 @@ mod io {
|
||||
wire__crate__api__downloader_api__downloader_stop_impl(port_)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__downloader_api__downloader_update_speed_limits(
|
||||
port_: i64,
|
||||
_upload_limit_bps: *mut u32,
|
||||
_download_limit_bps: *mut u32,
|
||||
) {
|
||||
wire__crate__api__downloader_api__downloader_update_speed_limits_impl(
|
||||
port_,
|
||||
_upload_limit_bps,
|
||||
_download_limit_bps,
|
||||
)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_wire__crate__api__http_api__fetch(
|
||||
port_: i64,
|
||||
@@ -4441,6 +4620,11 @@ mod io {
|
||||
)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_u_32(value: u32) -> *mut u32 {
|
||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_u_64(value: u64) -> *mut u64 {
|
||||
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
|
||||
|
||||
Reference in New Issue
Block a user