Mark various enums/structs as #[non_exhaustive] (#3981)

* Mark various enums/structs as `#[non_exhaustive]`

* Update `CHANGELOG.md`
This commit is contained in:
Jesse Braham 2025-08-25 02:47:56 -07:00 committed by GitHub
parent 6168d3487b
commit 4bfd7a28b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 8 deletions

View File

@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `esp-ieee802154` package has been folded into `esp-radio`, it's now alloc. (#3861, #3890)
- `ble`, `esp-now`, `csi`, `sniffer`, `esp-ieee802154` and `smoltcp` features and APIs marked as unstable (#3865)
- Update bt-hci version to add additional HCI commands (#3920)
- A number of enums/structs have been marked as `#[non_exhaustive]` (#3981)
- `AuthMethod`, `Protocol`, `AccessPointInfo`, `AccessPointConfiguration`, `ClientConfiguration`, `Capability`, `Configuration`, `WifiEvent`, `InternalWifiError`, `ScanTypeConfig`, and `WifiState`
### Fixed

View File

@ -149,10 +149,10 @@ use crate::binary::{
};
/// Supported Wi-Fi authentication methods.
#[derive(EnumSetType, Debug, PartialOrd)]
#[derive(Debug, Default, PartialOrd, EnumSetType)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Default)]
#[non_exhaustive]
pub enum AuthMethod {
/// No authentication (open network).
None,
@ -184,10 +184,10 @@ pub enum AuthMethod {
}
/// Supported Wi-Fi protocols.
#[derive(EnumSetType, Debug, PartialOrd)]
#[derive(Debug, Default, PartialOrd, EnumSetType)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Default)]
#[non_exhaustive]
pub enum Protocol {
/// 802.11b protocol.
P802D11B,
@ -274,6 +274,7 @@ impl defmt::Format for Country {
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[non_exhaustive]
pub struct AccessPointInfo {
/// The SSID of the access point.
// TODO: we can use the `alloc` feature once we have `defmt` 1.0.2
@ -302,6 +303,7 @@ pub struct AccessPointInfo {
/// Configuration for a Wi-Fi access point.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[non_exhaustive]
pub struct AccessPointConfiguration {
/// The SSID of the access point.
pub ssid: String,
@ -419,6 +421,7 @@ impl defmt::Format for AccessPointConfiguration {
/// Client configuration for a Wi-Fi connection.
#[derive(Clone, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[non_exhaustive]
pub struct ClientConfiguration {
/// The SSID of the Wi-Fi network.
pub ssid: String,
@ -713,6 +716,7 @@ impl Default for EapClientConfiguration {
#[derive(EnumSetType, Debug, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[non_exhaustive]
pub enum Capability {
/// The device operates as a client, connecting to an existing network.
Client,
@ -727,10 +731,11 @@ pub enum Capability {
}
/// Configuration of Wi-Fi operation mode.
#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[allow(clippy::large_enum_variant)]
#[non_exhaustive]
pub enum Configuration {
/// No configuration (default).
#[default]
@ -1204,9 +1209,10 @@ pub enum WifiError {
}
/// Events generated by the WiFi driver.
#[repr(i32)]
#[derive(Debug, FromPrimitive, EnumSetType)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
#[repr(i32)]
pub enum WifiEvent {
/// Wi-Fi is ready for operation.
WifiReady = 0,
@ -1311,9 +1317,10 @@ pub enum WifiEvent {
}
/// Error originating from the underlying drivers
#[repr(i32)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, FromPrimitive)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
#[repr(i32)]
pub enum InternalWifiError {
/// Out of memory
NoMem = 0x101,
@ -1589,7 +1596,8 @@ pub(crate) fn wifi_start() -> Result<(), WifiError> {
/// |--------------------------------------|------------|-------------|
/// | **Power consumption** | High | Low |
/// | **Time required (typical behavior)** | Low | High |
#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum ScanTypeConfig {
/// Active scan with min and max scan time per channel. This is the default
/// and recommended if you are unsure.

View File

@ -8,6 +8,7 @@ use super::WifiEvent;
#[atomic_enum]
#[derive(PartialEq, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum WifiState {
/// Station started.
StaStarted,