How inksha/rust-tutorial works
Project type and purpose
• This is a standalone command-line Todo-management tool written in Rust.
• It uses Cargo to pull in two major third-party crates: clap (for CLI argument parsing) and serde/serde_json (for JSON serialization).
• Users can run commands like create and list to manage their tasks; data is persisted in a local JSON file (todo.json).
File structure
• Top level:
– Cargo.toml and Cargo.lock define dependencies and build targets.
– README.md and docs/ explain usage and host the tutorial.
– todo.json is the runtime persistence file.
• src/ directory:
– main.rs: program entrypoint. Reads CLI args via clap, reads existing todos, dispatches to commands, then saves.
– todo.rs: module root; declares three submodules.
– todo/core.rs: domain definitions: TodoItem struct, TodoCommand enum, serialization/deserialization logic.
– todo/create.rs: interactive or flag-driven creation logic.
– todo/list.rs: listing and filtering logic.
– todo/storage.rs: file I/O; read/write JSON.
README for additional insights
• Highlights layering: parsing → domain → commands → persistence.
• Shows evolution from a monolithic main.rs to a modular layout.
• Emphasizes use of patterns like generics (Option, Into), traits (Serializer), and error handling (Result, ? operator).
Elements
– Presentation layer (terminal & clap)
– Application layer (command modules)
– Domain layer (core structs & enums)
– Infrastructure layer (storage & file system)
– External dependencies (clap, serde, std::fs)