use std::future::Future;
use std::path::Path;
use crate::config::DownloadOptions;
use crate::error::Result;
use crate::event::ProgressEvent;
use crate::http::{HttpRequest, HttpResponse};
use crate::manifest::{Manifest, Stream};
use crate::mux::OutputArtifact;
pub trait HttpClient {
fn send(&self, request: HttpRequest) -> impl Future<Output = Result<HttpResponse>> + Send + '_;
}
pub trait Storage {
fn write_all<'a>(
&'a self,
path: &'a Path,
bytes: &'a [u8],
) -> impl Future<Output = Result<()>> + Send + 'a;
}
pub trait ManifestLoader {
fn load(&self, input: &str) -> impl Future<Output = Result<Manifest>> + Send + '_;
}
pub trait KeyProvider {
fn key_for(&self, key_id: &str) -> impl Future<Output = Result<Option<Vec<u8>>>> + Send + '_;
}
pub trait Decryptor {
fn decrypt<'a>(
&'a self,
input: &'a Path,
output: &'a Path,
) -> impl Future<Output = Result<()>> + Send + 'a;
}
pub trait Muxer {
fn mux<'a>(
&'a self,
streams: &'a [Stream],
options: &'a DownloadOptions,
) -> impl Future<Output = Result<Vec<OutputArtifact>>> + Send + 'a;
}
pub trait ProgressSink {
fn emit(&self, event: ProgressEvent) -> Result<()>;
}
pub trait Cancellation {
fn is_cancelled(&self) -> bool;
}