mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Stop using borrows of reqwest::Client (#316)
This commit is contained in:
parent
1cf6076d62
commit
f5a682ccce
6 changed files with 11 additions and 11 deletions
|
@ -22,7 +22,7 @@ use visitor::ManifestVisitor;
|
||||||
|
|
||||||
/// Fetch a crate Cargo.toml by name and version from crates.io
|
/// Fetch a crate Cargo.toml by name and version from crates.io
|
||||||
pub async fn fetch_crate_cratesio(
|
pub async fn fetch_crate_cratesio(
|
||||||
client: &Client,
|
client: Client,
|
||||||
crates_io_api_client: &AsyncClient,
|
crates_io_api_client: &AsyncClient,
|
||||||
name: &str,
|
name: &str,
|
||||||
version_req: &VersionReq,
|
version_req: &VersionReq,
|
||||||
|
|
|
@ -145,7 +145,7 @@ impl super::Fetcher for GhCrateMeta {
|
||||||
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
|
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
|
||||||
let (url, pkg_fmt) = self.resolution.get().unwrap(); // find() is called first
|
let (url, pkg_fmt) = self.resolution.get().unwrap(); // find() is called first
|
||||||
debug!("Downloading package from: '{url}'");
|
debug!("Downloading package from: '{url}'");
|
||||||
Download::new(&self.client, url.clone())
|
Download::new(self.client.clone(), url.clone())
|
||||||
.and_extract(self.pkg_fmt(), dst)
|
.and_extract(self.pkg_fmt(), dst)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl super::Fetcher for QuickInstall {
|
||||||
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
|
async fn fetch_and_extract(&self, dst: &Path) -> Result<(), BinstallError> {
|
||||||
let url = self.package_url();
|
let url = self.package_url();
|
||||||
debug!("Downloading package from: '{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)
|
.and_extract(self.pkg_fmt(), dst)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,15 @@ mod extracter;
|
||||||
mod stream_readable;
|
mod stream_readable;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Download<'client, D: Digest = NoDigest> {
|
pub struct Download<D: Digest = NoDigest> {
|
||||||
client: &'client Client,
|
client: Client,
|
||||||
url: Url,
|
url: Url,
|
||||||
_digest: PhantomData<D>,
|
_digest: PhantomData<D>,
|
||||||
_checksum: Vec<u8>,
|
_checksum: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'client> Download<'client> {
|
impl Download {
|
||||||
pub fn new(client: &'client Client, url: Url) -> Self {
|
pub fn new(client: Client, url: Url) -> Self {
|
||||||
Self {
|
Self {
|
||||||
client,
|
client,
|
||||||
url,
|
url,
|
||||||
|
@ -82,8 +82,8 @@ impl<'client> Download<'client> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'client, D: Digest> Download<'client, D> {
|
impl<D: Digest> Download<D> {
|
||||||
pub fn new_with_checksum(client: &'client Client, url: Url, checksum: Vec<u8>) -> Self {
|
pub fn new_with_checksum(client: Client, url: Url, checksum: Vec<u8>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
client,
|
client,
|
||||||
url,
|
url,
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub async fn get_redirected_final_url(client: &Client, url: Url) -> Result<Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn create_request(
|
pub(crate) async fn create_request(
|
||||||
client: &Client,
|
client: Client,
|
||||||
url: Url,
|
url: Url,
|
||||||
) -> Result<impl Stream<Item = reqwest::Result<Bytes>>, BinstallError> {
|
) -> Result<impl Stream<Item = reqwest::Result<Bytes>>, BinstallError> {
|
||||||
debug!("Downloading from: '{url}'");
|
debug!("Downloading from: '{url}'");
|
||||||
|
|
|
@ -133,7 +133,7 @@ async fn resolve_inner(
|
||||||
Some(manifest_path) => load_manifest_path(manifest_path)?,
|
Some(manifest_path) => load_manifest_path(manifest_path)?,
|
||||||
None => {
|
None => {
|
||||||
fetch_crate_cratesio(
|
fetch_crate_cratesio(
|
||||||
&client,
|
client.clone(),
|
||||||
&crates_io_api_client,
|
&crates_io_api_client,
|
||||||
&crate_name.name,
|
&crate_name.name,
|
||||||
&version_req,
|
&version_req,
|
||||||
|
|
Loading…
Add table
Reference in a new issue