Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo.toml requirements unclear to run examples #141

Open
ananswam opened this issue Dec 23, 2020 · 1 comment
Open

Cargo.toml requirements unclear to run examples #141

ananswam opened this issue Dec 23, 2020 · 1 comment

Comments

@ananswam
Copy link

I'm fairly new to Rust, so feel free to call me a noob and close this. I was trying to get the server example to run. I was able to do so easily by cloning and running cargo run --example server 127.0.0.1:12345 as suggested.

However, when I started to incorporate that file content into my own project, I got all kinds of weird errors until I combed through the Cargo.toml file for tokio-tungstenite and added the following to my own Cargo.toml.

[dependencies]
tokio-tungstenite = "*"

futures-util = { version = "0.3", default-features = false, features = ["async-await", "sink", "std"] }
pin-project = "1.0"
futures-channel = "0.3"
tokio = { version = "0.3", default-features = false, features = ["io-std", "macros", "rt-multi-thread", "stream", "time"] }

[dependencies.tungstenite]
version = "0.11.1"
default-features = false

Initially, I tried just adding futures-util and futures-channel and tokio with the latest versions and default features based on what the IDE did not recognize, and I got compile errors. I think it must have been due to version incompatibility or feature selection.

In any case, I am all up and running now and excited to use the code, but it might be helpful to have the full above Cargo.toml snippet included with the example.

@daniel-abramov
Copy link
Member

Thanks for pointing out to that. Yeah, it's a bit boilerplate, which probably could be simplified at some point, so that we need less dependencies at the beginning. Tokio-related crates is something that we expect a person is familiar with since being not familiar with them makes the effective usage of tokio-tunsgtenite a bit complicated (as well as writing a new async-code).

Out of curiosity: why did you need to specify the tunsgtenite dependency? I may assume it's due to example using tungstenite explicitly, right? If so, I have a small hint: we re-expert the tungstenite in tokio-tungstenite, so that you don't need to include tungstenite dependency in your Cargo.toml directly to import the Message type, i.e. something like: use tokio_tungstenite::tungstenite::Message would do.

(Yes, I know, our example of server could be improved ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants