0
点赞
收藏
分享

微信扫一扫

【Rust日报】2020-07-20 boids算法, tide, popol, Calcite

yongxinz 2022-06-27 阅读 26

文章类

Rust 模块系统的超清晰解释

Rust 的模块系统可能对于新人来说有些困惑,这篇文章通过几个循序渐进的小例子,让你快速且清晰的对 Rust 模块系统有一个基本的认识.

​​http://www.sheshbabu.com/posts/rust-module-system/​​

使用 Rust 实现 boids 算法 (Game)

这是 Rust 来实现经典的 Boids 算法的一系列文章的 Part1. 做游戏或者对该算法感兴趣,并且希望来学习 Rust 的同学也可以参考一下.有比较详细的过程和代码.

​​https://blog.bitsacm.in/a-fistful-of-boids/​​关于Boids: http://www.red3d.com/cwr/boids/

Rate Limiting in Rust Using Redis

使用 Redis 来实现 Rate limit.

​​https://outcrawl.com/rust-redis-rate-limiting​​

Crates

Native-Windows-GUI 发布 1.0 stable 版本

Native-Windows-Gui (NWG) 一个基于 win32 的 rust 库. 号称在 Windows 平台下开发 native GUID 最好且唯一的 Rust 库.

此外,还有一个发布一个姐妹库 Native-Windows-Derive, 可以让开发者使用 Macro 来快速构建 GUI.

​​https://github.com/gabdube/native-windows-gui​​以及 https://gabdube.github.io/native-windows-gui/native-windows-docs/index.html

popol 更小的基于 poll 的 non-blocking IO 库

一个基于 poll 的最小 non-blocking IO 库. 作者设计的初衷是为了解决 peer-to-peer networking 中大量连接的管理问题. 作者不需要一个拥有大量依赖和复杂特性的 async/await runtime, 仅仅需要一个 non-bloking IO 库.

  • mio 更小 ( mio 的 10% 大小)
  • 而且所有的 Rust 标准库可以正常工作(例如 io::Read, io::Write)
  • 仅依赖libc
  • 没有 "runtime"

​​https://github.com/cloudhead/popol​​

Calcite 用于创建deno plugins的库

​​https://github.com/Srinivasa314/calcite/blob/master/docs/part1.md​​

例子:

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

​​https://github.com/Srinivasa314/calcite​​

tide 发布 v0.12.0

主要变动:

  1. 新增 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)
    })
  2. Server::listen 通过引入新的 Listener trait, 可以提供各种 transport, 默认内置对了 TcpStream,SocketAddrUnixStream的实现.
    ​​let mut app = tide::new();
    let listener = TlsListener::build()
    .addrs("localhost:4433")
    .cert(cert)
    .key(key);
    app.listen(listener).await?;
  3. 此外,同时发布的还有 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?;
  4. State现在必须要 clone.
  5. 迁移所有的 trait 使用 async-trait.
  6. middleware 中错误处理的改进.

​​https://github.com/http-rs/tide/releases/tag/v0.12.0​​


举报

相关推荐

0 条评论