terminal_jarvis/presentation/models/
mod.rs

1//! Core data models for Terminal Jarvis
2//!
3//! This module contains the fundamental data structures used throughout
4//! the application, following an MVVM-inspired architecture.
5
6pub mod tool;
7
8pub use tool::*;
9
10/// Application state management
11#[derive(Debug, Clone, PartialEq)]
12pub struct AppState {
13    pub current_view: ViewType,
14    pub tools: Vec<Tool>,
15    pub selected_tool_index: Option<usize>,
16}
17
18impl Default for AppState {
19    fn default() -> Self {
20        Self::new()
21    }
22}
23
24impl AppState {
25    pub fn new() -> Self {
26        Self {
27            current_view: ViewType::MainMenu,
28            tools: Vec::new(),
29            selected_tool_index: None,
30        }
31    }
32
33    pub fn set_view(&mut self, view: ViewType) {
34        self.current_view = view;
35    }
36
37    pub fn set_tools(&mut self, tools: Vec<Tool>) {
38        self.tools = tools;
39    }
40
41    pub fn select_tool(&mut self, index: usize) {
42        if index < self.tools.len() {
43            self.selected_tool_index = Some(index);
44        }
45    }
46
47    pub fn selected_tool(&self) -> Option<&Tool> {
48        self.selected_tool_index
49            .and_then(|index| self.tools.get(index))
50    }
51}
52
53/// View types for navigation
54#[derive(Debug, Clone, PartialEq)]
55pub enum ViewType {
56    MainMenu,
57    ToolList,
58    ToolDetails,
59    Settings,
60}