refactor: give modules descriptive names

This commit is contained in:
Willem Vanhulle committed 2026-10-21 12:12:48 +02:00
1 parent 4315f50745
commit 832db62f67
25 files changed
+95 -95

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
use std::{io, time::Duration}; use std::{io, time::Duration};
use bootvine::{ use bootvine::{
model::Phase, boot_model::Phase,
script::{Scenario, Step, failing, play, step}, scripted_boot::{Scenario, Step, failing, play, step},
}; };
const INITRD: &[Step] = &[ const INITRD: &[Step] = &[
+2 -2
View File
@@ -1,8 +1,8 @@
use std::{io, time::Duration}; use std::{io, time::Duration};
use bootvine::{ use bootvine::{
model::Phase, boot_model::Phase,
script::{Scenario, Step, play, step, unlocking}, scripted_boot::{Scenario, Step, play, step, unlocking},
}; };
const ROOT_PARTITION: &str = const ROOT_PARTITION: &str =
+2 -2
View File
@@ -1,8 +1,8 @@
use std::{io, time::Duration}; use std::{io, time::Duration};
use bootvine::{ use bootvine::{
model::Phase, boot_model::Phase,
script::{Scenario, Step, play, step, stopping}, scripted_boot::{Scenario, Step, play, step, stopping},
}; };
const SHUTDOWN: &[Step] = &[ const SHUTDOWN: &[Step] = &[
+6 -6
View File
@@ -8,7 +8,7 @@ use std::{
time::Duration, time::Duration,
}; };
use bootvine::{passphrase, view::PasswordPrompt}; use bootvine::{boot_view::PasswordPrompt, passphrase_input};
use crossterm::event::Event; use crossterm::event::Event;
use rustix::{ use rustix::{
fs::inotify::{self, CreateFlags, WatchFlags}, fs::inotify::{self, CreateFlags, WatchFlags},
@@ -17,7 +17,7 @@ use rustix::{
}; };
use zeroize::Zeroizing; use zeroize::Zeroizing;
use crate::clock::monotonic_now; use crate::monotonic_clock::monotonic_now;
const REQUESTS: &str = "/run/systemd/ask-password"; const REQUESTS: &str = "/run/systemd/ask-password";
const REQUEST_PREFIX: &str = "ask."; const REQUEST_PREFIX: &str = "ask.";
@@ -186,7 +186,7 @@ impl PasswordEntry {
} }
Some(Self { Some(Self {
request, request,
typed: passphrase::empty(), typed: passphrase_input::empty(),
sent: false, sent: false,
}) })
} }
@@ -201,7 +201,7 @@ impl PasswordEntry {
} else if self.request.echo { } else if self.request.echo {
self.typed.to_string() self.typed.to_string()
} else { } else {
passphrase::masked(&self.typed) passphrase_input::masked(&self.typed)
}; };
PasswordPrompt { PasswordPrompt {
message: &self.request.message, message: &self.request.message,
@@ -214,7 +214,7 @@ impl PasswordEntry {
if self.sent { if self.sent {
return Ok(()); 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(()); return Ok(());
}; };
self.request.answer(&submitted)?; self.request.answer(&submitted)?;
@@ -271,7 +271,7 @@ mod tests {
fn hides_what_is_typed() { fn hides_what_is_typed() {
let mut entry = PasswordEntry { let mut entry = PasswordEntry {
request: PasswordRequest::parse(Path::new("ask.x"), CRYPTSETUP_ASK).expect("parsed"), request: PasswordRequest::parse(Path::new("ask.x"), CRYPTSETUP_ASK).expect("parsed"),
typed: passphrase::empty(), typed: passphrase_input::empty(),
sent: false, sent: false,
}; };
"secret".chars().for_each(|character| { "secret".chars().for_each(|character| {
+5 -5
View File
@@ -7,16 +7,16 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use bootvine::model::{ use bootvine::boot_model::{
BootState, HANDOFF_UNIT, HOST_MILESTONES, JobKind, Phase, SHUTDOWN_MILESTONES, BootState, HANDOFF_UNIT, HOST_MILESTONES, JobKind, Phase, SHUTDOWN_MILESTONES,
}; };
use dbus::Path; use dbus::Path;
use crate::{ use crate::{
clock::monotonic_now, monotonic_clock::monotonic_now,
error::Error, switch_root::{INITRD_RELEASE, Sysroot},
sysroot::{INITRD_RELEASE, Sysroot}, systemd_bus::{Scope, Session, Signal},
systemd::{Scope, Session, Signal}, watch_error::Error,
}; };
const RECONNECT_PATIENCE: Duration = Duration::from_secs(60); const RECONNECT_PATIENCE: Duration = Duration::from_secs(60);
View File
File renamed without changes.
File renamed without changes.
+17 -17
View File
@@ -1,7 +1,7 @@
mod chrome; mod run_timeline;
mod stages; mod screen_chrome;
mod timeline; mod stage_summary;
mod tree; mod unit_tree;
use std::time::Duration; use std::time::Duration;
@@ -16,25 +16,25 @@ use ratatui::{
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
pub use self::chrome::PasswordPrompt; pub use self::screen_chrome::PasswordPrompt;
use self::{ use self::{
chrome::{FOOTER_HEIGHT, Footer, Header, PasswordPopup}, run_timeline::{RunningRun, Timeline},
stages::Stages, screen_chrome::{FOOTER_HEIGHT, Footer, Header, PasswordPopup},
timeline::{RunningRun, Timeline}, stage_summary::Stages,
tree::UnitTree, unit_tree::UnitTree,
}; };
use crate::{ use crate::{
colors::Colors, boot_model::{BootState, RowStatus, TreeRow, UnitKind, fit_to_height, fold_chains},
config::Timing, boot_origin::BootOrigin,
glyphs::Glyphs, color_scheme::Colors,
model::{BootState, RowStatus, TreeRow, UnitKind, fit_to_height, fold_chains}, config_file::Timing,
origin::BootOrigin, font_glyphs::Glyphs,
}; };
const DURATION_WIDTH: u16 = 8; const DURATION_WIDTH: u16 = 8;
const MIN_BAR_WIDTH: u16 = 12; const MIN_BAR_WIDTH: u16 = 12;
const MIN_HEIGHT_FOR_TIMELINE: 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 HEADER_HEIGHT: u16 = 1;
const BRANCH: &str = "├─ "; const BRANCH: &str = "├─ ";
const LAST_BRANCH: &str = "└─ "; const LAST_BRANCH: &str = "└─ ";
@@ -123,7 +123,7 @@ impl Widget for BootView<'_> {
colors: &self.colors.footer, colors: &self.colors.footer,
glyphs: self.glyphs, 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; && area.height >= MIN_HEIGHT_FOR_TIMELINE;
let free = area let free = area
.height .height
@@ -236,7 +236,7 @@ mod tests {
use ratatui::{Terminal, backend::TestBackend}; use ratatui::{Terminal, backend::TestBackend};
use super::*; 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); const MS: Duration = Duration::from_millis(1);
@@ -15,9 +15,9 @@ use ratatui::{
use super::{fit_width, rule, unit_count}; use super::{fit_width, rule, unit_count};
use crate::{ use crate::{
colors::TimelineColors, boot_model::{FinishedRun, MilestoneRow},
glyphs::Glyphs, color_scheme::TimelineColors,
model::{FinishedRun, MilestoneRow}, font_glyphs::Glyphs,
}; };
pub const LABEL_WIDTH: u16 = 28; pub const LABEL_WIDTH: u16 = 28;
@@ -10,10 +10,10 @@ use ratatui::{
use super::{DURATION_WIDTH, ELAPSED}; use super::{DURATION_WIDTH, ELAPSED};
use crate::{ use crate::{
colors::{FooterColors, HeaderColors, PasswordColors}, boot_model::Tally,
glyphs::Glyphs, boot_origin::BootOrigin,
model::Tally, color_scheme::{FooterColors, HeaderColors, PasswordColors},
origin::BootOrigin, font_glyphs::Glyphs,
}; };
pub const FOOTER_HEIGHT: u16 = 2; pub const FOOTER_HEIGHT: u16 = 2;
@@ -9,7 +9,7 @@ use ratatui::{
}; };
use super::{BRANCH, ELAPSED, LAST_BRANCH, unit_count}; 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 SHUTDOWN_SUCCESSOR: &str = "systemd-shutdown";
const PHASE_WIDTH: usize = 9; const PHASE_WIDTH: usize = 9;
@@ -11,9 +11,9 @@ use unicode_width::UnicodeWidthStr;
use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width}; use super::{BRANCH, DURATION_WIDTH, ELAPSED, ENDED_TRUNK, LAST_BRANCH, PASSING_TRUNK, fit_width};
use crate::{ use crate::{
colors::TreeColors, boot_model::{RowStatus, TreeRow, UnitKind},
glyphs::Glyphs, color_scheme::TreeColors,
model::{RowStatus, TreeRow, UnitKind}, font_glyphs::Glyphs,
}; };
const SPINNER: [char; 4] = ['|', '/', '-', '\\']; const SPINNER: [char; 4] = ['|', '/', '-', '\\'];
File renamed without changes.
+1 -1
View File
@@ -5,7 +5,7 @@ use jiff::fmt::serde::unsigned_duration::friendly::compact::required as friendly
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use toml::{Table, Value, de::Error as ParseError, ser::Error as SerializeError}; 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)] #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(default, deny_unknown_fields, rename_all = "kebab-case")] #[serde(default, deny_unknown_fields, rename_all = "kebab-case")]
+5 -5
View File
@@ -1,6 +1,6 @@
use std::{collections::HashSet, fs, ptr}; use std::{collections::HashSet, fs, ptr};
use bootvine::glyphs::Glyphs; use bootvine::font_glyphs::Glyphs;
use rustix::{ use rustix::{
io::Errno, io::Errno,
ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl}, ioctl::{Getter, IntegerSetter, Opcode, Updater, ioctl},
@@ -8,7 +8,7 @@ use rustix::{
termios::ttyname, termios::ttyname,
}; };
use crate::password; use crate::ask_password;
const GIO_UNIMAP: Opcode = 0x4B66; const GIO_UNIMAP: Opcode = 0x4B66;
const VT_GETSTATE: Opcode = 0x5603; const VT_GETSTATE: Opcode = 0x5603;
@@ -26,7 +26,7 @@ pub struct Console {
impl Console { impl Console {
pub fn take(for_system: bool) -> Self { 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 { if prompt_elsewhere {
eprintln!("bootvine: a password prompt is already showing, staying behind it"); 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 { 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; return false;
} }
self.foreground = ForegroundVt::take(); self.foreground = ForegroundVt::take();
@@ -194,7 +194,7 @@ impl ForegroundVt {
impl Drop for ForegroundVt { impl Drop for ForegroundVt {
fn drop(&mut self) { fn drop(&mut self) {
if password::requested() { if ask_password::requested() {
eprintln!("bootvine: leaving a password prompt to the console agent on this terminal"); eprintln!("bootvine: leaving a password prompt to the console agent on this terminal");
return; return;
} }
File renamed without changes.
+8 -8
View File
@@ -1,8 +1,8 @@
pub mod colors; pub mod boot_model;
pub mod config; pub mod boot_origin;
pub mod glyphs; pub mod boot_view;
pub mod model; pub mod color_scheme;
pub mod origin; pub mod config_file;
pub mod passphrase; pub mod font_glyphs;
pub mod script; pub mod passphrase_input;
pub mod view; pub mod scripted_boot;
+12 -12
View File
@@ -1,11 +1,11 @@
mod clock; mod ask_password;
mod console; mod boot_feed;
mod error; mod console_takeover;
mod feed; mod monotonic_clock;
mod password; mod switch_root;
mod run; mod systemd_bus;
mod sysroot; mod watch_error;
mod systemd; mod watch_loop;
use std::{ use std::{
error::Error, error::Error,
@@ -15,14 +15,14 @@ use std::{
time::Duration, 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 clap::{Parser, Subcommand, ValueEnum};
use jiff::fmt::friendly::SpanParser; use jiff::fmt::friendly::SpanParser;
use crate::{ use crate::{
feed::RootRequest, boot_feed::RootRequest,
run::{Settings, run}, systemd_bus::Scope,
systemd::Scope, watch_loop::{Settings, run},
}; };
#[derive(Parser)] #[derive(Parser)]
File renamed without changes.
File renamed without changes.
+10 -10
View File
@@ -10,13 +10,13 @@ use ratatui::{
}; };
use crate::{ use crate::{
colors::Colors, boot_model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts},
config::Timing, boot_origin::BootOrigin,
glyphs::Glyphs, boot_view::{BootView, PasswordPrompt},
model::{ActiveState, Activity, BootState, JobKind, JobResult, Phase, UnitFacts}, color_scheme::Colors,
origin::BootOrigin, config_file::Timing,
passphrase, font_glyphs::Glyphs,
view::{BootView, PasswordPrompt}, passphrase_input,
}; };
const FRAME_INTERVAL: Duration = Duration::from_millis(100); const FRAME_INTERVAL: Duration = Duration::from_millis(100);
@@ -209,7 +209,7 @@ impl Script {
fn prompt(&self, typed: &str, now: Duration) -> Option<PasswordPrompt<'static>> { fn prompt(&self, typed: &str, now: Duration) -> Option<PasswordPrompt<'static>> {
Some(PasswordPrompt { Some(PasswordPrompt {
message: self.asking()?.asks?, message: self.asking()?.asks?,
input: passphrase::masked(typed), input: passphrase_input::masked(typed),
sent: self.is_checking(now), 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 switched_root = scenario.after_switch_root.is_empty();
let mut settled_at = None; let mut settled_at = None;
let mut frame = 0; let mut frame = 0;
let mut typed = passphrase::empty(); let mut typed = passphrase_input::empty();
loop { loop {
script.advance(&mut state, now()); script.advance(&mut state, now());
if script.is_done() && !switched_root { if script.is_done() && !switched_root {
@@ -351,7 +351,7 @@ pub fn play(terminal: &mut DefaultTerminal, scenario: &Scenario) -> io::Result<(
} }
if asking if asking
&& !script.is_checking(now()) && !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()); script.answer(&submitted, now());
} }
File renamed without changes.
+2 -2
View File
@@ -4,14 +4,14 @@ use std::{
time::Duration, time::Duration,
}; };
use bootvine::model::{ActiveState, Activity, JobKind, JobResult, UnitFacts}; use bootvine::boot_model::{ActiveState, Activity, JobKind, JobResult, UnitFacts};
use dbus::{ use dbus::{
Message, MessageType, Path, Message, MessageType, Path,
arg::{AppendAll, PropMap, RefArg, Variant}, arg::{AppendAll, PropMap, RefArg, Variant},
channel::{BusType, Channel}, channel::{BusType, Channel},
}; };
use crate::error::Error; use crate::watch_error::Error;
const DESTINATION: &str = "org.freedesktop.systemd1"; const DESTINATION: &str = "org.freedesktop.systemd1";
const MANAGER_PATH: &str = "/org/freedesktop/systemd1"; const MANAGER_PATH: &str = "/org/freedesktop/systemd1";
View File
File renamed without changes.
+12 -12
View File
@@ -11,11 +11,11 @@ use std::{
}; };
use bootvine::{ use bootvine::{
colors::Colors, boot_model::{BootState, Phase},
config::Timing, boot_origin::BootOrigin,
model::{BootState, Phase}, boot_view::BootView,
origin::BootOrigin, color_scheme::Colors,
view::BootView, config_file::Timing,
}; };
use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers}; use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyModifiers};
use ratatui::{ use ratatui::{
@@ -33,13 +33,13 @@ use rustix::{
use signal_hook::{consts::SIGTERM, flag}; use signal_hook::{consts::SIGTERM, flag};
use crate::{ use crate::{
clock::monotonic_now, ask_password::{PasswordEntry, RequestWatch},
console::Console, boot_feed::{Feed, RootRequest},
error::Error, console_takeover::Console,
feed::{Feed, RootRequest}, monotonic_clock::monotonic_now,
password::{PasswordEntry, RequestWatch}, switch_root::INITRD_RELEASE,
sysroot::INITRD_RELEASE, systemd_bus::{Scope, Session},
systemd::{Scope, Session}, watch_error::Error,
}; };
const FRAME_INTERVAL: Duration = Duration::from_millis(100); const FRAME_INTERVAL: Duration = Duration::from_millis(100);