Skip to content

Commit 3835b93

Browse files
akhillesjbr
authored andcommitted
make async_std optional, add fs feature
1 parent 1dedf93 commit 3835b93

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ features = ["docs"]
1616
rustdoc-args = ["--cfg", "feature=\"docs\""]
1717

1818
[features]
19-
default = ["async_std", "cookie-secure"]
19+
default = ["fs", "cookie-secure"]
2020
docs = ["unstable"]
2121
unstable = []
2222
hyperium_http = ["http"]
23-
async_std = [] # "async-std" when it is not default
23+
async_std = ["fs"]
2424
cookie-secure = ["cookie/secure"]
25+
fs = ["async-std"]
2526

2627
[dependencies]
27-
# Note(yoshuawuyts): used for async_std's `channel` only; use "core" once possible.
2828
# features: async_std
29-
async-std = { version = "1.6.0", features = ["unstable"] }
29+
async-std = { version = "1.6.0", optional = true }
3030
futures-lite = "1.7.0"
3131
async-channel = "1.4.2"
3232

@@ -46,4 +46,4 @@ serde_qs = "0.7.0"
4646

4747
[dev-dependencies]
4848
http = "0.2.0"
49-
async-std = { version = "1.6.0", features = ["unstable", "attributes"] }
49+
async-std = { version = "1.6.0", features = ["attributes"] }

src/body.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl Body {
357357
/// res.set_body(Body::from_file("/path/to/file").await?);
358358
/// # Ok(()) }) }
359359
/// ```
360-
#[cfg(all(feature = "async_std", not(target_os = "unknown")))]
360+
#[cfg(all(feature = "fs", not(target_os = "unknown")))]
361361
pub async fn from_file<P>(path: P) -> io::Result<Self>
362362
where
363363
P: AsRef<std::path::Path>,
@@ -477,7 +477,7 @@ impl AsyncBufRead for Body {
477477

478478
/// Look at first few bytes of a file to determine the mime type.
479479
/// This is used for various binary formats such as images and videos.
480-
#[cfg(all(feature = "async_std", not(target_os = "unknown")))]
480+
#[cfg(all(feature = "fs", not(target_os = "unknown")))]
481481
async fn peek_mime(file: &mut async_std::fs::File) -> io::Result<Option<Mime>> {
482482
// We need to read the first 300 bytes to correctly infer formats such as tar.
483483
let mut buf = [0_u8; 300];
@@ -491,7 +491,7 @@ async fn peek_mime(file: &mut async_std::fs::File) -> io::Result<Option<Mime>> {
491491

492492
/// Look at the extension of a file to determine the mime type.
493493
/// This is useful for plain-text formats such as HTML and CSS.
494-
#[cfg(all(feature = "async_std", not(target_os = "unknown")))]
494+
#[cfg(all(feature = "fs", not(target_os = "unknown")))]
495495
fn guess_ext(path: &std::path::Path) -> Option<Mime> {
496496
let ext = path.extension().map(|p| p.to_str()).flatten();
497497
ext.and_then(Mime::from_extension)

0 commit comments

Comments
 (0)