【发布时间】:2020-01-10 04:06:00
【问题描述】:
我对 rust 和 Web Assembly 非常陌生,并且有一个简单的示例站点。到目前为止,这只是非常简单的事情,而且一切正常。接下来我想看看连接MySQL。
在 Cargo.toml 中,我添加了:
[dependencies]
wasm-bindgen = "0.2.50"
mysql = "*"
没有 mysql 部分,一切都编译得很好。添加 mysql="*" 后,我会收到很多 (317) 错误。
一些错误示例:
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling net2 v0.2.33
Compiling libc v0.2.62
error[E0432]: unresolved import `sys`
--> /home/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src
/tcp.rs:18:5
|
18 | use sys::c;
| ^^^ maybe a missing `extern crate sys;`?
和
error[E0425]: cannot find value `timeout2ms` in this scope
--> /home/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1145:18
|
1145 | .map(timeout2ms)
| ^^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `SOL_SOCKET` in this scope
--> /home/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1149:33
|
1149 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO,
| ^^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `SO_SNDTIMEO` in this scope
--> /home/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1149:45
|
1149 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO,
| ^^^^^^^^^^^ not found in this scope
到目前为止,我还没有添加任何代码来实际连接到数据库。我只是想建立这个项目。 唯一的 区别在于添加了 mysql 依赖项。
我正在使用这个网站关于使用 MySQL 的信息:mysql - Rust
鉴于我是 Rust 新手,我不确定可能需要哪些其他信息来提供帮助。
编辑:我一直在用谷歌搜索这些错误,但没有运气。
【问题讨论】:
标签: mysql rust webassembly