taskcluster_download/
lib.rs

1/*! Support for downloading data from the object service.
2
3This crate provides a set of functions to download data from the object service.
4These functions negotiate a download method with the object service, then perform the download, following all of the Taskcluster recommended practices.
5
6Each function takes the necessary metadata for the download, a handle to the a destination for the data, and a [taskcluster::Object] client.
7The destination can take a variety of forms, as described below.
8The client must be configured with the necessary credentials to access the object service.
9
10## Convenience Functions
11
12Most uses of this crate can utilize one of the following convenience functions:
13
14* [download_to_buf] -- download data to a fixed-size buffer;
15* [download_to_vec] -- download data to a dynamically allocated buffer; or
16* [download_to_file] -- download data to a [tokio::fs::File].
17
18## Artifacts
19
20This crate also supports downloads of artifacts, including all defined storage types.
21This combines a query to the queue service to request the artifact metadata with the appropriate process to download that data.
22In the case of error artifacts, a [`Result::Err`] is returned.
23
24* [download_artifact_to_buf] -- download artifact data to a fixed-size buffer;
25* [download_artifact_to_vec] -- download artifact data to a dynamically allocated buffer; or
26* [download_artifact_to_file] -- download artifact data to a [tokio::fs::File].
27
28## Factories
29
30A download may be retried, in which case the download function must have a means to truncate the data destination and begin writing from the beginning.
31This is accomplished with the [`AsyncWriterFactory`](crate::AsyncWriterFactory) trait, which defines a `get_writer` method to generate a fresh [tokio::io::AsyncWrite] for each attempt.
32Users for whom the supplied convenience functions are inadequate can add their own implementation of this trait.
33
34 */
35mod artifact;
36mod factory;
37mod geturl;
38mod hashing;
39mod object;
40mod service;
41
42#[cfg(test)]
43mod test_helpers;
44
45pub use artifact::{
46    download_artifact_to_buf, download_artifact_to_file, download_artifact_to_vec,
47    download_artifact_with_factory,
48};
49pub use factory::{AsyncWriterFactory, CursorWriterFactory, FileWriterFactory};
50pub use object::{download_to_buf, download_to_file, download_to_vec, download_with_factory};