A Good Rust Web Stack - Summary

Summary

The speaker, Tris, introduces a video focused on creating a fast, technical web service using Rust, a programming language known for its performance and safety. He introduces a stack of tools and libraries he uses in most of his Rust projects, which he refers to as the "stack". The stack is not the best or most featured, but it showcases what Rust is great at and focuses on correctness.

The speaker mentions several tools and libraries, including "air", a fork of the "anyhow" crate that allows for customizable error reports; "bacon", a tool that runs clippy, a linting tool for Rust, by pressing "C" after launch; and "tracing", a native logging library for Tokyo web servers.

He also discusses "SQL X", a Rust library that allows the same struct to build the state of your program and validate your SQL queries at compile time. He mentions that he loves this library so much that he has a deep dive video about it.

Tris then goes into detail about the "poem" web framework, which he discovered in 2022 and fell in love with. He talks about its first-party REST API plugin, "poem open API", and how it allows for the creation of simple plain text endpoints with minimal boilerplate. He also mentions the "oai" macro, which converts simple functions into open API handlers.

Tris discusses how the "poem" framework allows for the binding of your database and REST interface together at compile time, providing extreme confidence in data integrity. He explains that if you define your API in Rust structs, the compiler will stop you from breaking the contract with your API clients.

He then proceeds to demonstrate how to use these tools and libraries to create a simple to-do API with a database. He uses SQL X's compile-time verified query to pull data from the database and mentions that if the query is incorrect, SQL X will catch the error at compile time.

Finally, he discusses how to set up the "poem" router, which is straightforward and easy to understand. He explains how the router is used to define the routes for the API, and how the "data" method is used to attach state to the endpoint.

Tris ends the video by expressing his belief that working with Rust's type system will reward you with fast, production-grade code. He also invites viewers to support his channel on Patreon for early access to videos and one-to-one mentoring.

Facts

1. The speaker, Tris, is making web service recommendations by mixing some of his favorite Rust crates into a stack that he uses across most of his Rust projects.

2. The stack Tris is discussing is not the best or most fully featured; it's his favorite. It showcases what Rust is great at and focuses on correctness.

3. The speaker mentions that the script and images in the video are part of a markdown document available on GitHub under a public domain license.

4. The speaker is not going to discuss building tools with web.pi, a Python framework.

5. Tris uses several crates in nearly all his Rust projects, including "air" (pronounced like the book Jain air), "bacon" (always open running clippy), and "tracing" (Tokyo native logging).

6. Tris discusses the use of SQL X, a crate that allows the same struct to build the state of your program and validate your SQL queries at compile time.

7. Tris found Poem, a Rust web framework, in 2022. He fell in love with Poem and specifically their first-party REST API plugin, Poem Open API.

8. Tris builds a simple plain text endpoint mounted at slash hello, with a top-level struct that hangs Handler functions off the open API macro.

9. Tris emphasizes the importance of defining your API in Rust structs. The compiler will stop you from breaking the contract with your API clients.

10. Tris concludes by saying that Rust code is your templating system, functions and modules are your unit of abstraction, and it's all type-safe.

11. Tris invites viewers to support his channel on Patreon for early ad free and tracking free videos, VIP Discord access, or one-to-one mentoring.

12. Transcripts and companion markdown source code for the video are available on GitHub.