Skip to content

Commit

Permalink
move examples/ to demo/
Browse files Browse the repository at this point in the history
  • Loading branch information
tshepang committed May 2, 2020
1 parent 74b8276 commit c1aee6f
Show file tree
Hide file tree
Showing 28 changed files with 100 additions and 131 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ documentation = "https://docs.rs/smol"
keywords = ["async", "await", "future", "io", "networking"]
categories = ["asynchronous", "concurrency", "network-programming"]
readme = "README.md"
autoexamples = false

[features]
# Optional feature for seamless integration with crates depending on tokio.
Expand Down Expand Up @@ -53,5 +52,6 @@ tempfile = "3.1.0"
[workspace]
members = [
".",
"examples",
"demos",
]
default-members = [ "demos" ]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ and is only 1500 lines of code long.

[std]: https://docs.rs/std

Reading the [docs] or looking at the [examples] is a great way to start learning
Reading the [docs] or looking at the [demos] is a great way to start learning
async Rust.

[docs]: https://docs.rs/smol
[examples]: ./examples
[demos]: ./demos

Async I/O is implemented using [epoll] on Linux/Android, [kqueue] on
macOS/iOS/BSD, and [wepoll] on Windows.
Expand All @@ -42,14 +42,14 @@ macOS/iOS/BSD, and [wepoll] on Windows.
* Tasks that support cancelation.
* Userspace timers.

## Examples
## Demos

You need to be in the [examples] directory to run them:
There is a number of demos in the Git repo,
and you can run them with the `--bin` option,
example...

```terminal
$ cd examples
$ ls
$ cargo run --example ctrl-c
$ cargo run --bin ctrl-c
```

## Compatibility
Expand Down
98 changes: 49 additions & 49 deletions examples/Cargo.toml → demos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
[package]
name = "smol-examples"
name = "smol-demos"
version = "0.0.0"
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
edition = "2018"
publish = false

[target.'cfg(windows)'.dev-dependencies]
[target.'cfg(windows)'.dependencies]
uds_windows = "0.1.4"

[target.'cfg(target_os = "linux")'.dev-dependencies]
inotify = { version = "0.8.2", default-features = false }
nix = "0.17.0"
[target.'cfg(target_os = "linux")'.dependencies]
inotify = { version = "0.8", default-features = false }
nix = "0.17"
timerfd = "1.1.1"

[dev-dependencies]
anyhow = "1.0.28"
async-h1 = "1.1.2"
async-native-tls = "0.3.3"
async-std = "1.5.0"
async-tungstenite = { version = "0.4.2", features = ["async-native-tls"] }
base64 = "0.12.0"
ctrlc = "3.1.4"
futures = "0.3.4"
http = "0.2.1"
http-types = "1.2.0"
hyper = { version = "0.13.5", default-features = false, features = ["stream"] }
native-tls = "0.2.4"
num_cpus = "1.13.0"
piper = "0.1.1"
reqwest = "0.10.4"
scraper = "0.11.0"
signal-hook = "0.1.13"
[dependencies]
anyhow = "1"
async-h1 = "1"
async-native-tls = "0.3"
async-std = "1"
async-tungstenite = { version = "0.4", features = ["async-native-tls"] }
base64 = "0.12"
ctrlc = "3"
futures = "0.3"
http = "0.2"
http-types = "1"
hyper = { version = "0.13", default-features = false, features = ["stream"] }
native-tls = "0.2"
num_cpus = "1"
piper = "0.1"
reqwest = "0.10"
scraper = "0.11"
signal-hook = "0.1"
smol = { path = "../", features = ["tokio02"] }
surf = { version = "2.0.0-alpha.1", default-features = false, features = ["h1-client"] }
tempfile = "3.1.0"
tokio = { version = "0.2.18", default-features = false }
tungstenite = "0.10.1"
url = "2.1.1"
surf = { version = "2.0.0-alpha", default-features = false, features = ["h1-client"] }
tempfile = "3"
tokio = { version = "0.2", default-features = false }
tungstenite = "0.10"
url = "2"

[[example]]
[[bin]]
name = "async-h1-client"
path = "async-h1-client.rs"

[[example]]
[[bin]]
name = "async-h1-server"
path = "async-h1-server.rs"

[[example]]
[[bin]]
name = "chat-client"
path = "chat-client.rs"

[[example]]
[[bin]]
name = "chat-server"
path = "chat-server.rs"

[[example]]
[[bin]]
name = "ctrl-c"
path = "ctrl-c.rs"

[[example]]
[[bin]]
name = "hyper-client"
path = "hyper-client.rs"

[[example]]
[[bin]]
name = "hyper-server"
path = "hyper-server.rs"

