async-std
async-std copied to clipboard
Seems difficult to get a minimal set of features working
I am trying to reduce the dependencies of our project and I tried to use the minimal set of features for it.
I get this error:
error[E0425]: cannot find function `block_on` in module `task`
--> src/gstreamer.rs:18:15
|
18 | task::block_on(async move {
| ^^^^^^^^ not found in `task`
error[E0425]: cannot find function `sleep` in module `task`
--> src/gstreamer.rs:79:11
|
79 | task::sleep(std::time::Duration::from_secs(1)).await;
| ^^^^^ not found in `task`
|
help: possible candidate is found in another module, you can import it into scope
|
6 | use std::thread::sleep;
|
error[E0425]: cannot find function `spawn` in module `task`
--> src/gstreamer.rs:93:11
|
93 | task::spawn(feed_pipeline(playbin.clone(), manifest));
| ^^^^^ not found in `task`
|
help: possible candidate is found in another module, you can import it into scope
|
6 | use std::thread::spawn;
|
error[E0425]: cannot find function `block_on` in module `async_std::task`
--> src/main.rs:52:1
|
52 | #[async_std::main]
| ^^^^^^^^^^^^^^^^^^ not found in `async_std::task`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
and I am setting it as:
# Cargo.toml
async-std = { version = "1.5.0", default-features = false, features = ["std", "attributes", "unstable"] }
@otavio Hello. ¿Do you found a solution?
I didn't. I'd love to learn what would be the minimal.
Same problem.
The reason is using the cfg_default!
macro, which conditionally compiles depending on whether the "default" feature is enabled, which is a very bad idea, since it makes it impossible to pick and choose single features. Each sub-module should really depend on the minimal subset of features that it needs, instead on a forced superset.
Right now disabling the default
feature and enabling all the features contained in it doesn't work at all, and many modules like fs
, path
, net
, and many task
submodules doesn't get compiled.
# This doesn't work:
async-std = { version = "1.12.0", default-features = false, features = ["std", "async-global-executor", "async-io", "futures-lite", "kv-log-macro", "log", "pin-project-lite", "gloo-timers"] }
# But it should compile everything the same as:
# async-std = { version = "1.12.0", default-features = false, features = ["default"] }