跪拜 Guibai
← Back to the summary

Seven Rust Crates That Replace Homegrown Infrastructure

From Tokio and Serde to GPUI, Ratatui, Polars, Tantivy, and Wasmtime, the Rust ecosystem continues to provide tools for different engineering problems.

Because I have recently been developing tools in Rust and encountered some excellent crates, I want to share them.

I've sorted out what these crates can do, how mature they are, what architecture they adopt, and which ones are worth adopting in future projects.

The most interesting thing about the Rust ecosystem is not that almost every problem has a corresponding crate, but that some projects already allow small teams to take on work that previously required large teams.

Command-line tools can have genuinely usable terminal interfaces; desktop applications can render GPU-accelerated UI themselves; local processes can query columnar data, embed full-text search, and run third-party extensions through a WebAssembly boundary.

These libraries solve different problems, and through these crates you can see where Rust is building advantages: infrastructure that runs fast, is portable, has predictable behavior, and is close enough to the system for teams to control its behavior.

I'll temporarily divide them into three groups:

This distinction is important.

Base libraries change how most code is written; frameworks change how applications are organized; embeddable engines bring a significant capability to a program while also placing the responsibility for operating it correctly on you.

Tokio: A Powerful Async Runtime

tokio.png

Wait, why is Tokio a runtime?

You might at first find it strange: doesn't Rust compile programs into machine code? Why do we need a runtime?

Here, a "runtime" refers to a set of infrastructure that schedules async tasks and handles events during program execution. It is embedded in the program as a library, providing execution support for compiled Rust async code. It runs together with the program and does not require launching a separate service.

Rust's async/await syntax does not handle async task execution. Calling an async fn returns a Future. Think of it as an async computation that records its execution progress: what to do next, and where to resume after a wait, are all stored in it.

But the problem is that it doesn't start executing just because it is created.

To move it forward, an executor must call its poll method. If the result is not ready, it returns Pending and yields the execution opportunity; when it can continue, it notifies the executor through a wake mechanism to schedule it. .await lets us express this process in a way close to sequential code, but it does not automatically create threads or launch an executor for us.

So who executes the tasks?

While waiting for network data, who receives the OS's readiness notification? While waiting for a timer, who decides when the time is up?

Tokio takes over this work: the scheduler arranges task execution, the I/O driver hands network events to the tasks waiting on them, and timers handle time-based waits.

For example, a task is waiting for data on a socket. When no data is available, it can suspend and let the thread execute other tasks. When the OS notifies that the socket is readable, Tokio wakes the corresponding task, allowing it to continue from where it left off. This way, waiting on network doesn't tie up a thread.

The common #[tokio::main] is related to this: it generates a normal synchronous entry point, creates a Tokio runtime inside, and then drives the async entry point. It looks like just adding a marker, but behind the scenes it sets up the execution environment.

So Tokio is called a runtime because it handles the work of advancing async tasks. Rust provides the syntax and interfaces for expressing async computation, and Tokio provides the concrete facilities needed to execute these tasks. Tokio is one option; Rust's async syntax is not bound to it.

More than just a runtime

That sounds abstract.

Let's think about a service handling thousands of connections simultaneously: most of the time, it's waiting on databases, sockets, APIs, files, or message queues. If each request occupies an OS thread waiting, overhead quickly grows. Tokio lets tasks yield execution while waiting, so underlying threads can handle other tasks.

Its multithreaded runtime uses work-stealing scheduling. In simple terms, idle worker threads can take pending tasks from other threads' queues, but cannot forcibly take over running blocking code. This is one reason Tokio is widely used for web services, proxies, development tools, distributed systems, and network-intensive background tasks.

Choosing Tokio means choosing a model: long-running waits should be async, and CPU-intensive work must be deliberately separated. Thus, writing Tokio applications still requires attention to:

Tokio is mature enough that you usually don't think about "can it do it?" but rather "does this workload actually benefit from async I/O?"

A small command-line tool that only reads a file and prints a result probably doesn't need Tokio. Services that coordinate HTTP requests, database calls, data streams, timers, and background tasks are well suited for Tokio, also depending on which runtime the libraries you use rely on.

Serde: Foundational Capability

serde.png

Serde is easy to underestimate because its most common usage is only a few lines:

#[derive(Serialize, Deserialize)]
struct Config {
    port: u16,
    debug: bool,
}

Separating your application's data types from the formats used to transfer and store that data is its real value.

The same Rust struct, as long as field types and formats are compatible, can be JSON in an API, TOML in a config file, MessagePack for compact transport, YAML for manual maintenance, or a binary format required by a protocol. Your types implement the data model once, and the specific format is handled by the corresponding crate.

