fix tread safty issues by annotating Box Traits correctly

This commit is contained in:
2025-06-19 18:36:48 +02:00
parent e2cbf9618e
commit 69077239a5
5 changed files with 16 additions and 16 deletions

View File

@@ -93,7 +93,7 @@ pub enum Sensor {
pub struct PlantHal {}
pub struct HAL<'a> {
pub board_hal: Box<dyn BoardInteraction<'a> + Sync + Send>,
pub board_hal: Box<dyn BoardInteraction<'a> + Send>,
}
#[derive(Serialize, Deserialize, PartialEq, Debug)]
@@ -116,7 +116,7 @@ impl Default for BackupHeader {
pub trait BoardInteraction<'a> {
fn get_esp(&mut self) -> &mut ESP<'a>;
fn get_config(&mut self) -> &PlantControllerConfig;
fn get_battery_monitor(&mut self) -> &mut Box<dyn BatteryInteraction>;
fn get_battery_monitor(&mut self) -> &mut Box<dyn BatteryInteraction + Send>;
fn set_charge_indicator(&mut self, charging: bool) -> Result<()>;
fn deep_sleep(&mut self, duration_in_ms: u64) -> !;
fn get_backup_info(&mut self) -> Result<BackupHeader>;
@@ -304,9 +304,9 @@ impl PlantHal {
}
BatteryBoardVersion::WchI2cSlave => BatteryMonitor::WchI2cSlave {},
};
let battery_interaction = Box::new(battery_monitor) as Box<dyn BatteryInteraction>;
let battery_interaction = Box::new(battery_monitor) as Box<dyn BatteryInteraction + Send>;
let board_hal: Box<dyn BoardInteraction> = match config.hardware.board {
let board_hal: Box<dyn BoardInteraction + Send> = match config.hardware.board {
BoardVersion::INITIAL => {
initial_hal::create_initial_board(free_pins, fs_mount_error, config, esp)?
}