seed-rs / seed-quickstart

Bare essentials to start a Seed app.
https://seed-rs.org/
101 stars 28 forks source link

Error when add [dependencies] mongodb="0.9.0" to Cargo.toml #23

Closed jsyszh closed 4 years ago

jsyszh commented 4 years ago

When I add mongodb to the dependencies, like this, [dependencies] mongodb = "0.9.0" and then run cargo make watch in the terminal, then, so many errors occurs, like this,

    error[E0425]: cannot find value `IPV6_V6ONLY` in this scope
       --> C:\Users\zh\.cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.34\src\ext.rs:871:50
        |
    871 |         get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
        |                                                  ^^^^^^^^^^^ not found in this scope

    error[E0425]: cannot find value `SOL_SOCKET` in this scope
       --> C:\Users\zh\.cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.34\src\ext.rs:879:33
        |
    879 |         get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
        |                                 ^^^^^^^^^^ not found in this scope

......

MartinKavik commented 4 years ago

It looks like mongodb cannot be run in WASM. I had similar errors when I accidentally tried to compile Hyper to WASM (https://github.com/deprecrated/net2-rs/issues/75#issuecomment-485908436 and https://github.com/deprecrated/net2-rs/issues/75#issuecomment-526039705). Also there is a similar error - https://github.com/rustwasm/wasm-pack/issues/749.

So I'm not sure if it's Seed's bug. cargo make watch basically just invokes wasm-pack for compilation to WASM. I recommend to ask mongodb guys if it's doable - I didn't find any useful information.

MartinKavik commented 4 years ago

@jsyszh Why do you want to communicate with Mongo directly? I'm not familiar with Mongo too much, but I thought it was always hidden behind classic Rest/GraphQL API.

jsyszh commented 4 years ago

@MartinKavik Thank you for answering me. I thought I didn't understand wasm. MongoDB can not compilation to WASM directly, just like any other database such as MySQL, Redis. I need to set up a server to communicate with MongDB or other database.

MartinKavik commented 4 years ago

MongoDB can not compilation to WASM directly, just like any other database such as MySQL, Redis.

@jsyszh Write on Seed forum if you want to recommend an architecture with Seed for your app or have some other questions.