poll 的最小 non-blocking IO 库. 作者设计的初衷是为了解决 peer-to-peer networking 中大量连接的管理问题. 作者不需要一个拥有大量依赖和复杂特性的 async/await runtime, 仅仅需要一个 non-bloking IO 库.mio 更小 ( mio 的 10% 大小)io::Read, io::Write)libc"runtime"cargo build --example sync
deno run --unstable --allow-plugin --allow-read --allow-write examples/sync.ts
cargo build --example async
deno run --unstable --allow-plugin --allow-read --allow-write examples/async.ts
ResponseBuilder 更加方便的构建 Response.app.at("/").get(|_| async {
let res = Response::builder(203)
.body(json!({ "hello": "cats!" }))
.header("X-Nori", "me-ow")
.header("X-Chashu", "meewwww");
Ok(res)
})
Server::listen 通过引入新的 Listener trait, 可以提供各种 transport, 默认内置对了 TcpStream,SocketAddr和UnixStream的实现.let mut app = tide::new();
let listener = TlsListener::build()
.addrs("localhost:4433")
.cert(cert)
.key(key);
app.listen(listener).await?;
tide::listener::ConcurrentListener,用于处理多个 transports,例如开发者想同时处理 IPV4 和 IPV6.let mut app = tide::new();
let mut listener = listener::ConcurrentListener::new();
listener.add((Ipv4Addr::new(127, 0, 0, 1), 8000));
listener.add((Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8000));
app.listen(listener).await?;
State现在必须要 clone.async-trait.原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。