File formats and databases
The standard library offers the std::fs
module for filesystem manipulation, which we explored in Chapter 11, Exploring the Standard Library.
- If you have to work with Comma Separated Values (csv) files, use one of the available crates such as
csv
,quick_csv
,simple_csv
, orxsv
. The article on 24 days, http://zsiciarz.github.io/24daysofrust/book/vol1/day3.html, can get you started. - For working with JSON files, use a crate such as
json, simple_json, serde_json
, orjson_macros
; start with reading http://zsiciarz.github.io/24daysofrust/book/vol1/day6.html. - For XML format, there are also plenty of possibilities, such as the
xml-rs
orquick-xml
crates.
For databases, there are many crates available for working with:
- sqlite3 (crates
rusqlite
orsqlite
)
- PostgreSQL (crates
postgres
andtokio-postgres
); get started by using http://zsiciarz.github.io/24daysofrust/book/vol1/day11.html - Mysql (crate
mysql
ormysql_async
):
Here is some code (mysql.rs
) that connects to a local Mysql database...