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

Mismatched types error when compiling with websocket feature #180

Open
h2cone opened this issue Dec 17, 2024 · 1 comment
Open

Mismatched types error when compiling with websocket feature #180

h2cone opened this issue Dec 17, 2024 · 1 comment

Comments

@h2cone
Copy link

h2cone commented Dec 17, 2024

First of all, thank you for maintaining such a great project! While testing the WebSocket functionality with the example code provided in the All in one: TCP, UDP and WebSocket echo server, I encountered a compilation error when enabling the websocket feature (or using default features).

The following compilation errors occur:

❯ cargo run
   Compiling message-io v0.18.2
error[E0308]: mismatched types
   --> /home/metaflow/.cargo/registry/src/index.crates.io-6f17d22bba15001f/message-io-0.18.2/src/adapters/ws.rs:138:42
    |
138 | ...                   process_data(&data);
    |                       ------------ ^^^^^ expected `&[u8]`, found `&Payload`
    |                       |
    |                       arguments to this function are incorrect
    |
    = note: expected reference `&[u8]`
               found reference `&Payload`
note: type parameter defined here
   --> /home/metaflow/.cargo/registry/src/index.crates.io-6f17d22bba15001f/message-io-0.18.2/src/adapters/ws.rs:116:41
    |
116 |     fn receive(&self, mut process_data: impl FnMut(&[u8])) -> ReadStatus {
    |                                         ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> /home/metaflow/.cargo/registry/src/index.crates.io-6f17d22bba15001f/message-io-0.18.2/src/adapters/ws.rs:165:47
    |
165 |                 let message = Message::Binary(data.to_vec());
    |                               --------------- ^^^^^^^^^^^^^ expected `Payload`, found `Vec<u8>`
    |                               |
    |                               arguments to this enum variant are incorrect
    |
    = note: expected enum `Payload`
             found struct `std::vec::Vec<u8>`
note: tuple variant defined here
   --> /home/metaflow/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tungstenite-0.25.0/src/protocol/message.rs:159:5
    |
159 |     Binary(Payload),
    |     ^^^^^^
help: try wrapping the expression in `tungstenite::protocol::frame::Payload::Vec`
    |
165 |                 let message = Message::Binary(tungstenite::protocol::frame::Payload::Vec(data.to_vec()));
    |                                               +++++++++++++++++++++++++++++++++++++++++++             +

For more information about this error, try `rustc --explain E0308`.
error: could not compile `message-io` (lib) due to 2 previous errors
@lemunozm
Copy link
Owner

Thanks for arising this. Yes, it was a change introduced by the tungstenite dependency that should be fixed here: 77858e5

I need to create another release with that fix. By now it should compile if you use the message-io dependency with the github path to the master branch.

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

No branches or pull requests

2 participants