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

move examples/ to demo/ #75

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 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,5 @@ tempfile = "3.1.0"
[workspace]
members = [
".",
"examples",
"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
54 changes: 25 additions & 29 deletions examples/Cargo.toml → demos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[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]
[target.'cfg(target_os = "linux")'.dependencies]
inotify = { version = "0.8.2", default-features = false }
nix = "0.17.0"
timerfd = "1.1.1"

[dev-dependencies]
[dependencies]
anyhow = "1.0.28"
tshepang marked this conversation as resolved.
Show resolved Hide resolved
async-h1 = "1.1.2"
async-native-tls = "0.3.3"
async-native-tls = { version = "0.3.3", features = ["vendored"] }
async-std = "1.5.0"
async-tungstenite = { version = "0.4.2", features = ["async-native-tls"] }
base64 = "0.12.0"
Expand All @@ -38,86 +38,82 @@ tokio = { version = "0.2.18", default-features = false }
tungstenite = "0.10.1"
url = "2.1.1"

[[example]]
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
8 changes: 3 additions & 5 deletions examples/tcp-server.rs → demos/tcp-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 tcp-server
//! cargo run --bin tcp-server
//! ```
//!
//! Then start a client:
//! Then start clients:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example tcp-client
//! cargo run --bin tcp-client
//! ```

use std::net::{TcpListener, TcpStream};
Expand Down
6 changes: 2 additions & 4 deletions examples/tls-client.rs → demos/tls-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 tls-server
//! cargo run --bin tls-server
//! ```
//!
//! Then start a client:
//!
//! ```
//! cd examples # make sure to be in this directory
//! cargo run --example tls-client
//! cargo run --bin tls-client
//! ```

use std::net::TcpStream;
Expand Down
Loading