Trait condow_rusoto::Downloads
source · [−]pub trait Downloads: 'static + Send + Sync {
type Location: 'static + Debug + Display + Clone + Send + Sync;
fn blob(&self) -> RequestNoLocation<Self::Location>;
fn get_size(
&self,
location: Self::Location
) -> Pin<Box<dyn Future<Output = Result<u64, CondowError>> + Send, Global>>;
}
Expand description
A common interface for downloading
This trait is not object safe. If you want to use dynamic dispatch you might consider the trait DownloadsUntyped which is object safe and accepts string slices as a location.
use condow_core::{Condow, Downloads, config::Config};
use condow_core::condow_client::InMemoryClient;
// First we need a client... Let's make the type of the location simply `u32`s
let client = InMemoryClient::<i32>::new_static(b"a remote BLOB");
// ... and a configuration for Condow
let config = Config::default();
let condow = Condow::new(client, config).unwrap();
assert_eq!(Downloads::get_size(&condow, 42).await.unwrap(), 13);
let blob = Downloads::blob(&condow).at(42).download_into_vec().await.unwrap();
assert_eq!(blob, b"a remote BLOB");
// The trait can also be used dynamically:
let downloads_dyn_dispatch: Arc<dyn Downloads<Location = i32>> = Arc::new(condow);
let blob = downloads_dyn_dispatch.blob().at(42).download_into_vec().await.unwrap();
assert_eq!(blob, b"a remote BLOB");
Required Associated Types
Required Methods
fn blob(&self) -> RequestNoLocation<Self::Location>
fn blob(&self) -> RequestNoLocation<Self::Location>
Download a BLOB via the returned request object