5 Rust Project Ideas For Beginner Devs 🦀
Get requests, make API calls, very basic auth, and more!
Hey there, welcome back to my blog! 👋
If you’re learning Rust for the very first time I want to introduce you to 5 simple yet practical projects that will help you later in real-world projects. I wrote another article with 5 ideas, this is one step up on the learning ladder.
The concepts I’m presenting below are pretty basic; every Rust developer should know them.
Below you’ll find the 5 project ideas, the posts (tweets) where I’m explaining step-by-step how you can build these projects, and a link to the corresponding GitHub repo!
Project Idea 5: Simple Get Request
In the above post, I’m explaining how to make a GET request using the reqwest
crate in Rust, handle the response, and print the status code, headers, and body of the response. Additionally, in the code, you'll find the error_chain
crate for error handling.
Check it on GitHub.
Project Idea 4: Asynchronous GET Request
If you try this code for yourself you’ll learn how to:
- Make an asynchronous GET request using the
reqwest
crate in Rust - Handle the response asynchronously using
async
andawait
- Print the status code, headers, and body of the response
Check it on GitHub.
Project Idea 3: Making API Calls
If you completed the above projects I suggest you now work with API calls. In the project I’m presenting here you’ll be able to learn how to:
- Make an HTTP GET request to an API endpoint using the
reqwest
crate - Handle the response asynchronously using
async
andawait
- Deserialize the JSON response into Rust structs using
serde
- Additionally, you can use the
User-Agent
header in the request to identify the client making the request
Check it on GitHub.
Project Idea 2: Very Basic Authentication
Overall, after finishing this project you’ll be able to: make a synchronous GET request to a URL using the reqwest
crate and also add basic authentication to the request and handle the response.
Check it on GitHub.
Project Idea 1: Download an Image
This idea about this project is about downloading an image from a specified URL (in this case, the Rust logo image from the Rust website) and saving it to a temporary directory on the local file system.
Here’s an overview of what the program does:
- It creates a temporary directory using
tempfile::Builder
. - It specifies the URL of the image to be downloaded (
https://rust-lang.org/logos/rust-logo-512x512.png
). - It sends an asynchronous GET request to the specified URL using the
reqwest
crate. - It extracts the file name from the response URL and creates a file with that name in the temporary directory.
- It reads the content of the response body as text asynchronously.
- It copies the content of the response body, represented as bytes, to the file created in the temporary directory.
- It prints information about the downloaded file, such as the file name and the location where it is stored in the temporary directory.
- It returns
Ok(())
, indicating that the program executed successfully.
Check it on GitHub.
Notes
I’m new to Rust and I hope these small projects will help you get better and improve your skills. Check here part 1 of Rust project ideas for beginners and if you need more resources I’d also like to suggest Akhil Sharma’s YouTube Channel.
Originally published at https://eleftheriabatsou.hashnode.dev on February 25, 2024.