Skip to content

Commit 396136e

Browse files
committed
tacd: inline run() into main()
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 <l.goehrs@pengutronix.de>
1 parent c823515 commit 396136e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use regulators::Regulators;
5252
use setup_mode::SetupMode;
5353
use system::System;
5454
use temperatures::Temperatures;
55-
use ui::{message, setup_display, Display, ScreenShooter, Ui, UiResources};
55+
use ui::{message, setup_display, ScreenShooter, Ui, UiResources};
5656
use usb_hub::UsbHub;
5757
use watchdog::Watchdog;
5858
use watched_tasks::WatchedTasksBuilder;
@@ -171,25 +171,25 @@ async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)>
171171
Ok((ui, wtb))
172172
}
173173

174-
async fn run(ui: Ui, display: Display, mut wtb: WatchedTasksBuilder) -> Result<()> {
175-
// Start drawing the UI
176-
ui.run(&mut wtb, display)?;
177-
178-
info!("Setup complete. Handling requests");
179-
180-
wtb.watch().await
181-
}
182-
183174
#[async_std::main]
184175
async fn main() -> Result<()> {
185176
env_logger::init();
186177

187178
// Show a splash screen very early on
188179
let display = setup_display();
180+
181+
// This allows us to expose screenshoots of the LCD screen via HTTP
189182
let screenshooter = display.screenshooter();
190183

191184
match init(screenshooter).await {
192-
Ok((ui, wtb)) => run(ui, display, wtb).await,
185+
Ok((ui, mut wtb)) => {
186+
// Start drawing the UI
187+
ui.run(&mut wtb, display)?;
188+
189+
info!("Setup complete. Handling requests");
190+
191+
wtb.watch().await
192+
}
193193
Err(e) => {
194194
// Display a detailed error message on stderr (and thus in the journal) ...
195195
error!("Failed to initialize tacd: {e}");

0 commit comments

Comments
 (0)