Skip to content

Commit

Permalink
Stop using borrows of reqwest::Client (rust-lang#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod authored Sep 4, 2022
1 parent 1cf6076 commit f5a682c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/lib/src/drivers/crates_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/fetchers/gh_crate_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/fetchers/quickinstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions crates/lib/src/helpers/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/helpers/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}'");
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f5a682c

Please sign in to comment.