use anyhow for errors

This commit is contained in:
2025-06-02 15:12:59 +02:00
parent efd096a149
commit 4781570f8e
11 changed files with 72 additions and 120 deletions

View File

@@ -1,6 +1,6 @@
use std::{error::Error, time::Duration};
use anyhow::Result;
use log::debug;
use std::time::Duration;
use tokio::time::sleep;
use crate::hardware::{Buzzer, Hotspot, StatusLed};
@@ -8,11 +8,7 @@ use crate::hardware::{Buzzer, Hotspot, StatusLed};
pub struct MockBuzzer {}
impl Buzzer for MockBuzzer {
async fn modulated_tone(
&mut self,
frequency_hz: f64,
duration: Duration,
) -> Result<(), Box<dyn Error>> {
async fn modulated_tone(&mut self, frequency_hz: f64, duration: Duration) -> Result<()> {
debug!("MockBuzzer: modulte tone: {frequency_hz} Hz");
sleep(duration).await;
Ok(())
@@ -22,12 +18,12 @@ impl Buzzer for MockBuzzer {
pub struct MockLed {}
impl StatusLed for MockLed {
fn turn_off(&mut self) -> Result<(), Box<dyn std::error::Error>> {
fn turn_off(&mut self) -> Result<()> {
debug!("Turn mock LED off");
Ok(())
}
fn turn_on(&mut self, color: rgb::RGB8) -> Result<(), Box<dyn std::error::Error>> {
fn turn_on(&mut self, color: rgb::RGB8) -> Result<()> {
debug!("Turn mock LED on to: {color}");
Ok(())
}
@@ -36,12 +32,12 @@ impl StatusLed for MockLed {
pub struct MockHotspot {}
impl Hotspot for MockHotspot {
async fn enable_hotspot(&self) -> Result<(), crate::hotspot::HotspotError> {
async fn enable_hotspot(&self) -> Result<()> {
debug!("Mockhotspot: Enable hotspot");
Ok(())
}
async fn disable_hotspot(&self) -> Result<(), crate::hotspot::HotspotError> {
async fn disable_hotspot(&self) -> Result<()> {
debug!("Mockhotspot: Disable hotspot");
Ok(())
}