Skip to content

Commit 8e2d186

Browse files
committed
edition 2018
1 parent 8d70eff commit 8e2d186

36 files changed

+190
-220
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ name = "ws"
1414
readme = "README.md"
1515
repository = "https://github.com/housleyjk/ws-rs"
1616
version = "0.9.1"
17+
edition = "2018"
1718

1819
[dependencies]
1920
byteorder = "1.2.1"
2021
bytes = "0.4.6"
2122
httparse = "1.2.4"
22-
log = "0.4.1"
23+
log = "0.4.8"
2324
mio = "0.6.14"
2425
mio-extras = "2.0"
2526
rand = "0.7"

examples/autobahn-client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// WebSocket client used for testing against the Autobahn Test Suite
2-
extern crate ws;
1+
//! WebSocket client used for testing against the Autobahn Test Suite
32
43
use std::cell::Cell;
54
use std::rc::Rc;

examples/autobahn-server.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
extern crate env_logger;
2-
/// WebSocket server used for testing against the Autobahn Test Suite. This is basically the server
3-
/// example without printing output or comments.
4-
extern crate ws;
1+
//! WebSocket server used for testing against the Autobahn Test Suite. This is basically the server
2+
//! example without printing output or comments.
53
4+
use env_logger;
5+
use ws;
66
#[cfg(feature = "permessage-deflate")]
77
use ws::deflate::DeflateHandler;
88

examples/bench-server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// WebSocket server used for testing the bench example.
2-
extern crate ws;
1+
//! WebSocket server used for testing the bench example.
32
43
use ws::{Builder, Sender, Settings};
54

examples/bench.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
extern crate env_logger;
2-
extern crate time;
3-
extern crate url;
4-
/// A simple, but immature, benchmark client for destroying other WebSocket frameworks and proving
5-
/// WS-RS's performance excellence. ;)
6-
/// Make sure you allow for enough connections in your OS (e.g. ulimit -Sn 10000).
7-
extern crate ws;
1+
//! A simple, but immature, benchmark client for destroying other WebSocket frameworks and proving
2+
//! WS-RS's performance excellence. ;)
3+
//! Make sure you allow for enough connections in your OS (e.g. ulimit -Sn 10000).
84
95
// Try this against node for some fun
106

117
// TODO: Separate this example into a separate lib
128
// TODO: num threads, num connections per thread, num concurrent connections per thread, num
139
// messages per connection, length of message, text or binary
1410

11+
use env_logger;
12+
use time;
13+
use url;
1514
use ws::{Builder, CloseCode, Handler, Handshake, Message, Result, Sender, Settings};
1615

1716
const CONNECTIONS: usize = 10_000; // simultaneous

examples/channel.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
extern crate env_logger;
2-
/// An example of using channels to transfer data between three parts of some system.
3-
///
4-
/// A WebSocket server echoes data back to a client and tees that data to a logging system.
5-
/// A WebSocket client sends some data do the server.
6-
/// A worker thread stores data as a log and sends that data back to the main program when the
7-
/// WebSocket server has finished receiving data.
8-
///
9-
/// This example demonstrates how to use threads, channels, and WebSocket handlers to create a
10-
/// complex system from simple, composable parts.
11-
extern crate ws;
1+
//! An example of using channels to transfer data between three parts of some system.
2+
//!
3+
//! A WebSocket server echoes data back to a client and tees that data to a logging system.
4+
//! A WebSocket client sends some data do the server.
5+
//! A worker thread stores data as a log and sends that data back to the main program when the
6+
//! WebSocket server has finished receiving data.
7+
//!
8+
//! This example demonstrates how to use threads, channels, and WebSocket handlers to create a
9+
//! complex system from simple, composable parts.
1210
1311
use std::sync::mpsc::channel;
1412
use std::sync::mpsc::Sender as ThreadOut;
1513
use std::thread;
1614
use std::thread::sleep;
1715
use std::time::Duration;
1816

17+
use env_logger;
1918
use ws::{connect, listen, CloseCode, Handler, Handshake, Message, Result, Sender};
2019

2120
fn main() {

examples/cli.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
extern crate clap;
2-
extern crate env_logger;
3-
extern crate term;
4-
/// Run this cli like this:
5-
/// cargo run --example server
6-
/// cargo run --example cli -- ws://127.0.0.1:3012
7-
extern crate ws;
1+
//! Run this cli like this:
2+
//! cargo run --example server
3+
//! cargo run --example cli -- ws://127.0.0.1:3012
84
95
use std::io;
106
use std::io::prelude::*;
@@ -13,6 +9,8 @@ use std::sync::mpsc::Sender as TSender;
139
use std::thread;
1410

1511
use clap::{App, Arg};
12+
use env_logger;
13+
use term;
1614
use ws::{connect, CloseCode, Error, ErrorKind, Handler, Handshake, Message, Result, Sender};
1715

1816
fn main() {

examples/client.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
extern crate env_logger;
2-
/// Simple WebSocket client with error handling. It is not necessary to setup logging, but doing
3-
/// so will allow you to see more details about the connection by using the RUST_LOG env variable.
4-
extern crate ws;
1+
//! Simple WebSocket client with error handling. It is not necessary to setup logging, but doing
2+
//! so will allow you to see more details about the connection by using the RUST_LOG env variable.
53
4+
use env_logger;
65
use ws::{connect, CloseCode};
76

87
fn main() {

examples/external_shutdown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
extern crate ws;
2-
31
use std::sync::mpsc::channel;
42
use std::thread;
53
use std::time::Duration;
64

5+
use ws;
6+
77
fn main() {
88
let (tx, rx) = channel();
99

examples/html_chat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// An example of a chat web application server
2-
extern crate ws;
1+
//! An example of a chat web application server
2+
33
use ws::{listen, Handler, Message, Request, Response, Result, Sender};
44

55
// This can be read from a file

0 commit comments

Comments
 (0)