Skip to main content

Task 1: Core Functionalities


1. Project Setup​

  • Create Tauri project using vanilla-ts template

2. Frontend Structure​

  • Create HTML with:
    • <textarea> for text editing
    • Two buttons (Open/Save)
  • Add CSS for basic layout (optional)

3. Backend Functions (Rust)​

  • Use std::fs (built-in Rust module, no external crate needed):
    • read_file(path: String) -> Result<String,String>
    • write_file(path: String, contents: String) -> Result<String, String>
  • Expose these as Tauri commands using #[tauri::command] and add in .invoke_handler

4. Frontend Interaction (TypeScript)​

  • Use Tauri APIs:
    • @tauri-apps/api/plugin-dialog for file picker (open(), save())
    • @tauri-apps/api invoke() to call Rust commands
  • Link button clicks to:
    • Get file path via dialog, (hint: open())
    • Pass path/content between frontend ↔ backend (hint: invoke())

5. Security Configuration, if needed​

  • In tauri.conf.json:
    • Allow fs access to specific directories
    • Enable dialog API

Key Technical Requirements​

ComponentTechnology/PackagePurpose
FrontendTauri Dialog APIFile path selection
Bridgeinvoke()TS ↔ Rust communication
BackendRust std::fsRead/write files
Error HandlingRust Result typePropagate I/O errors to frontend

Conclusion Task 1​

  • Great job! You have done it, now you have a text editor with the core functionalities!
  • "First, make it work. Then make it work harder..." β€” Engineers’ Mantra