pub trait ParallelUploader: Uploader + Send + Sync {
    // Required method
    fn upload_asset(
        &self,
        asset: AssetInfo
    ) -> JoinHandle<Result<(String, String)>>;

    // Provided method
    fn parallel_limit(&self) -> usize { ... }
}
Expand description

Types that can upload assets in parallel.

This trait abstracts the threading logic and allows methods to focus on the logic of uploading a single asset (file).

Required Methods§

source

fn upload_asset(&self, asset: AssetInfo) -> JoinHandle<Result<(String, String)>>

Returns a JoinHandle to the task responsible to upload the specified asset.

Arguments
  • asset - The asset to upload
Example

In most cases, the function will return the value from tokio::spawn:

tokio::spawn(async move {
    // code responsible to upload a single asset
});

Provided Methods§

source

fn parallel_limit(&self) -> usize

Return the number of concurrent uploads allowed. The default implementation returns the value PARALLEL_LIMIT.

Implementors§