diff --git a/CHANGELOG.md b/CHANGELOG.md index ee3b4d81..b49991ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add --confirm-port argument to flash command (#455) - Add --chip argument for flash and write-bin commands (#514) - Add --partition-table-offset argument for specifying the partition table offset (#516) +- Add `Serialize` and `Deserialize` to `FlashFrequency`, `FlashMode` and `FlashSize`. (#528) ### Fixed diff --git a/espflash/src/flasher/mod.rs b/espflash/src/flasher/mod.rs index 0b22bb9b..d9ac4bf5 100644 --- a/espflash/src/flasher/mod.rs +++ b/espflash/src/flasher/mod.rs @@ -9,6 +9,7 @@ use std::{borrow::Cow, str::FromStr, thread::sleep}; use bytemuck::{Pod, Zeroable, __core::time::Duration}; use esp_idf_part::PartitionTable; use log::{debug, info, warn}; +use serde::{Deserialize, Serialize}; use serialport::UsbPortInfo; use strum::{Display, EnumIter, EnumVariantNames}; @@ -39,7 +40,19 @@ const FLASH_SECTORS_PER_BLOCK: usize = FLASH_SECTOR_SIZE / FLASH_BLOCK_SIZE; /// /// Note that not all frequencies are supported by each target device. #[cfg_attr(feature = "cli", derive(clap::ValueEnum))] -#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, Display, EnumVariantNames)] +#[derive( + Debug, + Default, + Clone, + Copy, + Hash, + PartialEq, + Eq, + Display, + EnumVariantNames, + Serialize, + Deserialize, +)] #[non_exhaustive] #[repr(u8)] pub enum FlashFrequency { @@ -85,7 +98,7 @@ impl FlashFrequency { /// Supported flash modes #[cfg_attr(feature = "cli", derive(clap::ValueEnum))] -#[derive(Copy, Clone, Debug, Default, EnumVariantNames)] +#[derive(Copy, Clone, Debug, Default, EnumVariantNames, Serialize, Deserialize)] #[non_exhaustive] #[strum(serialize_all = "lowercase")] pub enum FlashMode { @@ -104,7 +117,19 @@ pub enum FlashMode { /// /// Note that not all sizes are supported by each target device. #[cfg_attr(feature = "cli", derive(clap::ValueEnum))] -#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Display, EnumVariantNames, EnumIter)] +#[derive( + Clone, + Copy, + Debug, + Default, + Eq, + PartialEq, + Display, + EnumVariantNames, + EnumIter, + Serialize, + Deserialize, +)] #[non_exhaustive] #[repr(u8)] #[strum(serialize_all = "SCREAMING_SNAKE_CASE")]