Skip to content

Commit

Permalink
Mark public enums as #[non_exhaustive] for semver compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebraham committed Jan 10, 2023
1 parent 50946ce commit 59d62c1
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion espflash/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const MEM_END_TIMEOUT: Duration = Duration::from_millis(50);
const SYNC_TIMEOUT: Duration = Duration::from_millis(100);

#[derive(Copy, Clone, Debug, Display)]
#[repr(u8)]
#[non_exhaustive]
#[repr(u8)]
pub enum CommandType {
Unknown = 0,
FlashBegin = 0x02,
Expand Down Expand Up @@ -70,6 +70,7 @@ impl CommandType {
}

#[derive(Copy, Clone, Debug)]
#[non_exhaustive]
pub enum Command<'a> {
FlashBegin {
size: u32,
Expand Down
3 changes: 3 additions & 0 deletions espflash/src/flasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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)]
#[non_exhaustive]
#[repr(u8)]
pub enum FlashFrequency {
/// 12 MHz
Expand Down Expand Up @@ -70,6 +71,7 @@ pub enum FlashFrequency {
/// Supported flash modes
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Copy, Clone, Debug, Default, EnumVariantNames)]
#[non_exhaustive]
#[strum(serialize_all = "lowercase")]
pub enum FlashMode {
/// Quad I/O (4 pins used for address & data)
Expand All @@ -88,6 +90,7 @@ 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)]
#[non_exhaustive]
#[repr(u8)]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
pub enum FlashSize {
Expand Down
1 change: 1 addition & 0 deletions espflash/src/image_format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub trait ImageFormat<'a>: Send {
#[derive(
Debug, Copy, Clone, Eq, PartialEq, Display, IntoStaticStr, EnumVariantNames, Deserialize,
)]
#[non_exhaustive]
#[strum(serialize_all = "kebab-case")]
#[serde(rename_all = "kebab-case")]
pub enum ImageFormatKind {
Expand Down
1 change: 1 addition & 0 deletions espflash/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::error::Error;

/// Errors relating to the configuration of a serial port
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum SerialConfigError {
#[cfg(feature = "raspberry")]
#[error("You need to specify both DTR and RTS pins when using an internal UART peripheral")]
Expand Down
1 change: 1 addition & 0 deletions espflash/src/targets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod flash_target;
/// Enumeration of all supported devices
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display, EnumIter, EnumVariantNames)]
#[non_exhaustive]
#[strum(serialize_all = "lowercase")]
pub enum Chip {
/// ESP32
Expand Down

0 comments on commit 59d62c1

Please sign in to comment.