Migrate serialization from Bincode to Postcard
- Replaced Bincode with Postcard for serialization/deserialization across configs and save operations. - Simplified struct derives by removing `bincode`-specific traits. - Updated `Cargo.toml` and `Cargo.lock` to include `postcard` and dependencies. - Added padding stripping for deserialization and improved error handling. - Adjusted serialization logic in `savegame_manager.rs` and related modules.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
use crate::hal::PLANT_COUNT;
|
||||
use crate::plant_state::PlantWateringMode;
|
||||
use alloc::string::{String, ToString};
|
||||
use bincode::{Decode, Encode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct NetworkConfig {
|
||||
pub ap_ssid: String,
|
||||
@@ -31,7 +30,7 @@ impl Default for NetworkConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct NightLampConfig {
|
||||
pub enabled: bool,
|
||||
@@ -54,7 +53,7 @@ impl Default for NightLampConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct TankConfig {
|
||||
pub tank_sensor_enabled: bool,
|
||||
@@ -79,20 +78,20 @@ impl Default for TankConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
|
||||
pub enum BatteryBoardVersion {
|
||||
#[default]
|
||||
Disabled,
|
||||
WchI2cSlave,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
|
||||
pub enum BoardVersion {
|
||||
Initial,
|
||||
#[default]
|
||||
V4,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
|
||||
pub struct BoardHardware {
|
||||
pub board: BoardVersion,
|
||||
pub battery: BatteryBoardVersion,
|
||||
@@ -100,7 +99,7 @@ pub struct BoardHardware {
|
||||
pub pump_corrosion_protection: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
|
||||
#[serde(default)]
|
||||
pub struct PlantControllerConfig {
|
||||
pub hardware: BoardHardware,
|
||||
@@ -111,7 +110,7 @@ pub struct PlantControllerConfig {
|
||||
pub timezone: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Encode, Decode)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||
#[serde(default)]
|
||||
pub struct PlantConfig {
|
||||
pub mode: PlantWateringMode,
|
||||
|
||||
Reference in New Issue
Block a user