1use serde::{Deserialize, Serialize};
6use tracing::info;
7
8#[derive(Debug, Deserialize, Serialize)]
10pub struct AppConfig {
11 pub name: String,
13 pub version: String,
15 pub description: Option<String>,
17 pub authors: Vec<String>,
19}
20
21#[derive(Debug)]
23pub struct App {
24 config: AppConfig,
26 windows: Vec<Window>,
28}
29
30#[derive(Debug)]
32pub struct Window {
33 title: String,
35 width: u32,
37 height: u32,
39}
40
41impl App {
42 pub fn new(config: AppConfig) -> Self {
50 info!("Creating new GUI app: {}", config.name);
51 Self { config, windows: Vec::new() }
52 }
53
54 pub fn add_window(&mut self, title: &str, width: u32, height: u32) -> usize {
64 let window = Window { title: title.to_string(), width, height };
65 self.windows.push(window);
66 self.windows.len() - 1
67 }
68
69 pub fn run(&mut self) -> Result<(), Box<dyn std::error::Error>> {
74 info!("Running GUI app: {}", self.config.name);
75 Ok(())
77 }
78
79 pub fn config(&self) -> &AppConfig {
84 &self.config
85 }
86
87 pub fn windows(&self) -> &Vec<Window> {
92 &self.windows
93 }
94}