From b45a2bd8ee29f4f394fcf60770bcb766e29afc10 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 23 May 2022 18:04:37 +0200 Subject: [PATCH] [Refactor] Move the config structs to a new module --- src/config.rs | 13 +++++++++++++ src/main.rs | 15 ++------------- 2 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 src/config.rs diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..198066c --- /dev/null +++ b/src/config.rs @@ -0,0 +1,13 @@ +use serde::Deserialize; + +#[derive(Deserialize, Copy, Clone)] +pub struct Config { + pub latitude: f64, + pub longitude: f64, +} + +#[derive(Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct CompleteConfig { + pub seasonal_clock: Config, +} diff --git a/src/main.rs b/src/main.rs index 3e59cd2..1393d3c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,14 +9,15 @@ use chrono::Timelike; use sctk::reexports::client::protocol::{wl_shm, wl_surface}; use sctk::shm::AutoMemPool; use sctk::window::{Event as WEvent, FallbackFrame}; -use serde::Deserialize; use svg::node::element::path::Data as PathData; use svg::node::element::{Circle, Group, Line, Rectangle, Style, Text}; use svg::node::Text as TextNode; use svg::Document; +mod config; mod svg_clock; +use config::{CompleteConfig, Config}; use svg_clock::{ cache_hour_name_paths, get_moon_path, get_range_path, hour_marker, seconds_to_degrees, svg_to_usvg, HOUR_NAMES, HOUR_NAME_FONT_SIZE, IMAGE_WIDTH, OUTER_R, RING_WIDTH, @@ -25,18 +26,6 @@ use svg_clock::{ sctk::default_environment!(SeasonalClock, desktop); -#[derive(Deserialize, Copy, Clone)] -struct Config { - latitude: f64, - longitude: f64, -} - -#[derive(Deserialize)] -#[serde(rename_all = "kebab-case")] -struct CompleteConfig { - seasonal_clock: Config, -} - fn gen_svg(config: &Option, hour_name_path_cache: &[(PathData, PathData); 24]) -> Document { let local_timestamp = Local::now(); let utc_hour = local_timestamp.with_timezone(&Utc).time().hour();