Compilation errors on tungstenite home page example

Compilation errors using simple example
What's the issue? It looks like a legitimate error to me.

use std::net::TcpListener;
use std::thread::spawn;
use tungstenite::server::accept;

/// A WebSocket echo server
fn main () {
    let server = TcpListener::bind("").unwrap();
    for stream in server.incoming() {
        spawn (move || {
            let mut websocket = accept(stream.unwrap()).unwrap();
            loop {
                let msg = websocket.read_message().unwrap();

                // We do not want to send back ping/pong messages.
                if msg.is_binary() || msg.is_text() {
error[E0603]: module `server` is private
  --> src/
3  | use tungstenite::server::accept;
   |                  ^^^^^^ private module
note: the module `server` is defined here
  --> /home/jpm/.cargo/registry/src/
22 | mod server;
   | ^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0603`.
error: could not compile `goo`

To learn more, run the command again with --verbose.
tungstenite = "0.15.0"
$  rustc --version
rustc 1.51.0 (2fd73fabe 2021-03-23)

I'm guessing the example is from an older version of Tungstenite.

The server module was made private by this PR:

You might want to open an issue on that repo asking them to update the example in the README.

Thanks. I opened an issue.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.