From 832db62f6790c9888693adbe7ccd2911136718d5 Mon Sep 17 00:00:00 2001 From: Willem Vanhulle Date: Wed, 21 Oct 2026 11:26:21 +0200 Subject: [PATCH] refactor: give modules descriptive names --- examples/boot.rs | 4 +-- examples/luks.rs | 4 +-- examples/shutdown.rs | 4 +-- src/{password.rs => ask_password.rs} | 12 +++---- src/{feed.rs => boot_feed.rs} | 10 +++--- src/{model.rs => boot_model.rs} | 0 src/{origin.rs => boot_origin.rs} | 0 src/{view.rs => boot_view.rs} | 34 +++++++++---------- .../timeline.rs => boot_view/run_timeline.rs} | 6 ++-- .../chrome.rs => boot_view/screen_chrome.rs} | 8 ++--- .../stages.rs => boot_view/stage_summary.rs} | 2 +- src/{view/tree.rs => boot_view/unit_tree.rs} | 6 ++-- src/{colors.rs => color_scheme.rs} | 0 src/{config.rs => config_file.rs} | 2 +- src/{console.rs => console_takeover.rs} | 10 +++--- src/{glyphs.rs => font_glyphs.rs} | 0 src/lib.rs | 16 ++++----- src/main.rs | 24 ++++++------- src/{clock.rs => monotonic_clock.rs} | 0 src/{passphrase.rs => passphrase_input.rs} | 0 src/{script.rs => scripted_boot.rs} | 20 +++++------ src/{sysroot.rs => switch_root.rs} | 0 src/{systemd.rs => systemd_bus.rs} | 4 +-- src/{error.rs => watch_error.rs} | 0 src/{run.rs => watch_loop.rs} | 24 ++++++------- 25 files changed, 95 insertions(+), 95 deletions(-) rename src/{password.rs => ask_password.rs} (95%) rename src/{feed.rs => boot_feed.rs} (97%) rename src/{model.rs => boot_model.rs} (100%) rename src/{origin.rs => boot_origin.rs} (100%) rename src/{view.rs => boot_view.rs} (97%) rename src/{view/timeline.rs => boot_view/run_timeline.rs} (98%) rename src/{view/chrome.rs => boot_view/screen_chrome.rs} (96%) rename src/{view/stages.rs => boot_view/stage_summary.rs} (97%) rename src/{view/tree.rs => boot_view/unit_tree.rs} (99%) rename src/{colors.rs => color_scheme.rs} (100%) rename src/{config.rs => config_file.rs} (99%) rename src/{console.rs => console_takeover.rs} (95%) rename src/{glyphs.rs => font_glyphs.rs} (100%) rename src/{clock.rs => monotonic_clock.rs} (100%) rename src/{passphrase.rs => passphrase_input.rs} (100%) rename src/{script.rs => scripted_boot.rs} (95%) rename src/{sysroot.rs => switch_root.rs} (100%) rename src/{systemd.rs => systemd_bus.rs} (98%) rename src/{error.rs => watch_error.rs} (100%) rename src/{run.rs => watch_loop.rs} (94%) diff --git a/examples/boot.rs b/examples/boot.rs index 5982f46..d369e82 100644 --- a/examples/boot.rs +++ b/examples/boot.rs @@ -1,8 +1,8 @@ use std::{io, time::Duration}; use bootvine::{ - model::Phase, - script::{Scenario, Step, failing, play, step}, + boot_model::Phase, + scripted_boot::{Scenario, Step, failing, play, step}, }; const INITRD: &[Step] = &[ diff --git a/examples/luks.rs b/examples/luks.rs index 55b4f1d..5fb7056 100644 --- a/examples/luks.rs +++ b/examples/luks.rs @@ -1,8 +1,8 @@ use std::{io, time::Duration}; use bootvine::{ - model::Phase, - script::{Scenario, Step, play, step, unlocking}, + boot_model::Phase, + scripted_boot::{Scenario, Step, play, step, unlocking}, }; const ROOT_PARTITION: &str = diff --git a/examples/shutdown.rs b/examples/shutdown.rs index 136b557..57042f8 100644 --- a/examples/shutdown.rs +++ b/examples/shutdown.rs @@ -1,8 +1,8 @@ use std::{io, time::Duration}; use bootvine::{ - model::Phase, - script::{Scenario, Step, play, step, stopping}, + boot_model::Phase, + scripted_boot::{Scenario, Step, play, step, stopping}, }; const SHUTDOWN: &[Step] = &[ diff --git a/src/password.rs b/src/ask_password.rs similarity index 95% rename from src/password.rs rename to src/ask_password.rs index 3b51295..da6e47c 100644 --- a/src/password.rs +++ b/src/ask_password.rs @@ -8,7 +8,7 @@ use std::{ time::Duration, }; -use bootvine::{passphrase, view::PasswordPrompt}; +use bootvine::{boot_view::PasswordPrompt, passphrase_input}; use crossterm::event::Event; use rustix::{ fs::inotify::{self, CreateFlags, WatchFlags}, @@ -17,7 +17,7 @@ use rustix::{ }; use zeroize::Zeroizing; -use crate::clock::monotonic_now; +use crate::monotonic_clock::monotonic_now; const REQUESTS: &str = "/run/systemd/ask-password"; const REQUEST_PREFIX: &str = "ask."; @@ -186,7 +186,7 @@ impl PasswordEntry { } Some(Self { request, - typed: passphrase::empty(), + typed: passphrase_input::empty(), sent: false, }) } @@ -201,7 +201,7 @@ impl PasswordEntry { } else if self.request.echo { self.typed.to_string() } else { - passphrase::masked(&self.typed) + passphrase_input::masked(&self.typed) }; PasswordPrompt { message: &self.request.message, @@ -214,7 +214,7 @@ impl PasswordEntry { if self.sent { return Ok(()); } - let Some(submitted) = passphrase::type_key(&mut self.typed, event) else { + let Some(submitted) = passphrase_input::type_key(&mut self.typed, event) else { return Ok(()); }; self.request.answer(&submitted)?; @@ -271,7 +271,7 @@ mod tests { fn hides_what_is_typed() { let mut entry = PasswordEntry { request: PasswordRequest::parse(Path::new("ask.x"), CRYPTSETUP_ASK).expect("parsed"), - typed: passphrase::empty(), + typed: passphrase_input::empty(), sent: false, }; "secret".chars().for_each(|character| { diff --git a/src/feed.rs b/src/boot_feed.rs similarity index 97% rename from src/feed.rs rename to src/boot_feed.rs index 4adf267..03bed4e 100644 --- a/src/feed.rs +++ b/src/boot_feed.rs @@ -7,16 +7,16 @@ use std::{ time::{Duration, Instant}, }; -use bootvine::model::{ +use bootvine::boot_model::{ BootState, HANDOFF_UNIT, HOST_MILESTONES, JobKind, Phase, SHUTDOWN_MILESTONES, }; use dbus::Path; use crate::{ - clock::monotonic_now, - error::Error, - sysroot::{INITRD_RELEASE, Sysroot}, - systemd::{Scope, Session, Signal}, + monotonic_clock::monotonic_now, + switch_root::{INITRD_RELEASE, Sysroot}, + systemd_bus::{Scope, Session, Signal}, + watch_error::Error, }; const RECONNECT_PATIENCE: Duration = Duration::from_secs(60); diff --git a/src/model.rs b/src/boot_model.rs similarity index 100% rename from src/model.rs rename to src/boot_model.rs diff --git a/src/origin.rs b/src/boot_origin.rs similarity index 100% rename from src/origin.rs rename to src/boot_origin.rs diff --git a/src/view.rs b/src/boot_view.rs similarity index 97% rename from src/view.rs rename to src/boot_view.rs index 4975ddb..951c139 100644 --- a/src/view.rs +++ b/src/boot_view.rs @@ -1,7 +1,7 @@ -mod chrome; -mod stages; -mod timeline; -mod tree; +mod run_timeline; +mod screen_chrome; +mod stage_summary; +mod unit_tree; use std::time::Duration; @@ -16,25 +16,25 @@ use ratatui::{ use unicode_truncate::UnicodeTruncateStr; use unicode_width::UnicodeWidthStr; -pub use self::chrome::PasswordPrompt; +pub use self::screen_chrome::PasswordPrompt; use self::{ - chrome::{FOOTER_HEIGHT, Footer, Header, PasswordPopup}, - stages::Stages, - timeline::{RunningRun, Timeline}, - tree::UnitTree, + run_timeline::{RunningRun, Timeline}, + screen_chrome::{FOOTER_HEIGHT, Footer, Header, PasswordPopup}, + stage_summary::Stages, + unit_tree::UnitTree, }; use crate::{ - colors::Colors, - config::Timing, - glyphs::Glyphs, - model::{BootState, RowStatus, TreeRow, UnitKind, fit_to_height, fold_chains}, - origin::BootOrigin, + boot_model::{BootState, RowStatus, TreeRow, UnitKind, fit_to_height, fold_chains}, + boot_origin::BootOrigin, + color_scheme::Colors, + config_file::Timing, + font_glyphs::Glyphs, }; const DURATION_WIDTH: u16 = 8; const MIN_BAR_WIDTH: u16 = 12; const MIN_HEIGHT_FOR_TIMELINE: u16 = 12; -const MIN_TIMELINE_HEIGHT: u16 = timeline::CHROME_HEIGHT + 4; +const MIN_TIMELINE_HEIGHT: u16 = run_timeline::CHROME_HEIGHT + 4; const HEADER_HEIGHT: u16 = 1; const BRANCH: &str = "├─ "; const LAST_BRANCH: &str = "└─ "; @@ -123,7 +123,7 @@ impl Widget for BootView<'_> { colors: &self.colors.footer, glyphs: self.glyphs, }; - let fits_timeline = area.width >= timeline::LABEL_WIDTH + 1 + MIN_BAR_WIDTH + let fits_timeline = area.width >= run_timeline::LABEL_WIDTH + 1 + MIN_BAR_WIDTH && area.height >= MIN_HEIGHT_FOR_TIMELINE; let free = area .height @@ -236,7 +236,7 @@ mod tests { use ratatui::{Terminal, backend::TestBackend}; use super::*; - use crate::model::{ActiveState, Activity, JobKind, JobResult, Phase, UnitFacts}; + use crate::boot_model::{ActiveState, Activity, JobKind, JobResult, Phase, UnitFacts}; const MS: Duration = Duration::from_millis(1); diff --git a/src/view/timeline.rs b/src/boot_view/run_timeline.rs similarity index 98% rename from src/view/timeline.rs rename to src/boot_view/run_timeline.rs index 5aa06ce..97ad77b 100644 --- a/src/view/timeline.rs +++ b/src/boot_view/run_timeline.rs @@ -15,9 +15,9 @@ use ratatui::{ use super::{fit_width, rule, unit_count}; use crate::{ - colors::TimelineColors, - glyphs::Glyphs, - model::{FinishedRun, MilestoneRow}, + boot_model::{FinishedRun, MilestoneRow}, + color_scheme::TimelineColors, + font_glyphs::Glyphs, }; pub const LABEL_WIDTH: u16 = 28; diff --git a/src/view/chrome.rs b/src/boot_view/screen_chrome.rs similarity index 96% rename from src/view/chrome.rs rename to src/boot_view/screen_chrome.rs index e410132..270b408 100644 --- a/src/view/chrome.rs +++ b/src/boot_view/screen_chrome.rs @@ -10,10 +10,10 @@ use ratatui::{ use super::{DURATION_WIDTH, ELAPSED}; use crate::{ - colors::{FooterColors, HeaderColors, PasswordColors}, - glyphs::Glyphs, - model::Tally, - origin::BootOrigin, + boot_model::Tally, + boot_origin::BootOrigin, + color_scheme::{FooterColors, HeaderColors, PasswordColors}, + font_glyphs::Glyphs, }; pub const FOOTER_HEIGHT: u16 = 2; diff --git a/src/view/stages.rs b/src/boot_view/stage_summary.rs similarity index 97% rename from src/view/stages.rs rename to src/boot_view/stage_summary.rs index 445418d..89bc5fc 100644 --- a/src/view/stages.rs +++ b/src/boot_view/stage_summary.rs @@ -9,7 +9,7 @@ use ratatui::{ }; use super::{BRANCH, ELAPSED, LAST_BRANCH, unit_count}; -use crate::{colors::StageColors, glyphs::Glyphs, model::BootState}; +use crate::{boot_model::BootState, color_scheme::StageColors, font_glyphs::Glyphs}; const SHUTDOWN_SUCCESSOR: &str = "systemd-shutdown"; const PHASE_WIDTH: usize = 9; diff --git a/src/view/tree.rs b/src/boot_view/unit_tree.rs similarity index 99% rename from src/view/tree.rs rename to src/boot_view/unit_tree.rs index 164f76c..df82d4a 100644 --- a/src/view/tree.rs +++ b/src/boot_view/unit_tree.rs @@ -11,9 +11,9 @@ use unicode_width::UnicodeWidthStr; use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width}; use crate::{ - colors::TreeColors, - glyphs::Glyphs, - model::{RowStatus, TreeRow, UnitKind}, + boot_model::{RowStatus, TreeRow, UnitKind}, + color_scheme::TreeColors, + font_glyphs::Glyphs, }; const SPINNER: [char; 4] = ['|', '/', '-', '\\']; diff --git a/src/colors.rs b/src/color_scheme.rs similarity index 100% rename from src/colors.rs rename to src/color_scheme.rs diff --git a/src/config.rs b/src/config_file.rs similarity index 99% rename from src/config.rs rename to src/config_file.rs index 508a79b..26e5439 100644 --- a/src/config.rs +++ b/src/config_file.rs @@ -5,7 +5,7 @@ use jiff::fmt::serde::unsigned_duration::friendly::compact::required as friendly use serde::{Deserialize, Serialize}; use toml::{Table, Value, de::Error as ParseError, ser::Error as SerializeError}; -use crate::colors::Colors; +use crate::color_scheme::Colors; #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)] #[serde(default, deny_unknown_fields, rename_all = "kebab-case")] diff --git a/src/console.rs b/src/console_takeover.rs similarity index 95% rename from src/console.rs rename to src/console_takeover.rs index 168c03f..3feca4a 100644 --- a/src/console.rs +++ b/src/console_takeover.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, fs, ptr}; -use bootvine::glyphs::Glyphs; +use bootvine::font_glyphs::Glyphs; use rustix::{ io::Errno, ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl}, @@ -8,7 +8,7 @@ use rustix::{ termios::ttyname, }; -use crate::password; +use crate::ask_password; const GIO_UNIMAP: Opcode = 0x4B66; const VT_GETSTATE: Opcode = 0x5603; @@ -26,7 +26,7 @@ pub struct Console { impl Console { pub fn take(for_system: bool) -> Self { - let prompt_elsewhere = for_system && password::requested(); + let prompt_elsewhere = for_system && ask_password::requested(); if prompt_elsewhere { eprintln!("bootvine: a password prompt is already showing, staying behind it"); } @@ -48,7 +48,7 @@ impl Console { } pub fn come_forward_once_prompts_are_gone(&mut self) -> bool { - if !self.for_system || self.foreground.is_some() || password::requested() { + if !self.for_system || self.foreground.is_some() || ask_password::requested() { return false; } self.foreground = ForegroundVt::take(); @@ -194,7 +194,7 @@ impl ForegroundVt { impl Drop for ForegroundVt { fn drop(&mut self) { - if password::requested() { + if ask_password::requested() { eprintln!("bootvine: leaving a password prompt to the console agent on this terminal"); return; } diff --git a/src/glyphs.rs b/src/font_glyphs.rs similarity index 100% rename from src/glyphs.rs rename to src/font_glyphs.rs diff --git a/src/lib.rs b/src/lib.rs index 802f05e..1b48f72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ -pub mod colors; -pub mod config; -pub mod glyphs; -pub mod model; -pub mod origin; -pub mod passphrase; -pub mod script; -pub mod view; +pub mod boot_model; +pub mod boot_origin; +pub mod boot_view; +pub mod color_scheme; +pub mod config_file; +pub mod font_glyphs; +pub mod passphrase_input; +pub mod scripted_boot; diff --git a/src/main.rs b/src/main.rs index 0cd8b59..238c7f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ -mod clock; -mod console; -mod error; -mod feed; -mod password; -mod run; -mod sysroot; -mod systemd; +mod ask_password; +mod boot_feed; +mod console_takeover; +mod monotonic_clock; +mod switch_root; +mod systemd_bus; +mod watch_error; +mod watch_loop; use std::{ error::Error, @@ -15,14 +15,14 @@ use std::{ time::Duration, }; -use bootvine::config::{Config, ConfigError, Timing, default_config_table, read_config_file}; +use bootvine::config_file::{Config, ConfigError, Timing, default_config_table, read_config_file}; use clap::{Parser, Subcommand, ValueEnum}; use jiff::fmt::friendly::SpanParser; use crate::{ - feed::RootRequest, - run::{Settings, run}, - systemd::Scope, + boot_feed::RootRequest, + systemd_bus::Scope, + watch_loop::{Settings, run}, }; #[derive(Parser)] diff --git a/src/clock.rs b/src/monotonic_clock.rs similarity index 100% rename from src/clock.rs rename to src/monotonic_clock.rs diff --git a/src/passphrase.rs b/src/passphrase_input.rs similarity index 100% rename from src/passphrase.rs rename to src/passphrase_input.rs diff --git a/src/script.rs b/src/scripted_boot.rs similarity index 95% rename from src/script.rs rename to src/scripted_boot.rs index 3535785..3a308f8 100644 --- a/src/script.rs +++ b/src/scripted_boot.rs @@ -10,13 +10,13 @@ use ratatui::{ }; use crate::{ - colors::Colors, - config::Timing, - glyphs::Glyphs, - model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts}, - origin::BootOrigin, - passphrase, - view::{BootView, PasswordPrompt}, + boot_model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts}, + boot_origin::BootOrigin, + boot_view::{BootView, PasswordPrompt}, + color_scheme::Colors, + config_file::Timing, + font_glyphs::Glyphs, + passphrase_input, }; const FRAME_INTERVAL: Duration = Duration::from_millis(100); @@ -209,7 +209,7 @@ impl Script { fn prompt(&self, typed: &str, now: Duration) -> Option> { Some(PasswordPrompt { message: self.asking()?.asks?, - input: passphrase::masked(typed), + input: passphrase_input::masked(typed), sent: self.is_checking(now), }) } @@ -311,7 +311,7 @@ pub fn play(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<( let mut switched_root = scenario.after_switch_root.is_empty(); let mut settled_at = None; let mut frame = 0; - let mut typed = passphrase::empty(); + let mut typed = passphrase_input::empty(); loop { script.advance(&mut state, now()); if script.is_done() && !switched_root { @@ -351,7 +351,7 @@ pub fn play(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<( } if asking && !script.is_checking(now()) - && let Some(submitted) = passphrase::type_key(&mut typed, &event) + && let Some(submitted) = passphrase_input::type_key(&mut typed, &event) { script.answer(&submitted, now()); } diff --git a/src/sysroot.rs b/src/switch_root.rs similarity index 100% rename from src/sysroot.rs rename to src/switch_root.rs diff --git a/src/systemd.rs b/src/systemd_bus.rs similarity index 98% rename from src/systemd.rs rename to src/systemd_bus.rs index 71623ce..bcd2674 100644 --- a/src/systemd.rs +++ b/src/systemd_bus.rs @@ -4,14 +4,14 @@ use std::{ time::Duration, }; -use bootvine::model::{ActiveState, Activity, JobKind, JobResult, UnitFacts}; +use bootvine::boot_model::{ActiveState, Activity, JobKind, JobResult, UnitFacts}; use dbus::{ Message, MessageType, Path, arg::{AppendAll, PropMap, RefArg, Variant}, channel::{BusType, Channel}, }; -use crate::error::Error; +use crate::watch_error::Error; const DESTINATION: &str = "org.freedesktop.systemd1"; const MANAGER_PATH: &str = "/org/freedesktop/systemd1"; diff --git a/src/error.rs b/src/watch_error.rs similarity index 100% rename from src/error.rs rename to src/watch_error.rs diff --git a/src/run.rs b/src/watch_loop.rs similarity index 94% rename from src/run.rs rename to src/watch_loop.rs index 2fe0827..c0fadbe 100644 --- a/src/run.rs +++ b/src/watch_loop.rs @@ -11,11 +11,11 @@ use std::{ }; use bootvine::{ - colors::Colors, - config::Timing, - model::{BootState, Phase}, - origin::BootOrigin, - view::BootView, + boot_model::{BootState, Phase}, + boot_origin::BootOrigin, + boot_view::BootView, + color_scheme::Colors, + config_file::Timing, }; use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers}; use ratatui::{ @@ -33,13 +33,13 @@ use rustix::{ use signal_hook::{consts::SIGTERM, flag}; use crate::{ - clock::monotonic_now, - console::Console, - error::Error, - feed::{Feed, RootRequest}, - password::{PasswordEntry, RequestWatch}, - sysroot::INITRD_RELEASE, - systemd::{Scope, Session}, + ask_password::{PasswordEntry, RequestWatch}, + boot_feed::{Feed, RootRequest}, + console_takeover::Console, + monotonic_clock::monotonic_now, + switch_root::INITRD_RELEASE, + systemd_bus::{Scope, Session}, + watch_error::Error, }; const FRAME_INTERVAL: Duration = Duration::from_millis(100);