Stop using borrows of reqwest::Client (#316)

This commit is contained in:
Félix Saparelli 2022-09-04 23:00:33 +12:00 committed by GitHub
parent 1cf6076d62
commit f5a682ccce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 11 deletions

View file

@ -22,7 +22,7 @@ use visitor::ManifestVisitor;
/// Fetch a crate Cargo.toml by name and version from crates.io
pub async fn fetch_crate_cratesio(
client: &Client,
client: Client,
crates_io_api_client: &AsyncClient,
name: &str,
version_req: &VersionReq,

View file

@ -145,7 +145,7 @@ impl super::Fetcher for GhCrateMeta {
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
let (url, pkg_fmt) = self.resolution.get().unwrap(); // find() is called first
debug!("Downloading package from: '{url}'");
Download::new(&self.client, url.clone())
Download::new(self.client.clone(), url.clone())
.and_extract(self.pkg_fmt(), dst)
.await
}

View file

@ -49,7 +49,7 @@ impl super::Fetcher for QuickInstall {
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
let url = self.package_url();
debug!("Downloading package from: '{url}'");
Download::new(&self.client, Url::parse(&url)?)
Download::new(self.client.clone(), Url::parse(&url)?)
.and_extract(self.pkg_fmt(), dst)
.await
}

View file

@ -18,15 +18,15 @@ mod extracter;
mod stream_readable;
#[derive(Debug)]
pub struct Download<'client, D: Digest = NoDigest> {
client: &'client Client,
pub struct Download<D: Digest = NoDigest> {
client: Client,
url: Url,
_digest: PhantomData<D>,
_checksum: Vec<u8>,
}
impl<'client> Download<'client> {
pub fn new(client: &'client Client, url: Url) -> Self {
impl Download {
pub fn new(client: Client, url: Url) -> Self {
Self {
client,
url,
@ -82,8 +82,8 @@ impl<'client> Download<'client> {
}
}
impl<'client, D: Digest> Download<'client, D> {
pub fn new_with_checksum(client: &'client Client, url: Url, checksum: Vec<u8>) -> Self {
impl<D: Digest> Download<D> {
pub fn new_with_checksum(client: Client, url: Url, checksum: Vec<u8>) -> Self {
Self {
client,
url,

View file

@ -56,7 +56,7 @@ pub async fn get_redirected_final_url(client: &Client, url: Url) -> Result<Url,
}
pub(crate) async fn create_request(
client: &Client,
client: Client,
url: Url,
) -> Result<impl Stream<Item = reqwest::Result<Bytes>>, BinstallError> {
debug!("Downloading from: '{url}'");

View file

@ -133,7 +133,7 @@ async fn resolve_inner(
Some(manifest_path) => load_manifest_path(manifest_path)?,
None => {
fetch_crate_cratesio(
&client,
client.clone(),
&crates_io_api_client,
&crate_name.name,
&version_req,