Skip to main content

PackageFetcher

Trait PackageFetcher 

Source
pub trait PackageFetcher:
    Debug
    + Send
    + Sync {
    // Required method
    fn fetch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
        destination: &'life2 Path,
    ) -> Pin<Box<dyn Future<Output = Result<u64, PackageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Streams a published package onto disk.

§Contract

  • The bytes are written to destination and nowhere else.
  • The implementation does not remove destination on failure. A partial file is the caller’s to discard, and PackageCache discards it — see PackageCache::prune’s neighbour, download_and_verify. Having the fetcher clean up would hide a partial download from the very test that proves it is removed.
  • Nothing is verified here. Verification is the cache’s, and it happens before extraction.

Required Methods§

Source

fn fetch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, url: &'life1 str, destination: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<u64, PackageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Stream url into destination, answering how many bytes were written.

§Errors

PackageError::Download for a transport or status failure, PackageError::Io for a write failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§