use std::{
path::{Path, PathBuf},
sync::Arc,
};
use crate::io::walk::S3Walker;
use crate::telemetry::TARGET_TRANSFER_DOWNLOAD_OBJECTS;
use crate::types::FailedTransferPolicy;
use super::{DownloadObjectsHandle, DownloadObjectsInputBuilder};
#[derive(Debug)]
pub struct DownloadObjectsFluentBuilder {
handle: Arc<crate::client::Handle>,
inner: DownloadObjectsInputBuilder,
}
impl DownloadObjectsFluentBuilder {
pub(crate) fn new(handle: Arc<crate::client::Handle>) -> Self {
Self {
handle,
inner: std::default::Default::default(),
}
}
#[tracing::instrument(skip_all, level = "debug", target = TARGET_TRANSFER_DOWNLOAD_OBJECTS, name = "initiate-download-objects", fields(
bucket = self.inner.bucket.as_deref().unwrap_or_default(),
destination = self.inner.destination.as_deref().map(|p| p.to_str().unwrap_or_default()).unwrap_or_default(),
))]
pub fn initiate(self) -> Result<DownloadObjectsHandle, crate::error::Error> {
let input = self.inner.build()?;
crate::operation::download_objects::DownloadObjects::orchestrate(self.handle, input)
}
pub fn bucket(mut self, input: impl Into<String>) -> Self {
self.inner = self.inner.bucket(input);
self
}
pub fn set_bucket(mut self, input: Option<String>) -> Self {
self.inner = self.inner.set_bucket(input);
self
}
pub fn get_bucket(&self) -> Option<&str> {
self.inner.get_bucket()
}
pub fn destination(mut self, input: impl Into<PathBuf>) -> Self {
self.inner = self.inner.destination(input);
self
}
pub fn set_destination(mut self, input: Option<PathBuf>) -> Self {
self.inner = self.inner.set_destination(input);
self
}
pub fn get_destination(&self) -> Option<&Path> {
self.inner.get_destination()
}
pub fn delimiter(mut self, input: impl Into<String>) -> Self {
self.inner = self.inner.delimiter(input);
self
}
pub fn set_delimiter(mut self, input: Option<String>) -> Self {
self.inner = self.inner.set_delimiter(input);
self
}
pub fn get_delimiter(&self) -> Option<&str> {
self.inner.get_delimiter()
}
pub fn failure_policy(mut self, input: FailedTransferPolicy) -> Self {
self.inner = self.inner.failure_policy(input);
self
}
pub fn set_failure_policy(mut self, input: Option<FailedTransferPolicy>) -> Self {
self.inner = self.inner.set_failure_policy(input);
self
}
pub fn get_failure_policy(&self) -> &FailedTransferPolicy {
self.inner.get_failure_policy()
}
pub fn walker(mut self, input: S3Walker) -> Self {
self.inner = self.inner.walker(input);
self
}
pub fn set_walker(mut self, input: Option<S3Walker>) -> Self {
self.inner = self.inner.set_walker(input);
self
}
pub fn get_walker(&self) -> Option<&S3Walker> {
self.inner.get_walker()
}
pub fn max_concurrent_downloads(mut self, input: usize) -> Self {
self.inner = self.inner.max_concurrent_downloads(input);
self
}
pub fn set_max_concurrent_downloads(mut self, input: Option<usize>) -> Self {
self.inner = self.inner.set_max_concurrent_downloads(input);
self
}
pub fn get_max_concurrent_downloads(&self) -> Option<usize> {
self.inner.get_max_concurrent_downloads()
}
}
impl crate::operation::download_objects::input::DownloadObjectsInputBuilder {
pub fn initiate_with(
self,
client: &crate::Client,
) -> Result<DownloadObjectsHandle, crate::error::Error> {
let mut fluent_builder = client.download_objects();
fluent_builder.inner = self;
fluent_builder.initiate()
}
}