fix(bat-api): 完成 issue #19 同机 live 联调
bat-rust / Build and test Go API (push) Canceled after 0s
bat-rust / Build and test Rust (push) Canceled after 0s

This commit is contained in:
2026-08-29 22:58:01 +08:00
parent 90083302a2
commit 7f465523e1
22 changed files with 819 additions and 115 deletions
+6 -2
View File
@@ -24,6 +24,10 @@ pub trait DownloaderBackend<T>: Send + Sync {
fn download(&self, task: T) -> Result<Self::Output, Self::Error>;
}
/// Results returned by a scheduler for a task type and backend.
pub type DownloadResults<T, B> =
Vec<Result<<B as DownloaderBackend<T>>::Output, <B as DownloaderBackend<T>>::Error>>;
/// A bounded worker scheduler.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DownloadScheduler {
@@ -54,7 +58,7 @@ impl DownloadScheduler {
/// order. A failed task does not cause additional tasks to be scheduled
/// after it, because already-started bounded work must be joined cleanly;
/// callers decide whether a failed result invalidates the whole release.
pub fn execute<T, B>(self, backend: &B, tasks: Vec<T>) -> Vec<Result<B::Output, B::Error>>
pub fn execute<T, B>(self, backend: &B, tasks: Vec<T>) -> DownloadResults<T, B>
where
T: Send + 'static,
B: DownloaderBackend<T>,
@@ -78,7 +82,7 @@ impl DownloadScheduler {
backend: &B,
tasks: Vec<T>,
mut observer: F,
) -> Result<Vec<Result<B::Output, B::Error>>, E>
) -> Result<DownloadResults<T, B>, E>
where
T: Send + 'static,
B: DownloaderBackend<T>,