From d397a6d5b434b74299b3054dfab837cc90568fb9 Mon Sep 17 00:00:00 2001 From: Chase Naples Date: Fri, 19 Sep 2025 02:41:58 -0400 Subject: [PATCH] feat: mark selected public enums as #[non_exhaustive] (part of #1016) - lambda-events (dynamodb): StreamViewType, StreamStatus, SharedIteratorType, OperationType, KeyType - lambda-http: PayloadError, JsonPayloadError, FormUrlEncodedPayloadError These enums are likely to grow; marking them non_exhaustive helps avoid semver hazards for downstream consumers who pattern-match exhaustively. --- lambda-events/src/event/dynamodb/mod.rs | 5 +++++ lambda-http/src/ext/request.rs | 3 +++ 2 files changed, 8 insertions(+) diff --git a/lambda-events/src/event/dynamodb/mod.rs b/lambda-events/src/event/dynamodb/mod.rs index 8b8041c0..316768dc 100644 --- a/lambda-events/src/event/dynamodb/mod.rs +++ b/lambda-events/src/event/dynamodb/mod.rs @@ -13,6 +13,7 @@ use std::fmt; mod attributes; #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] +#[non_exhaustive] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum StreamViewType { NewImage, @@ -35,6 +36,7 @@ impl fmt::Display for StreamViewType { } #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] +#[non_exhaustive] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum StreamStatus { Enabling, @@ -57,6 +59,7 @@ impl fmt::Display for StreamStatus { } #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] +#[non_exhaustive] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum SharedIteratorType { TrimHorizon, @@ -79,6 +82,7 @@ impl fmt::Display for SharedIteratorType { } #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] +#[non_exhaustive] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum OperationType { #[default] @@ -99,6 +103,7 @@ impl fmt::Display for OperationType { } #[derive(Clone, Default, Debug, Deserialize, Eq, PartialEq, Serialize)] +#[non_exhaustive] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum KeyType { #[default] diff --git a/lambda-http/src/ext/request.rs b/lambda-http/src/ext/request.rs index c56518f6..dc14532e 100644 --- a/lambda-http/src/ext/request.rs +++ b/lambda-http/src/ext/request.rs @@ -13,6 +13,7 @@ use crate::Body; /// /// Returned by [`RequestPayloadExt::payload()`] #[derive(Debug)] +#[non_exhaustive] pub enum PayloadError { /// Returned when `application/json` bodies fail to deserialize a payload Json(serde_json::Error), @@ -22,6 +23,7 @@ pub enum PayloadError { /// Indicates a problem processing a JSON payload. #[derive(Debug)] +#[non_exhaustive] pub enum JsonPayloadError { /// Problem deserializing a JSON payload. Parsing(serde_json::Error), @@ -29,6 +31,7 @@ pub enum JsonPayloadError { /// Indicates a problem processing an x-www-form-urlencoded payload. #[derive(Debug)] +#[non_exhaustive] pub enum FormUrlEncodedPayloadError { /// Problem deserializing an x-www-form-urlencoded payload. Parsing(SerdeError),