use crate::metrics::TransferMetrics;
use crate::types::FailedDownload;
#[non_exhaustive]
#[derive(Debug)]
pub struct DownloadObjectsOutput {
pub objects_downloaded: u64,
pub failed_transfers: Vec<FailedDownload>,
pub metrics: TransferMetrics,
}
impl DownloadObjectsOutput {
pub fn builder() -> DownloadObjectsOutputBuilder {
DownloadObjectsOutputBuilder::default()
}
pub fn objects_downloaded(&self) -> u64 {
self.objects_downloaded
}
pub fn failed_transfers(&self) -> &[FailedDownload] {
self.failed_transfers.as_slice()
}
pub fn metrics(&self) -> &TransferMetrics {
&self.metrics
}
}
#[non_exhaustive]
#[derive(Debug, Default)]
pub struct DownloadObjectsOutputBuilder {
pub(crate) objects_downloaded: u64,
pub(crate) failed_transfers: Vec<FailedDownload>,
pub(crate) metrics: Option<TransferMetrics>,
}
impl DownloadObjectsOutputBuilder {
pub fn objects_downloaded(mut self, input: u64) -> Self {
self.objects_downloaded = input;
self
}
pub fn failed_transfers(mut self, input: FailedDownload) -> Self {
self.failed_transfers.push(input);
self
}
pub fn set_failed_transfers(mut self, input: Vec<FailedDownload>) -> Self {
self.failed_transfers = input;
self
}
pub fn metrics(mut self, input: TransferMetrics) -> Self {
self.metrics = Some(input);
self
}
pub fn build(self) -> DownloadObjectsOutput {
DownloadObjectsOutput {
objects_downloaded: self.objects_downloaded,
failed_transfers: self.failed_transfers,
metrics: self.metrics.expect("metrics must be set"),
}
}
}