mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-01-13 19:50:28 +00:00
285 lines
9.4 KiB
Dart
285 lines
9.4 KiB
Dart
// This file is automatically generated, so please do not edit it.
|
|
// @generated by `flutter_rust_bridge`@ 2.11.1.
|
|
|
|
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
|
|
|
|
import '../frb_generated.dart';
|
|
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
|
|
|
// These functions are ignored because they are not marked as `pub`: `get_session`, `get_task_status`
|
|
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `eq`, `fmt`, `fmt`, `fmt`
|
|
|
|
/// 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)
|
|
Future<void> downloaderInit({
|
|
required String workingDir,
|
|
required String defaultDownloadDir,
|
|
int? uploadLimitBps,
|
|
int? downloadLimitBps,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderInit(
|
|
workingDir: workingDir,
|
|
defaultDownloadDir: defaultDownloadDir,
|
|
uploadLimitBps: uploadLimitBps,
|
|
downloadLimitBps: downloadLimitBps,
|
|
);
|
|
|
|
/// Check if the downloader is initialized
|
|
bool downloaderIsInitialized() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderIsInitialized();
|
|
|
|
/// Check if there are pending tasks to restore from session file (without starting the downloader)
|
|
/// This reads the session.json file directly to check if there are any torrents saved.
|
|
///
|
|
/// Parameters:
|
|
/// - working_dir: The directory where session data is stored (same as passed to downloader_init)
|
|
///
|
|
/// Returns: true if there are tasks to restore, false otherwise
|
|
bool downloaderHasPendingSessionTasks({required String workingDir}) =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderHasPendingSessionTasks(
|
|
workingDir: workingDir,
|
|
);
|
|
|
|
/// Add a torrent from bytes (e.g., .torrent file content)
|
|
Future<BigInt> downloaderAddTorrent({
|
|
required List<int> torrentBytes,
|
|
String? outputFolder,
|
|
List<String>? trackers,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderAddTorrent(
|
|
torrentBytes: torrentBytes,
|
|
outputFolder: outputFolder,
|
|
trackers: trackers,
|
|
);
|
|
|
|
/// Add a torrent from a magnet link
|
|
Future<BigInt> downloaderAddMagnet({
|
|
required String magnetLink,
|
|
String? outputFolder,
|
|
List<String>? trackers,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderAddMagnet(
|
|
magnetLink: magnetLink,
|
|
outputFolder: outputFolder,
|
|
trackers: trackers,
|
|
);
|
|
|
|
/// Add a torrent from URL (HTTP download not supported, only torrent file URLs)
|
|
Future<BigInt> downloaderAddUrl({
|
|
required String url,
|
|
String? outputFolder,
|
|
List<String>? trackers,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderAddUrl(
|
|
url: url,
|
|
outputFolder: outputFolder,
|
|
trackers: trackers,
|
|
);
|
|
|
|
/// Pause a download task
|
|
Future<void> downloaderPause({required BigInt taskId}) =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderPause(taskId: taskId);
|
|
|
|
/// Resume a download task
|
|
Future<void> downloaderResume({required BigInt taskId}) =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderResume(taskId: taskId);
|
|
|
|
/// Remove a download task
|
|
/// Handles both active tasks (task_id < 10000) and cached completed tasks (task_id >= 10000)
|
|
Future<void> downloaderRemove({
|
|
required BigInt taskId,
|
|
required bool deleteFiles,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderRemove(
|
|
taskId: taskId,
|
|
deleteFiles: deleteFiles,
|
|
);
|
|
|
|
/// Get information about a specific task
|
|
Future<DownloadTaskInfo> downloaderGetTaskInfo({required BigInt taskId}) =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderGetTaskInfo(
|
|
taskId: taskId,
|
|
);
|
|
|
|
/// Get all tasks (includes both active and completed tasks from cache)
|
|
Future<List<DownloadTaskInfo>> downloaderGetAllTasks() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderGetAllTasks();
|
|
|
|
/// Get global statistics
|
|
Future<DownloadGlobalStat> downloaderGetGlobalStats() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderGetGlobalStats();
|
|
|
|
/// Check if a task with given name exists
|
|
///
|
|
/// Parameters:
|
|
/// - name: Task name to search for
|
|
/// - downloading_only: If true, only search in active/waiting tasks. If false, include completed tasks (default: true)
|
|
Future<bool> downloaderIsNameInTask({
|
|
required String name,
|
|
bool? downloadingOnly,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderIsNameInTask(
|
|
name: name,
|
|
downloadingOnly: downloadingOnly,
|
|
);
|
|
|
|
/// Pause all tasks
|
|
Future<void> downloaderPauseAll() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderPauseAll();
|
|
|
|
/// Resume all tasks
|
|
Future<void> downloaderResumeAll() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderResumeAll();
|
|
|
|
/// Stop the downloader session (pauses all tasks but keeps session)
|
|
Future<void> downloaderStop() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderStop();
|
|
|
|
/// Shutdown the downloader session completely (allows restart with new settings)
|
|
Future<void> downloaderShutdown() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderShutdown();
|
|
|
|
/// Get all completed tasks from cache (tasks removed by downloader_remove_completed_tasks)
|
|
/// This cache is cleared when the downloader is shutdown/restarted
|
|
List<DownloadTaskInfo> downloaderGetCompletedTasksCache() => RustLib
|
|
.instance
|
|
.api
|
|
.crateApiDownloaderApiDownloaderGetCompletedTasksCache();
|
|
|
|
/// Clear the completed tasks cache manually
|
|
void downloaderClearCompletedTasksCache() => RustLib.instance.api
|
|
.crateApiDownloaderApiDownloaderClearCompletedTasksCache();
|
|
|
|
/// 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.
|
|
Future<void> downloaderUpdateSpeedLimits({
|
|
int? uploadLimitBps,
|
|
int? downloadLimitBps,
|
|
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderUpdateSpeedLimits(
|
|
uploadLimitBps: uploadLimitBps,
|
|
downloadLimitBps: downloadLimitBps,
|
|
);
|
|
|
|
/// Remove all completed tasks (equivalent to aria2's --seed-time=0 behavior)
|
|
/// Removed tasks are cached in memory and can be queried via downloader_get_completed_tasks_cache
|
|
Future<int> downloaderRemoveCompletedTasks() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderRemoveCompletedTasks();
|
|
|
|
/// Check if there are any active (non-completed) tasks
|
|
Future<bool> downloaderHasActiveTasks() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloaderHasActiveTasks();
|
|
|
|
/// Global statistics
|
|
class DownloadGlobalStat {
|
|
final BigInt downloadSpeed;
|
|
final BigInt uploadSpeed;
|
|
final BigInt numActive;
|
|
final BigInt numWaiting;
|
|
|
|
const DownloadGlobalStat({
|
|
required this.downloadSpeed,
|
|
required this.uploadSpeed,
|
|
required this.numActive,
|
|
required this.numWaiting,
|
|
});
|
|
|
|
static Future<DownloadGlobalStat> default_() =>
|
|
RustLib.instance.api.crateApiDownloaderApiDownloadGlobalStatDefault();
|
|
|
|
@override
|
|
int get hashCode =>
|
|
downloadSpeed.hashCode ^
|
|
uploadSpeed.hashCode ^
|
|
numActive.hashCode ^
|
|
numWaiting.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is DownloadGlobalStat &&
|
|
runtimeType == other.runtimeType &&
|
|
downloadSpeed == other.downloadSpeed &&
|
|
uploadSpeed == other.uploadSpeed &&
|
|
numActive == other.numActive &&
|
|
numWaiting == other.numWaiting;
|
|
}
|
|
|
|
/// Download task information
|
|
class DownloadTaskInfo {
|
|
final BigInt id;
|
|
final String name;
|
|
final DownloadTaskStatus status;
|
|
final BigInt totalBytes;
|
|
final BigInt downloadedBytes;
|
|
final BigInt uploadedBytes;
|
|
final BigInt downloadSpeed;
|
|
final BigInt uploadSpeed;
|
|
final double progress;
|
|
final BigInt numPeers;
|
|
final String outputFolder;
|
|
|
|
const DownloadTaskInfo({
|
|
required this.id,
|
|
required this.name,
|
|
required this.status,
|
|
required this.totalBytes,
|
|
required this.downloadedBytes,
|
|
required this.uploadedBytes,
|
|
required this.downloadSpeed,
|
|
required this.uploadSpeed,
|
|
required this.progress,
|
|
required this.numPeers,
|
|
required this.outputFolder,
|
|
});
|
|
|
|
@override
|
|
int get hashCode =>
|
|
id.hashCode ^
|
|
name.hashCode ^
|
|
status.hashCode ^
|
|
totalBytes.hashCode ^
|
|
downloadedBytes.hashCode ^
|
|
uploadedBytes.hashCode ^
|
|
downloadSpeed.hashCode ^
|
|
uploadSpeed.hashCode ^
|
|
progress.hashCode ^
|
|
numPeers.hashCode ^
|
|
outputFolder.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is DownloadTaskInfo &&
|
|
runtimeType == other.runtimeType &&
|
|
id == other.id &&
|
|
name == other.name &&
|
|
status == other.status &&
|
|
totalBytes == other.totalBytes &&
|
|
downloadedBytes == other.downloadedBytes &&
|
|
uploadedBytes == other.uploadedBytes &&
|
|
downloadSpeed == other.downloadSpeed &&
|
|
uploadSpeed == other.uploadSpeed &&
|
|
progress == other.progress &&
|
|
numPeers == other.numPeers &&
|
|
outputFolder == other.outputFolder;
|
|
}
|
|
|
|
/// Download task status
|
|
enum DownloadTaskStatus {
|
|
/// Checking/verifying existing files
|
|
checking,
|
|
|
|
/// Actively downloading
|
|
live,
|
|
|
|
/// Paused
|
|
paused,
|
|
|
|
/// Error occurred
|
|
error,
|
|
|
|
/// Download completed
|
|
finished,
|
|
}
|