Hello all 👋🏻 ! In this series, I will be trying to build a Todo service with Rust, Actix Web, Sea-ORM with MySQL as our database of choice. I would assume you probably searched for Rust and found this which means you must know what Rust is. If not there are plenty of courses and videos explaining and what place better than the official rust lang page Here. With this let's get started with the setup and start with the implementation.
- Rust installed Instructions
- MySQL server installed
- Editor of your choice
Basic understanding of how web services work, HTTP Request-Response paradigms, Relational databases is required. I will try to explain the paradigms in context of this language as much as possible
cargo new todo-actix-seaorm
Cargo is the package and dependency management tool for rust. Run the above command in your terminal at your desired location which will generate the folder "todo-actix-seaorm" and some files/folders inside.
Understanding the structure
We can generate two types of projects with rust namely lib (Library) and bin (Binary). By default the cargo new command generates a binary and you can create a lib with the command "cargo new --lib ". The binary has an entry point and is executable on it's own and a library is a collection of modules that is used as a dependency inside another library or binary.
[package] name = "todo-actix-seaorm" version = "0.1.0" edition = "2021" [dependencies]
This file is responsible for defining the metadata about binary or library. I will not go into depth of what each and everything means and the important section for us is the dependencies section which allows us to define ( you guessed 🤪) dependencies.
This is the main file that will get executed when we execute the build output of the project. The main function is the entry point for our service and the binary will have only one main function unless of course we make some changes in cargo.toml.
The target folder holds the final and intermediate build outputs and is generally not committed to the repository as it is CPU architecture dependent and varies across CPU architectures and Operating systems.
Well, we have successfully setup the project and onwards to the next part and let's try to add some code 🤩
Did you find this article valuable?
Support Omprakash Sridharan by becoming a sponsor. Any amount is appreciated!