Top 40 Rust Libraries every Rustacean Should Know 🦀
Most commonly used rust crates or libraries beginners should know about.
Rust is a blazingly fast and memory-efficient programming language empowering everyone to build reliable and efficient software. Below is a list of 40 crates ( synonymous with a 'library' or 'package' in other languages) every rust developer should be acquainted with.
1. actix_web, rocket, tide
actix_web - A powerful, pragmatic, and extremely fast web framework for Rust. It is similar to Express in Nodejs - slightly opinionated but no strict configuration or ORM.
rocket - Rocket provides primitives to build web servers and applications with Rust: Rocket provides routing, pre-processing of requests, and post-processing of responses; the rest is up to you. Your application code instructs Rocket on what to pre-process and post-process and fills the gaps between pre-processing and post-processing. Rocket is similar to Python's Django.
tide Tide is a minimal and pragmatic Rust web application framework built for rapid development. It comes with a robust set of features that make building async web applications and APIs easier and more fun.
2. async_std
async_std is the async version of the Rust standard library. It is a set of shared abstractions for the broader Rust ecosystem. It offers std types, like Future and Stream, library-defined operations on language primitives, standard macros, I/O, and multithreading, among many other things.
3. async_stream
async_stream is async streams using async & await notation. Provides two macros, stream! and try_stream!, allowing the caller to define asynchronous streams of elements. These are implemented using async & await notation.
4. bignum
bignum is a library for performing arbitrary-precision arithmetic.
5. bytemuck
bytemuck is a crate for mucking around with piles of bytes. This crate gives small utilities for casting between plain data types.
6. chrono, time
chrono is a date and time library for Rust. It aims to be a feature-complete superset of the time library.
time a date and time library. Fully interoperable with the standard library. Mostly compatible with #![no_std].
7. clap
clap - It is a simple-to-use, efficient, and full-featured library for parsing command-line arguments and subcommands when writing command line, console, or terminal applications.
8. derive_more
derive_more adds #[derive(x)] macros for more traits. It does this by allowing you to derive lots of commonly used traits for both structs and enums.
9. derive_new
derive_new
#[derive(new)]
implements simple constructor functions for structs and enums.
A derive(new) attribute creates a new constructor function for the annotated type. That function takes an argument for each field in the type giving a trivial constructor. This is useful since as your type evolves you can make the constructor non-trivial (and add or remove fields) without changing client code (i.e., without breaking backwards compatibility). It is also the most succinct way to initialise a struct or an enum.
10. fst
fst Crate fst is a library for efficiently storing and searching ordered sets or maps where the keys are byte strings. A key design goal of this crate is to support storing and searching very large sets or maps (i.e., billions). This means that much effort has gone into making sure that all operations are memory efficient.
11. hyper, reqwest
hyper is a fast and correct HTTP library. It is a lower-level HTTP library, meant to be a building block for libraries and applications. If looking for just a convenient HTTP client, consider the reqwest crate.
reqwest is a higher-level HTTP client library.
12. inventory
inventory is a typed distributed plugin registration. This crate provides a way to set up a plugin registry into which plugins can be registered from any source file linked to your application. There does not need to be a central list of all the plugins.
13. itertools
itertools is an extra iterator adaptors, iterator methods, free functions, and macros. It's similar to a utility library like lodash in Js.
14. libloading
libloading is a safer binding to the platform’s dynamic library loading utilities. It is a memory-safer wrapper around system dynamic library loading primitives. Using this library allows loading shared libraries and use functions & global variables contained within the libraries. E.g. Wrap Go for Rust
15. ndarray
ndarray is an n-dimensional array for general elements and for numerics. Lightweight array views and slicing; views support chunking and splitting.
16. once_cell
once_cell is a single assignment cells and lazy values. It provides two new cell-like types, unsync::OnceCell and sync::OnceCell. A OnceCell might store arbitrary non-Copy types, can be assigned to at most once and provides direct access to the stored contents.
17. protest
protest is a hypothesis-like property-based testing and shrinking. It is a property testing framework (i.e., the QuickCheck family) inspired by the Hypothesis framework for Python. It allows to test that certain properties of your code hold for arbitrary inputs, and if a failure is found, automatically finds the minimal test case to reproduce the problem.
18. pyo3
pyo3 are bindings to Python interpreter Rust libraries in Python. PyO3 can be used to write native Python modules or run Python code and modules from Rust.
19. rand
rand is a random number generator and other randomness functionality. Rand provides utilities to generate random numbers, to convert them to use types and distributions, and some randomness-related algorithms. Also nanorand - a tiny, fast, zero-dep library for random number generation; fastrand is another alternative but not cryptographically secure.
20. rayon / parallel_stream
rayon is a simple work-stealing parallelism for Rust. The data-parallelism library that makes it easy to convert sequential computations into parallel. Rayon is lightweight and convenient for introducing parallelism into existing code. It guarantees data-race-free executions and takes advantage of parallelism when sensible, based on work-load at runtime.
parallel-stream is a data parallelism library for async-std. This library provides convenient parallel iteration of Streams. Analogous to how Rayon provides parallel iteration of Iterators. This allows processing data coming from a stream in parallel, enabling the use of all system resources.
21. regex
regex is an implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs. This crate provides a library for parsing, compiling, and executing regular expressions. Its syntax is similar to Perl-style regular expressions, but lacks a few features like look around and backreferences. In exchange, all searches execute in linear time with respect to the size of the regular expression and search text.
22. serde
serde is a generic serialization/deserialization framework. Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.
The Serde ecosystem consists of data structures that know how to serialize and deserialize themselves along with data formats that know how to serialize and deserialize other things. Serde provides the layer by which these two groups interact with each other, allowing any supported data structure to be serialized and deserialized using any supported data format.
23. slog, log
slog is an ecosystem of reusable components for structured, extensible, composable logging for Rust.
log is a lightweight logging facade for Rust.
24. slotmap
slotmap This library provides a container with persistent unique keys to access stored values, SlotMap. Upon insertion a key is returned that can be used to later access or remove the values. Insertion, removal and access all take O(1) time with low overhead. Great for storing collections of objects that need stable, safe references but have no clear ownership otherwise, such as game entities or graph nodes.
25. strum
strum a helpful macros for working with enums and strings
26. surf
surf surf the web - HTTP client framework. Surf is a friendly HTTP client built for casual Rustaceans and veterans alike. It’s completely modular, and built directly for async/await. Whether it’s a quick script, or a cross-platform SDK, Surf will make it work.
27. syn, quote
syn is a parsing library for parsing a stream of Rust tokens into a syntax tree of Rust source code. quoteThis crate provides the quote! macro for turning Rust syntax tree data structures into tokens of source code. Procedural macros in Rust receive a stream of tokens as input, execute arbitrary Rust code to determine how to manipulate those tokens, and produce a stream of tokens to hand back to the compiler to compile into the caller's crate. Quasi-quoting is a solution to one piece of that — producing tokens to return to the compiler.
28. thiserror
thiserror This library provides a convenient derive macro for the standard library’s std::error::Error
trait.
29. tinyvec
tinyvec provides 100% safe vec-like data structures. With no features enabled, this crate provides the ArrayVec type, which is an array-backed storage. You can push values into the array and pop them out of the array and so on. If the array is made to overflow it will panic. Similarly, there is also a SliceVec type available, which is a vec-like that’s backed by a slice you provide. You can add and remove elements, but if you overflow the slice it will panic.
30. tracing
tracing is a framework for instrumenting Rust programs to collect structured, event-based diagnostic information.
In asynchronous systems like Tokio, interpreting traditional log messages can often be quite challenging. Since individual tasks are multiplexed on the same thread, associated events and log lines are intermixed making it difficult to trace the logic flow. tracing expands upon logging-style diagnostics by allowing libraries and applications to record structured events with additional information about temporality and causality — unlike a log message, a span in tracing has a beginning and end time, may be entered and exited by the flow of execution, and may exist within a nested tree of similar spans. In addition, tracing spans are structured, with the ability to record typed data as well as textual messages.
31. walkdir / ignore
walkdir crate provides an efficient and cross-platform implementation of recursive directory traversal. Several options are exposed to control iteration, such as whether to follow symbolic links (default off), limit the maximum number of simultaneous open file descriptors, and the ability to efficiently skip descending into directories.
ignore The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files. The precise matching rules and precedence is explained in the documentation for WalkBuilder. Secondarily, this crate exposes gitignore and file type matchers for use cases that demand more fine-grained control.
32. wrap
wrap Macros for defining function wrappers and wrapped functions. It provides two macros, def_wrapper!
and wrap_with!
. def_wrapper!
lets you define before and after actions to wrap any given function. wrappers can then be applied to arbitrary functions using wrap_with!
which takes a wrapper name and function definition and expands to a wrapped form.