[Refactor] Move the config structs to a new module
This commit is contained in:
parent
48ace5dc01
commit
b45a2bd8ee
13
src/config.rs
Normal file
13
src/config.rs
Normal file
@ -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,
|
||||
}
|
15
src/main.rs
15
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<Config>, hour_name_path_cache: &[(PathData, PathData); 24]) -> Document {
|
||||
let local_timestamp = Local::now();
|
||||
let utc_hour = local_timestamp.with_timezone(&Utc).time().hour();
|
||||
|
Loading…
Reference in New Issue
Block a user