Rust
Supported projects
The following project is recommended for implementing Rust applications using the YugabyteDB YSQL API.
Project | Documentation and Guides | Latest Driver Version | Supported YugabyteDB Version | Example Apps |
---|---|---|---|---|
YugabyteDB Rust-Postgres Smart Driver [Recommended] | Documentation Reference |
yb-postgres (synchronous YSQL client): v0.19.7-yb-1-beta yb-tokio-postgres (asynchronous YSQL client): v0.7.10-yb-1-beta |
2.19 and later | |
Diesel | Documentation Hello World |
Diesel app |
Learn how to establish a connection to a YugabyteDB database and begin basic CRUD operations using the Hello World examples.
For fully-runnable code snippets and explanations of common operations, see the example apps. Before running the example apps, make sure you have installed the prerequisites.
Prerequisites
To develop Rust applications for YugabyteDB, you need the following:
-
Rust
To download and install Rust, refer to the Rust documentation.
To check the version of Rust, use the following command:$ rustc --version
-
Create a Rust project
To create a new Rust project, run the following command:$ cargo new HelloWorld-rust
This creates the project as
HelloWorld-rust
which consists of aCargo.toml
file (project metadata) and asrc
directory containing the main code file,main.rs
. -
YugabyteDB cluster
- Create a free cluster on YugabyteDB Managed. Refer to Use a cloud cluster. Note that YugabyteDB Managed requires SSL.
- Alternatively, set up a standalone YugabyteDB cluster by following the steps in Install YugabyteDB.