[[example]]
[[bin]]
name = "linux-inotify"
path = "linux-inotify.rs"

[[example]]
[[bin]]
name = "linux-timerfd"
path = "linux-timerfd.rs"

[[example]]
[[bin]]
name = "other-runtimes"
path = "other-runtimes.rs"

[[example]]
[[bin]]
name = "simple-client"
path = "simple-client.rs"

[[example]]
[[bin]]
name = "simple-server"
path = "simple-server.rs"

[[example]]
[[bin]]
name = "tcp-client"
path = "tcp-client.rs"

[[example]]
[[bin]]
name = "tcp-server"
path = "tcp-server.rs"

[[example]]
[[bin]]
name = "tls-client"
path = "tls-client.rs"

[[example]]
[[bin]]
name = "tls-server"
path = "tls-server.rs"

[[example]]
[[bin]]
name = "unix-signal"
path = "unix-signal.rs"

[[example]]
[[bin]]
name = "web-crawler"
path = "web-crawler.rs"

[[example]]
[[bin]]
name = "websocket-client"
path = "websocket-client.rs"

[[example]]
[[bin]]
name = "websocket-server"
path = "websocket-server.rs"

[[example]]
[[bin]]
name = "windows-uds"
path = "windows-uds.rs"
10 changes: 10 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## smol demos

An example of running any of the demos:

```
$ cargo run --bin ctrl-c
```

If you've got a demo you'd like to see here,
please feel free to open an issue or submit a PR!
4 changes: 1 addition & 3 deletions examples/async-h1-client.rs → demos/async-h1-client.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
//! An HTTP+TLS client based on `async-h1` and `async-native-tls`.
//!
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example async-h1-client
//! cargo run --bin async-h1-client
//! ```

use std::net::TcpStream;
Expand Down
3 changes: 1 addition & 2 deletions examples/async-h1-server.rs → demos/async-h1-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example async-h1-server
//! cargo run --bin async-h1-server
//! ```
//!
//! Open in the browser any of these addresses:
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions examples/chat-client.rs → demos/chat-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
//! First start a server:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example chat-server
//! cargo run --bin chat-server
//! ```
//!
//! Then start clients:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example chat-client
//! cargo run --bin chat-client
//! ```

use std::net::TcpStream;
Expand Down
6 changes: 2 additions & 4 deletions examples/chat-server.rs → demos/chat-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
//! First start a server:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example chat-server
//! cargo run --bin chat-server
//! ```
//!
//! Then start clients:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example chat-client
//! cargo run --bin chat-client
//! ```

use std::collections::HashMap;
Expand Down
3 changes: 1 addition & 2 deletions examples/ctrl-c.rs → demos/ctrl-c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example ctrl-c
//! cargo run --bin ctrl-c
//! ```

use futures::prelude::*;
Expand Down
3 changes: 1 addition & 2 deletions examples/hyper-client.rs → demos/hyper-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example hyper-client
//! cargo run --bin hyper-client
//! ```

use std::io;
Expand Down
3 changes: 1 addition & 2 deletions examples/hyper-server.rs → demos/hyper-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example hyper-server
//! cargo run --bin hyper-server
//! ```
//!
//! Open in the browser any of these addresses:
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions examples/linux-inotify.rs → demos/linux-inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example linux-inotify
//! cargo run --bin linux-inotify
//! ```

#[cfg(target_os = "linux")]
Expand Down
3 changes: 1 addition & 2 deletions examples/linux-timerfd.rs → demos/linux-timerfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example linux-timerfd
//! cargo run --bin linux-timerfd
//! ```

#[cfg(target_os = "linux")]
Expand Down
3 changes: 1 addition & 2 deletions examples/other-runtimes.rs → demos/other-runtimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example other-runtimes
//! cargo run --bin other-runtimes
//! ```

use std::time::{Duration, Instant};
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-client.rs → demos/simple-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Run with:
//!
//! ```
//! cargo run --example simple-client
//! cargo run --bin simple-client
//! ```

use std::net::TcpStream;
Expand Down
3 changes: 1 addition & 2 deletions examples/simple-server.rs → demos/simple-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//! Run with:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example simple-server
//! cargo run --bin simple-server
//! ```
//!
//! Open in the browser any of these addresses:
Expand Down
6 changes: 2 additions & 4 deletions examples/tcp-client.rs → demos/tcp-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
//! First start a server:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example tcp-server
//! cargo run --bin tcp-server
//! ```
//!
//! Then start a client:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example tcp-client
//! cargo run --bin tcp-client
//! ```

use std::net::TcpStream;
Expand Down

0 comments on commit c1aee6f

Please sign in to comment.