chore: initial sanitized public snapshot
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
#![doc(hidden)]
|
||||
#![expect(
|
||||
clippy::redundant_pub_crate,
|
||||
reason = "this private runtime host module is an internal orchestration façade for the CLI crate split"
|
||||
)]
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use aria2_rust_pro_compat::ConfigProfile;
|
||||
use aria2_rust_pro_core::RuntimeConfig;
|
||||
use aria2_rust_pro_protocol::Downloader;
|
||||
use aria2_rust_pro_storage::ControlFileVersion;
|
||||
|
||||
use super::{
|
||||
CliError, CliTransferSource, Invocation, RuntimeReport, StartupProfile, derive_http_session,
|
||||
};
|
||||
use crate::{
|
||||
runtime_execution::{collect_runtime_execution_summary, execute_registered_transfers},
|
||||
runtime_planning::{build_runtime_input_context, register_runtime_entries},
|
||||
};
|
||||
|
||||
pub(super) fn execute_runtime_with_downloader_impl<D: Downloader + Sync>(
|
||||
invocation: Invocation,
|
||||
startup: &StartupProfile,
|
||||
cli_profile: Option<&ConfigProfile>,
|
||||
cli_transfer_sources: Option<&[CliTransferSource]>,
|
||||
downloader: &D,
|
||||
) -> Result<RuntimeReport, CliError> {
|
||||
match invocation {
|
||||
Invocation::Version | Invocation::Help { .. } => Ok(empty_runtime_report()),
|
||||
Invocation::Run { config_path, uris } => execute_run_invocation(
|
||||
config_path,
|
||||
uris,
|
||||
startup,
|
||||
cli_profile,
|
||||
cli_transfer_sources,
|
||||
downloader,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn empty_runtime_report() -> RuntimeReport {
|
||||
RuntimeReport {
|
||||
accepted_uri_count: 0,
|
||||
tracked_download_count: 0,
|
||||
completed_download_count: 0,
|
||||
first_gid: None,
|
||||
first_status: None,
|
||||
first_total_length: None,
|
||||
first_completed_length: None,
|
||||
first_connections: None,
|
||||
recognized_schemes: Vec::new(),
|
||||
transfer_kinds: Vec::new(),
|
||||
config_report: None,
|
||||
derived_runtime: RuntimeConfig::default(),
|
||||
http_session: derive_http_session(None, &StartupProfile::default()),
|
||||
control_file_version_major: ControlFileVersion::CURRENT.major(),
|
||||
first_bt_status: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_run_invocation<D: Downloader + Sync>(
|
||||
config_path: Option<PathBuf>,
|
||||
uris: Vec<String>,
|
||||
startup: &StartupProfile,
|
||||
cli_profile: Option<&ConfigProfile>,
|
||||
cli_transfer_sources: Option<&[CliTransferSource]>,
|
||||
downloader: &D,
|
||||
) -> Result<RuntimeReport, CliError> {
|
||||
let context = build_runtime_input_context(
|
||||
config_path,
|
||||
uris,
|
||||
startup,
|
||||
cli_profile,
|
||||
cli_transfer_sources,
|
||||
downloader,
|
||||
)?;
|
||||
let base_profile = context.effective_profile.as_ref();
|
||||
let mut dispatcher =
|
||||
super::InProcessRpcDispatcher::with_runtime(context.derived_runtime.clone());
|
||||
let registered_entries = register_runtime_entries(
|
||||
&mut dispatcher,
|
||||
downloader,
|
||||
context.resolved_entries,
|
||||
base_profile,
|
||||
)?;
|
||||
execute_registered_transfers(
|
||||
&mut dispatcher,
|
||||
downloader,
|
||||
®istered_entries,
|
||||
base_profile,
|
||||
&context.derived_runtime,
|
||||
)?;
|
||||
let summary = collect_runtime_execution_summary(&mut dispatcher, ®istered_entries)?;
|
||||
|
||||
Ok(RuntimeReport {
|
||||
accepted_uri_count: registered_entries.len(),
|
||||
tracked_download_count: summary.tracked_download_count,
|
||||
completed_download_count: summary.completed_download_count,
|
||||
first_gid: summary.first_gid,
|
||||
first_status: summary.first_status,
|
||||
first_total_length: summary.first_total_length,
|
||||
first_completed_length: summary.first_completed_length,
|
||||
first_connections: summary.first_connections,
|
||||
recognized_schemes: context.recognized_schemes,
|
||||
transfer_kinds: context.transfer_kinds,
|
||||
config_report: context.config_report,
|
||||
derived_runtime: context.derived_runtime,
|
||||
http_session: context.http_session,
|
||||
control_file_version_major: ControlFileVersion::CURRENT.major(),
|
||||
first_bt_status: summary.first_bt_status,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user