mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2026-05-03 11:41:56 +00:00
use anyhow for errors
This commit is contained in:
18
src/mock.rs
18
src/mock.rs
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user