This separation has kept Serde useful for years, because most applications have many boundaries:

Serde helps you handle these boundaries, but it doesn't design the contracts for you.

That means there's still plenty for you as a developer to do; it's not enough to derive Deserialize on all internal structs.

Deliberately designing serialized types is critical:

Serde is a solid choice for serialization capabilities. It's not a trendy framework, but a foundational layer of the Rust ecosystem. Understanding how it handles ownership, defaults, enum representation, and errors is knowledge you'll use in nearly every Rust project.

Ratatui: Terminal as UI

ratatui.gif

Ratatui is a terminal UI library, but saying only that doesn't explain why it's useful.

Infrastructure tools, database clients, log browsers, deployment panels, observability consoles, Git tools, and development workflows naturally belong in the terminal.

But plain terminal output has its limits. Once users need filtering, navigation, live updates, split views, shortcuts, or persistent state, plain line-by-line output becomes hard to use.

Ratatui provides a rendering model suitable for the terminal for Rust programs.

Instead of continuously printing text and hoping the screen remains clear, an application draws a frame of interface: divides areas, places components, tables, charts, lists, status bars, and text. The backend handles cursor movement, drawing, colors, and other terminal details; the application still needs to respond to size changes and re-layout.

This clarifies responsibilities:

It doesn't force a large architecture on you. That's an advantage, but it means you have to build the architecture yourself. A usable Ratatui program usually needs:

The last point isn't glamorous but is important. A terminal app that exits and leaves a hidden cursor, abnormal line wrapping, or raw mode input will feel unreliable no matter how nice the interface was seconds earlier.

Ratatui is mature enough to build serious terminal interaction tools.

If users are already in the terminal and the tool genuinely needs fast keyboard interaction, I'll use it. If you just want to make a simple CLI look fancy, there's no need. Terminal UI brings extra work in state management, testing, event coordination, and accessibility, and that complexity needs enough payoff to justify it.

I believe in the era of agents, Ratatui will become very popular.

If you want to develop a good-looking CLI tool, Ratatui is a great choice, and I would consider it first.

GPUI: Interesting Native Desktop Development

gpui.jpg

Among the crates mentioned here, GPUI is younger and not yet settled.

Yes, many developers will definitely like this new thing! Me too.

It was originally built for the Zed editor as a GPU-accelerated Rust UI framework. Its architecture is hybrid: it combines immediate-mode rendering ideas with retained state. It draws the interface itself, doesn't embed a browser runtime, and doesn't rely entirely on platform-native components.

This gives GPUI its own characteristics. It targets applications that value:

GPUI explicitly hasn't reached 1.0 and is tightly coupled to Zed's development.

If your team plans to build on it, you can't ignore that.

I certainly wouldn't describe GPUI as the universal answer for Rust desktop development. Its API, ecosystem, documentation, packaging, and component library are still changing.

If a company intends to bet a multi-year core product on it, it should first verify accessibility, OS support, input behavior, internationalization, update mechanisms, and the team's familiarity with it. Though Vibe Coding can assist development, the gap in ecosystem maturity still requires serious evaluation.

However, that doesn't mean it's an edge project. Quite the opposite; I think it's worth studying carefully.

GPU rendering is only one reason I'm drawn to it. There's also: a Rust application can control its own rendering pipeline, state model, and performance without first becoming a browser app.

Yes, I dislike that most cross-platform tools nowadays require bundling a browser engine.

For development tools, editors, creative software, data browsers, and native productivity tools, GPUI can be a priority.

My advice: research GPUI now; when its strengths align with product requirements, use it for prototypes.

Polars: More Than a Faster DataFrame

polars.png

Polars is often described as a DataFrame library. That's true, but it doesn't capture the architectural change it brings to Rust applications.

Think of it this way: Polars is an analytical query engine you can embed in your application process.

It handles columnar data and supports immediate execution when you need results right away. More importantly, it also supports lazy execution: the application builds a query plan first and executes it later. This gives the engine room to optimize before actually doing the work.

Lazy queries can push column selection and filtering as close to the data source as possible, avoiding loading all columns and filtering row by row before picking the needed fields. The query planner can skip unnecessary operations, eliminate duplicate work, and choose more efficient execution paths.

Polars changed how I think about data processing tools.

Traditional data processing scripts are often a sequence of steps:

With Polars, you can think differently: first ask yourself, "What result do I ultimately need?" Then let the engine decide how to get it.

Polars is especially suited for:

