summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/main.rs
blob: 24aedc0c441bd03416e80446a7683f8b815a7295 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod config;
mod connection;
mod gui;
mod settings;
mod shortcut;
mod style;
mod theme;
mod traits;
mod window_settings;

use anyhow::Context;
use diesel_migrations::MigrationHarness;
use schist_schema::migrations::MIGRATIONS;

use crate::{
    config::Config,
    connection::establish_connection,
    gui::Gui,
    settings::make_settings,
    theme::make_theme,
    window_settings::make_window_settings,
};

fn main() -> anyhow::Result<()> {
    let config = Config::default();
    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")
}