summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/main.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2025-08-15 16:02:40 +0000
committerjoeac <me@joeac.net>2025-08-15 16:02:40 +0000
commit703496a49315f7b67442abf0e0df3c41d3605d3b (patch)
tree8e92f3842710162f3b26e910eb931950c1049f07 /schist_desktop_gui/src/main.rs
parent8d714f760bd0349560d464583a151a04a19de1c9 (diff)
task-012 (#2)
Co-authored-by: Joe Carstairs <jcarstairs@scottlogic.com> Reviewed-on: https://git.joeac.net/joeac/schist/pulls/2 Co-authored-by: Joe Carstairs <me@joeac.net> Co-committed-by: Joe Carstairs <me@joeac.net>
Diffstat (limited to 'schist_desktop_gui/src/main.rs')
-rw-r--r--schist_desktop_gui/src/main.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/schist_desktop_gui/src/main.rs b/schist_desktop_gui/src/main.rs
index 7e54ddb..24aedc0 100644
--- a/schist_desktop_gui/src/main.rs
+++ b/schist_desktop_gui/src/main.rs
@@ -1,5 +1,5 @@
mod config;
-mod dummy_data;
+mod connection;
mod gui;
mod settings;
mod shortcut;
@@ -8,17 +8,31 @@ mod theme;
mod traits;
mod window_settings;
+use anyhow::Context;
+use diesel_migrations::MigrationHarness;
+use schist_schema::migrations::MIGRATIONS;
+
use crate::{
- config::Config, gui::Gui, settings::make_settings, theme::make_theme,
+ config::Config,
+ connection::establish_connection,
+ gui::Gui,
+ settings::make_settings,
+ theme::make_theme,
window_settings::make_window_settings,
};
-fn main() -> iced::Result {
+fn main() -> anyhow::Result<()> {
let config = Config::default();
- iced::application("Schist", Gui::update, Gui::view)
- .settings(make_settings(&config.clone()))
- .subscription(gui::subscription)
- .theme(make_theme)
- .window(make_window_settings(&config.clone()))
- .run_with(Gui::new)
+ let mut connection = establish_connection()
+ .context("Failed to establish database connection")?;
+ connection.run_pending_migrations(MIGRATIONS)
+ .expect("Failed to run pending database migrations");
+
+iced::application("Schist", Gui::update, Gui::view)
+ .settings(make_settings(&config.clone()))
+ .subscription(gui::subscription)
+ .theme(make_theme)
+ .window(make_window_settings(&config.clone()))
+ .run_with(move || Gui::new(&mut connection))
+ .context("Failed to run Schist GUI")
}