Crate of the Week

I’ll do my part, since suggestions have been scarce:

In light of the release of Rocket 0.5 I thought that it must be worth a suggestion.

Rocket aims to be fast, easy, and flexible while offering guaranteed safety and security where it can. Importantly, Rocket also aims to be fun , and it accomplishes this by ensuring that you write as little code as needed to accomplish your task.

5 Likes

Shutdown management for graceful shutdown of tokio applications. Guard creating and usage is lock-free and the crate only locks when:

  • the shutdown signal was not yet given and you wait with a (weak or strong) guard on whether or not it was in fact cancelled;
  • the check of whether or not the app can shut down typically is locked until the shutdown signal was received and all (strong) guards were dropped.

It's the kind of thng that you can also do alone, but why would you want it, and if so, better make sure it's done correctly.

In order to avoid you having to figure out how to do it yourself correctly, it is much easier to use this crate instead.

3 Likes

As promised during RustLab in Florence, here is my crate proposal: https://crates.io/crates/symbols

Symbols is an utility, not a standalone crate, that allows people quickly create proc-macros to solidify database tables into enums, e.g. allowing compile time foreign keys checks

2 Likes

strum was CotW 2017-06-27

https://crates.io/crates/const_format has some nice helpers.

https://crates.io/crates/buildstructor - "builders" for arbitrary methods with many arguments, not just constructors.

2 Likes

Self suggestion: GitHub - SUPERCILEX/io-adapters: Adapters to convert between different writable APIs.

It lets you write code like this:

let mut output1 = String::new();
let mut output2 = [0u8; 13]; // Or io::stdout() for example

my_common_writer(&mut output1).unwrap();
my_common_writer(&mut output2.as_mut_slice().write_adapter()).unwrap();

fn my_common_writer(output: &mut impl fmt::Write) -> fmt::Result {
    write!(output, "Hello, World!")
}

Self-nomination: constcat. A tiny crate that provides concat! macros that also support const variables and expressions.

  • concat!: like std::concat! but it also supports const variables and expressions.
  • concat_bytes!: like std::concat_bytes! but it also supports const variables and expressions.
  • concat_slices!: concatenate const &[T] variables and expressions.
3 Likes

Kondo: clean up build artifacts in rust and other types of projects.

1 Like

Self-nomination: sqids. Helps you generate short unique ids from numbers (useful in url shortening, etc).

Example:

let sqids = Sqids::default();
let id = sqids.encode(&[1, 2, 3])?; // "86Rf07"
let numbers = sqids.decode(&id); // [1, 2, 3]
1 Like

I would like to suggest rouille, a small synchronous web framework, built on tiny-http. It is easier to get started with than its asynchronous alternatives like axum and it has become my default for small size web projects.
I would love to see it featured in Crate of the Week as this project seems to be overlooked often in web framework land, undeservedly so!

2 Likes

I would like to nominate fast_pool
a fast async pool based on channel。
You can think of it as a substitute for connection pools such as deadpool and mobc

  • support get(),get_timeout(),state() methods
  • support atomic max_open(Resize freely)
  • Fewer code, clearer logic, less prone to bugs
  • based on flume channel

way fast_pool?

  • fast get() method performance
//windows:
//---- bench_pool stdout ----
//use Time: 4.0313ms ,each:40 ns/op
//use QPS: 24749412 QPS/s
//macos:
//---- bench_pool stdout ----
// use Time: 6.373708ms ,each:63 ns/op
// use QPS: 15683710 QPS/s

Self-nomination: named-sem. This is a wrapper for named semaphore in Linux & Windows.

Example:

let mut semaphore = NamedSemaphore::create("/my-semaphore", 3)?;

semaphore.wait_then_post(|| {
    do_heavy_things();
})?;

I would like to recommend ractor a very friendly and easy to use actor framework that I have been very happy with when working on my latest project :slight_smile:

4 Likes

Self nomination: apistos , an OpenAPI documentation tool exposing OAS 3.0 models as well as an actix-web wrapper similar to paperclip.

8 Likes

Hey! long time reader, first time writer (creating an account wasn't that bad)
For next week, I'd like to self nominate GitHub - astrale-sharp/typstfmt
It's a formatter for the typst language, It's far from perfect yet but It's going through it's second iteration atm.

5 Likes

Hi!

Self-nomination: commit-emoji a git post-commit hook to add pretty emoji to your otherwise dull conventional commits (and a couple qol improvements like replacing predefined commit messages with longer versions, e.g. "bumpdeps" -> "fix: :arrow_double_up: Update dependencies")

Self nominating page-turner as, probably, the first announced library which supports stabilized async in traits.

page-turner is a utility to work with paginated APIs. You specify how to query a single page and then page-turner provides async streams that query all pages automatically and allow to process data as if pagination doesn't exist.

Hi!

Self nominating Apache Iceberg Rust, the native rust implementation of Apache Iceberg.

iceberg-rust helps to bring apache iceberg to rust, and is designed to be fast, jvm free.

8 Likes