From 396136e4afbbd3675a9f92170c9159e5a6e73923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Mon, 6 Nov 2023 14:27:27 +0100 Subject: [PATCH] tacd: inline run() into main() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many small functions is a nice thing in general, but a three line function that is only used once seems a bit over the top. Signed-off-by: Leonard Göhrs --- src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 861b237..4847812 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,7 @@ use regulators::Regulators; use setup_mode::SetupMode; use system::System; use temperatures::Temperatures; -use ui::{message, setup_display, Display, ScreenShooter, Ui, UiResources}; +use ui::{message, setup_display, ScreenShooter, Ui, UiResources}; use usb_hub::UsbHub; use watchdog::Watchdog; use watched_tasks::WatchedTasksBuilder; @@ -171,25 +171,25 @@ async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)> Ok((ui, wtb)) } -async fn run(ui: Ui, display: Display, mut wtb: WatchedTasksBuilder) -> Result<()> { - // Start drawing the UI - ui.run(&mut wtb, display)?; - - info!("Setup complete. Handling requests"); - - wtb.watch().await -} - #[async_std::main] async fn main() -> Result<()> { env_logger::init(); // Show a splash screen very early on let display = setup_display(); + + // This allows us to expose screenshoots of the LCD screen via HTTP let screenshooter = display.screenshooter(); match init(screenshooter).await { - Ok((ui, wtb)) => run(ui, display, wtb).await, + Ok((ui, mut wtb)) => { + // Start drawing the UI + ui.run(&mut wtb, display)?; + + info!("Setup complete. Handling requests"); + + wtb.watch().await + } Err(e) => { // Display a detailed error message on stderr (and thus in the journal) ... error!("Failed to initialize tacd: {e}");