mirror of https://github.com/stjepang/smol
move examples/ to demo/
This commit is contained in:
parent
74b8276e99
commit
78090b4f12
|
@ -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.
|
||||
|
@ -53,5 +52,6 @@ tempfile = "3.1.0"
|
|||
[workspace]
|
||||
members = [
|
||||
".",
|
||||
"examples",
|
||||
"demos",
|
||||
]
|
||||
default-members = [ "demos" ]
|
||||
|
|
14
README.md
14
README.md
|
@ -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.
|
||||
|
@ -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
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
[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"
|
||||
async-h1 = "1.1.2"
|
||||
async-native-tls = "0.3.3"
|
||||
|
@ -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"
|
|
@ -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!
|
|
@ -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;
|
|
@ -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:
|
|
@ -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;
|
|
@ -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;
|
|
@ -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::*;
|
|
@ -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;
|
|
@ -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:
|
|
@ -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")]
|
|
@ -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")]
|
|
@ -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};
|
|
@ -3,7 +3,7 @@
|
|||
//! Run with:
|
||||
//!
|
||||
//! ```
|
||||
//! cargo run --example simple-client
|
||||
//! cargo run --bin simple-client
|
||||
//! ```
|
||||
|
||||
use std::net::TcpStream;
|
|
@ -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:
|
|
@ -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;
|
|
@ -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};
|
|
@ -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;
|
|
@ -3,15 +3,13 @@
|
|||
//! First start a server:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example tls-server
|
||||
//! cargo run --bim 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::{TcpListener, TcpStream};
|
|
@ -3,8 +3,7 @@
|
|||
//! Run with:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example unix-signal
|
||||
//! cargo run --bin unix-signal
|
||||
//! ```
|
||||
|
||||
#[cfg(unix)]
|
|
@ -3,8 +3,7 @@
|
|||
//! Run with:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example web-crawler
|
||||
//! cargo run --bin web-crawler
|
||||
//! ```
|
||||
|
||||
use std::collections::{HashSet, VecDeque};
|
|
@ -3,15 +3,13 @@
|
|||
//! First start a server:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example websocket-server
|
||||
//! cargo run --bin websocket-server
|
||||
//! ```
|
||||
//!
|
||||
//! Then start a client:
|
||||
//! Then start clients:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example websocket-client
|
||||
//! cargo run --bin websocket-client
|
||||
//! ```
|
||||
|
||||
use std::net::TcpStream;
|
|
@ -3,15 +3,13 @@
|
|||
//! First start a server:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example websocket-server
|
||||
//! cargo run --bin websocket-server
|
||||
//! ```
|
||||
//!
|
||||
//! Then start a client:
|
||||
//! Then start clients:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example websocket-client
|
||||
//! cargo run --bin websocket-client
|
||||
//! ```
|
||||
|
||||
use std::net::{TcpListener, TcpStream};
|
|
@ -3,8 +3,7 @@
|
|||
//! Run with:
|
||||
//!
|
||||
//! ```
|
||||
//! cd examples # make sure to be in this directory
|
||||
//! cargo run --example windows-uds
|
||||
//! cargo run --bin windows-uds
|
||||
//! ```
|
||||
|
||||
#[cfg(windows)]
|
|
@ -1,12 +0,0 @@
|
|||
## smol examples
|
||||
|
||||
You need to be in this directory to run examples:
|
||||
|
||||
```
|
||||
$ cd examples
|
||||
$ ls
|
||||
$ cargo run --example ctrl-c
|
||||
```
|
||||
|
||||
If you've got an example you'd like to see here,
|
||||
please feel free to open an issue or submit a PR!
|
Loading…
Reference in New Issue