mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Replace dep futures-util
with futures-lite
in binstalk-downloader (#764)
`futures-util` has too many dependencies and it contains a lot of code of which we only use a tiny bit of them. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
6bc1fb4983
commit
833684b095
7 changed files with 47 additions and 30 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -214,7 +214,7 @@ dependencies = [
|
|||
"compact_str",
|
||||
"digest",
|
||||
"flate2",
|
||||
"futures-util",
|
||||
"futures-lite",
|
||||
"generic-array",
|
||||
"httpdate",
|
||||
"reqwest",
|
||||
|
@ -847,6 +847,16 @@ version = "0.3.26"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
|
||||
|
||||
[[package]]
|
||||
name = "futures-lite"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.26"
|
||||
|
|
|
@ -19,7 +19,7 @@ bzip2 = "0.4.4"
|
|||
compact_str = "0.6.1"
|
||||
digest = "0.10.6"
|
||||
flate2 = { version = "1.0.25", default-features = false }
|
||||
futures-util = { version = "0.3.26", default-features = false, features = ["std"] }
|
||||
futures-lite = { version = "1.12.0", default-features = false }
|
||||
generic-array = "0.14.6"
|
||||
httpdate = "1.0.2"
|
||||
reqwest = { version = "0.11.14", features = ["stream", "gzip", "brotli", "deflate"], default-features = false }
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{fmt::Debug, io, marker::PhantomData, path::Path};
|
|||
|
||||
use binstalk_types::cargo_toml_binstall::PkgFmtDecomposed;
|
||||
use digest::{Digest, FixedOutput, HashMarker, Output, OutputSizeUser, Update};
|
||||
use futures_util::stream::StreamExt;
|
||||
use futures_lite::stream::StreamExt;
|
||||
use thiserror::Error as ThisError;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::{
|
|||
|
||||
use async_zip::read::stream::ZipFileReader;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_util::{
|
||||
future::try_join,
|
||||
use futures_lite::{
|
||||
future::try_zip as try_join,
|
||||
stream::{Stream, StreamExt},
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{borrow::Cow, fmt::Debug, io, path::Path, pin::Pin};
|
|||
|
||||
use async_compression::tokio::bufread;
|
||||
use bytes::Bytes;
|
||||
use futures_util::stream::{Stream, StreamExt};
|
||||
use futures_lite::stream::{Stream, StreamExt};
|
||||
use tokio::io::{copy, sink, AsyncRead};
|
||||
use tokio_tar::{Archive, Entry, EntryType};
|
||||
use tokio_util::io::StreamReader;
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
|
||||
use async_zip::{read::ZipEntryReader, ZipEntryExt};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_util::future::{try_join, TryFutureExt};
|
||||
use futures_lite::future::try_zip as try_join;
|
||||
use thiserror::Error as ThisError;
|
||||
use tokio::{
|
||||
io::{AsyncRead, AsyncReadExt},
|
||||
|
@ -78,8 +78,8 @@ where
|
|||
let (tx, mut rx) = mpsc::channel::<Bytes>(5);
|
||||
|
||||
// This entry is a file.
|
||||
try_join(
|
||||
asyncify(move || {
|
||||
|
||||
let write_task = asyncify(move || {
|
||||
if let Some(p) = outpath.parent() {
|
||||
std::fs::create_dir_all(p)?;
|
||||
}
|
||||
|
@ -96,11 +96,18 @@ where
|
|||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.err_into(),
|
||||
copy_file_to_mpsc(entry, tx, buf)
|
||||
});
|
||||
|
||||
let read_task = copy_file_to_mpsc(entry, tx, buf);
|
||||
|
||||
try_join(
|
||||
async move { write_task.await.map_err(From::from) },
|
||||
async move {
|
||||
read_task
|
||||
.await
|
||||
.map_err(ZipError::from_inner)
|
||||
.map_err(DownloadError::from),
|
||||
.map_err(DownloadError::from)
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_util::stream::{Stream, StreamExt};
|
||||
use futures_lite::stream::{Stream, StreamExt};
|
||||
use httpdate::parse_http_date;
|
||||
use reqwest::{
|
||||
header::{HeaderMap, RETRY_AFTER},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue