Creating a Task using our DAL
We now shift our focus back to creating a task. When creating this task, we need to store the newly created task using the data access layer. Storing the task in JSON will involve some serialization, therefore, we need to ensure that we have the serde
crate installed, and our Cargo.toml
file should have the following dependencies:
# File: to_do/core/Cargo.toml
[dependencies]
dal = { path = "../dal", features = ["json-file"] }
serde = { version = "1.0.197", features = ["derive"] }
clap = { version = "4.5.4", features = ["derive"] }
We can now start writing code. We now need to enable our TaskStatus
to deserialize and serialize so we can write the task status of the to-do item to the JSON file. We also want our status to construct from a string.
Before we write any additional code to the TaskStatus
enum, we need to use the following code:
//! File: to_do/core/src/enums.rs
use serde::{Serialize,...