However, it doesn't replace all data systems.

Polars can join tables, but that doesn't make it a transactional database. It doesn't handle multi-user concurrency, durable business processes, access control, distributed coordination, or long-running data warehouse management. It excels at transformation and analysis, but it can't replace every system that stores data.

The lazy API may have a learning curve: build queries first; check execution plans when performance matters; collect data only at the boundary where the application actually needs results.

Here, Polars' value goes beyond a "convenient library": it provides a more appropriate way to describe data processing work.

Tantivy: Bringing Full-Text Search Back Inside Applications

tantivy.png

Tantivy is a full-text search engine library written in Rust. The simplest analogy is Lucene, but it can be embedded directly into Rust applications.

That's attractive.

We often treat search as separate infrastructure: services, clusters, HTTP APIs, index synchronization, credentials, monitoring dashboards, backups, and the operational burden that comes with them. Large systems may indeed need all this, but many applications don't need a distributed search platform; they just need good local search.

If an application needs to index documents, tokenize text, score results, filter by fields, produce highlighted snippets, and doesn't want to send every query to an external service, Tantivy fits.

For example:

Of course, like almost all retrieval frameworks, Tantivy gives you the power of a search engine, but it doesn't bring an operations team along.

The application still must handle:

If search belongs to an application and should stay close to its data, Tantivy is a good choice. If you truly need a multi-user search platform, global replication, large-scale operational tooling, and a managed search service shared by multiple teams, it's not suited.

Wasmtime: Making Plugins a Runtime Design Problem

wasmtime.png

Wasmtime is a WebAssembly runtime from the Bytecode Alliance. It compiles and executes WebAssembly modules, supports WASI, and supports the WebAssembly Component Model.

Its appeal comes from the growing need for extensibility in applications. User-defined automation, plugins, policy scripts, customer logic, data transforms, AI agent tools, and third-party integrations all fall into this category.

The traditional approach is to load native code or open a high-privilege scripting environment. But that can bring serious security problems (whenever permissions are mentioned, security comes to mind).

Wasmtime offers another model: code runs inside a WebAssembly boundary, and the host decides which capabilities are granted to it.

More important than the word "sandbox" is the specific permission boundary. A plugin doesn't become automatically safe just because it uses WebAssembly.

The host still must decide:

Wasmtime provides the mechanisms to build these boundaries, but it doesn't design policies for you.

In plugin architectures, Wasmtime is worth attention because the host can explicitly grant capabilities to a plugin instead of trusting code loaded into the process.

I would choose Wasmtime when executing extension code is a genuine product requirement, especially when that code shouldn't inherit unrestricted access to the host process.

If you're just replacing a trait with something more complex, there's no need. For example, when all extensions are trusted, compiled together, and versioned with the same codebase, organizing extensions with native Rust traits is still the more appropriate approach—it's simpler and fully meets your needs.

"Useful" and "Should Use" Are Two Different Things

Each of the libraries above is useful, but that doesn't mean every project should use them.

Before using one, ask: does this crate eliminate a system that you would otherwise have to design, implement, test, and operate yourself?

Here are some selection suggestions:

A common mistake is pulling in a crate because it looks impressive in the dependency graph. Many developers make this mistake.

A better and correct reason is that it can replace a certain type of self-built infrastructure.

Tokio replaces a hand-written async runtime; Serde replaces scattered conversion code for different formats; Ratatui replaces a pile of terminal escape sequences; Polars replaces fragile line-by-line data scripts; Tantivy replaces a simple search engine strung together with map structures; Wasmtime replaces "load someone's code into our process and pray it works."

That's where these projects belong.

A Few Thoughts

For most Rust developers, Tokio and Serde belong to a first layer of knowledge. Even if a project doesn't depend on them directly, understanding their models helps in reading modern Rust projects.

Ratatui belongs to a second layer. Not every application needs it, but building a small interactive tool teaches you about state, event loops, rendering, and terminal usability.

Polars, Tantivy, and Wasmtime are libraries I would study as architectural options. Each can change the shape of a product:

I'm watching GPUI most closely. It tries to make high-performance native desktop software feel natural in Rust. It's not yet a conservative choice, but not every project worth studying is conservative.

If you've read my previous article, you'll know I've already used GPUI to build an Android development tool.

The Rust ecosystem is becoming more interesting. Its libraries are no longer limited to small utilities and low-level primitives. They are beginning to offer more complete engineering solutions: how to schedule work, pass data, render interfaces, analyze records, search text, and execute untrusted extensions.

The future certainly has a place for Rust!