rust - 如何在#[no_std] 环境中使用 Tokio Reactor?

标签 rust future rust-cargo rust-tokio

我正在尝试在 Tock OS 嵌入式操作系统上实现 future 。我正在尝试使用 Tokio#[no_std] 环境中。

我的 Cargo.toml 文件如下所示:

[package]
name = "nrf52dk"
version = "0.1.0"
authors = ["Tock Project Developers <tock-dev@googlegroups.com>"]
build = "build.rs"

[profile.dev]
panic = "abort"
lto = true
opt-level = "z"
debug = true

[profile.release]
panic = "abort"
lto = true
opt-level = "z"
debug = true

[dependencies]
cortexm4 = { path = "../../arch/cortex-m4" }
capsules = { path = "../../capsules" }
kernel = { path = "../../kernel" }
nrf52 = { path = "../../chips/nrf52" }
nrf5x = { path = "../../chips/nrf5x" }
futures = {version = "0.2.0", default-features = false }

编译没有错误,但是当我添加 tokio-reactor = "0.1.1" 时,我收到错误:error[E0463]: can't find crate for std。我知道这是因为 Tokio 从 std 库中导入了一些东西。

有没有可能解决这个问题?

最佳答案

据我所知,你没有。 Tokio Reactor 0.1.1 imports many things from the standard library , 它们都不是有条件的。

大多数导入可能会切换到 libcore 替代方案,但 Arc 需要内存分配,它位于 alloc crate 中。

作为支持 no_std 的 crate 示例,查看 Futures 0.1.20 .这有一个功能标志,可以选择加入需要标准库的功能。

如果您希望这样做,您需要为 Tokio 及其所有依赖项做出大量努力,以添加功能标志以选择加入需要标准库的所有功能。值得向维护者提出一个问题来协调这样的工作。

关于rust - 如何在#[no_std] 环境中使用 Tokio Reactor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49922999/

相关文章:

clojure - 我想并行化我的 Clojure 实现

java - Spring @Async 与 future

c++ - 将来尝试引用已删除的函数

powershell - 显示颜色代码而不是颜色

macros - 有没有办法从文档中隐藏宏模式?

rust - 如何创建特定数量结果的向量?

iteration - Rust 迭代器和展望(peek/multipeek)

rust - 类型注释需要静态生命周期

testing - 如何递归测试目录下的所有 crate ?

json - 以不同的格式反序列化 JSON - Serde_JSON