Skip to content

Commit ba49cbb

Browse files
bugadaniSergioGasquez
authored andcommitted
Add serde derives to flash params
1 parent 71d7a63 commit ba49cbb

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Add --confirm-port argument to flash command (#455)
1616
- Add --chip argument for flash and write-bin commands (#514)
1717
- Add --partition-table-offset argument for specifying the partition table offset (#516)
18+
- Add `Serialize` and `Deserialize` to `FlashFrequency`, `FlashMode` and `FlashSize`. (#528)
1819

1920
### Fixed
2021

Diff for: espflash/src/flasher/mod.rs

+28-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{borrow::Cow, str::FromStr, thread::sleep};
99
use bytemuck::{Pod, Zeroable, __core::time::Duration};
1010
use esp_idf_part::PartitionTable;
1111
use log::{debug, info, warn};
12+
use serde::{Deserialize, Serialize};
1213
use serialport::UsbPortInfo;
1314
use strum::{Display, EnumIter, EnumVariantNames};
1415

@@ -39,7 +40,19 @@ const FLASH_SECTORS_PER_BLOCK: usize = FLASH_SECTOR_SIZE / FLASH_BLOCK_SIZE;
3940
///
4041
/// Note that not all frequencies are supported by each target device.
4142
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
42-
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, Display, EnumVariantNames)]
43+
#[derive(
44+
Debug,
45+
Default,
46+
Clone,
47+
Copy,
48+
Hash,
49+
PartialEq,
50+
Eq,
51+
Display,
52+
EnumVariantNames,
53+
Serialize,
54+
Deserialize,
55+
)]
4356
#[non_exhaustive]
4457
#[repr(u8)]
4558
pub enum FlashFrequency {
@@ -85,7 +98,7 @@ impl FlashFrequency {
8598

8699
/// Supported flash modes
87100
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
88-
#[derive(Copy, Clone, Debug, Default, EnumVariantNames)]
101+
#[derive(Copy, Clone, Debug, Default, EnumVariantNames, Serialize, Deserialize)]
89102
#[non_exhaustive]
90103
#[strum(serialize_all = "lowercase")]
91104
pub enum FlashMode {
@@ -104,7 +117,19 @@ pub enum FlashMode {
104117
///
105118
/// Note that not all sizes are supported by each target device.
106119
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
107-
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Display, EnumVariantNames, EnumIter)]
120+
#[derive(
121+
Clone,
122+
Copy,
123+
Debug,
124+
Default,
125+
Eq,
126+
PartialEq,
127+
Display,
128+
EnumVariantNames,
129+
EnumIter,
130+
Serialize,
131+
Deserialize,
132+
)]
108133
#[non_exhaustive]
109134
#[repr(u8)]
110135
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]

0 commit comments

Comments
 (0)