Skip to content

Commit 888c414

Browse files
author
Mara Pindaru
committed
feat(lambda-events): mark public structs/enums as #[non_exhaustive]
1 parent 3c8a8be commit 888c414

File tree

75 files changed

+427
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+427
-6
lines changed

lambda-events/src/encodings/http.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use std::{borrow::Cow, mem::take, ops::Deref, pin::Pin, task::Poll};
6060
///
6161
/// For more information about API Gateway's body types,
6262
/// refer to [this documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html).
63+
#[non_exhaustive]
6364
#[derive(Debug, Default, Eq, PartialEq)]
6465
pub enum Body {
6566
/// An empty body

lambda-events/src/encodings/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use self::http::*;
1717
pub type Error = Box<dyn std::error::Error + Send + Sync>;
1818

1919
/// Binary data encoded in base64.
20+
#[non_exhaustive]
2021
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
2122
pub struct Base64Data(
2223
#[serde(deserialize_with = "deserialize_base64")]

lambda-events/src/encodings/time.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use serde::{
77
use std::ops::{Deref, DerefMut};
88

99
/// Timestamp with millisecond precision.
10+
#[non_exhaustive]
1011
#[derive(Clone, Default, Debug, Deserialize, Eq, PartialEq, Serialize)]
1112
pub struct MillisecondTimestamp(
1213
#[serde(deserialize_with = "deserialize_milliseconds")]
@@ -29,6 +30,7 @@ impl DerefMut for MillisecondTimestamp {
2930
}
3031

3132
/// Timestamp with second precision.
33+
#[non_exhaustive]
3234
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
3335
pub struct SecondTimestamp(
3436
#[serde(deserialize_with = "deserialize_seconds")]
@@ -51,6 +53,7 @@ impl DerefMut for SecondTimestamp {
5153
}
5254

5355
/// Duration with second precision.
56+
#[non_exhaustive]
5457
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
5558
pub struct SecondDuration(
5659
#[serde(deserialize_with = "deserialize_duration_seconds")]
@@ -73,6 +76,7 @@ impl DerefMut for SecondDuration {
7376
}
7477

7578
/// Duration with minute precision.
79+
#[non_exhaustive]
7680
#[derive(Clone, Default, Debug, Deserialize, Eq, PartialEq, Serialize)]
7781
pub struct MinuteDuration(
7882
#[serde(deserialize_with = "deserialize_duration_minutes")]

lambda-events/src/event/activemq/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::collections::HashMap;
55

66
use crate::custom_serde::deserialize_lambda_map;
77

8+
#[non_exhaustive]
89
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
910
#[serde(rename_all = "camelCase")]
1011
pub struct ActiveMqEvent {
@@ -22,6 +23,7 @@ pub struct ActiveMqEvent {
2223
pub other: serde_json::Map<String, Value>,
2324
}
2425

26+
#[non_exhaustive]
2527
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
2628
#[serde(rename_all = "camelCase")]
2729
pub struct ActiveMqMessage {
@@ -59,6 +61,7 @@ pub struct ActiveMqMessage {
5961
pub other: serde_json::Map<String, Value>,
6062
}
6163

64+
#[non_exhaustive]
6265
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
6366
#[serde(rename_all = "camelCase")]
6467
pub struct ActiveMqDestination {

lambda-events/src/event/alb/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
1212
use serde_json::Value;
1313

1414
/// `AlbTargetGroupRequest` contains data originating from the ALB Lambda target group integration
15+
#[non_exhaustive]
1516
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
1617
#[serde(rename_all = "camelCase")]
1718
pub struct AlbTargetGroupRequest {
@@ -44,6 +45,7 @@ pub struct AlbTargetGroupRequest {
4445
}
4546

4647
/// `AlbTargetGroupRequestContext` contains the information to identify the load balancer invoking the lambda
48+
#[non_exhaustive]
4749
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
4850
#[serde(rename_all = "camelCase")]
4951
pub struct AlbTargetGroupRequestContext {
@@ -58,6 +60,7 @@ pub struct AlbTargetGroupRequestContext {
5860
}
5961

6062
/// `ElbContext` contains the information to identify the ARN invoking the lambda
63+
#[non_exhaustive]
6164
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
6265
#[serde(rename_all = "camelCase")]
6366
pub struct ElbContext {

lambda-events/src/event/apigw/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use serde_json::Value;
1313
use std::collections::HashMap;
1414

1515
/// `ApiGatewayProxyRequest` contains data coming from the API Gateway proxy
16+
#[non_exhaustive]
1617
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
1718
#[serde(rename_all = "camelCase")]
1819
pub struct ApiGatewayProxyRequest {
@@ -82,6 +83,7 @@ pub struct ApiGatewayProxyResponse {
8283

8384
/// `ApiGatewayProxyRequestContext` contains the information to identify the AWS account and resources invoking the
8485
/// Lambda function. It also includes Cognito identity information for the caller.
86+
#[non_exhaustive]
8587
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
8688
#[serde(rename_all = "camelCase")]
8789
pub struct ApiGatewayProxyRequestContext {
@@ -134,6 +136,7 @@ pub struct ApiGatewayProxyRequestContext {
134136
}
135137

136138
/// `ApiGatewayV2httpRequest` contains data coming from the new HTTP API Gateway
139+
#[non_exhaustive]
137140
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
138141
#[serde(rename_all = "camelCase")]
139142
pub struct ApiGatewayV2httpRequest {
@@ -191,6 +194,7 @@ pub struct ApiGatewayV2httpRequest {
191194
}
192195

193196
/// `ApiGatewayV2httpRequestContext` contains the information to identify the AWS account and resources invoking the Lambda function.
197+
#[non_exhaustive]
194198
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
195199
#[serde(rename_all = "camelCase")]
196200
pub struct ApiGatewayV2httpRequestContext {
@@ -230,6 +234,7 @@ pub struct ApiGatewayV2httpRequestContext {
230234
}
231235

232236
/// `ApiGatewayRequestAuthorizer` contains authorizer information for the request context.
237+
#[non_exhaustive]
233238
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
234239
pub struct ApiGatewayRequestAuthorizer {
235240
#[serde(skip_serializing_if = "Option::is_none")]
@@ -254,6 +259,7 @@ pub struct ApiGatewayRequestAuthorizer {
254259
}
255260

256261
/// `ApiGatewayRequestAuthorizerJwtDescription` contains JWT authorizer information for the request context.
262+
#[non_exhaustive]
257263
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
258264
#[serde(rename_all = "camelCase")]
259265
pub struct ApiGatewayRequestAuthorizerJwtDescription {
@@ -272,6 +278,7 @@ pub struct ApiGatewayRequestAuthorizerJwtDescription {
272278
}
273279

274280
/// `ApiGatewayRequestAuthorizerIamDescription` contains IAM information for the request context.
281+
#[non_exhaustive]
275282
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
276283
#[serde(rename_all = "camelCase")]
277284
pub struct ApiGatewayRequestAuthorizerIamDescription {
@@ -299,6 +306,7 @@ pub struct ApiGatewayRequestAuthorizerIamDescription {
299306
}
300307

301308
/// `ApiGatewayRequestAuthorizerCognitoIdentity` contains Cognito identity information for the request context.
309+
#[non_exhaustive]
302310
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
303311
#[serde(rename_all = "camelCase")]
304312
pub struct ApiGatewayRequestAuthorizerCognitoIdentity {
@@ -317,6 +325,7 @@ pub struct ApiGatewayRequestAuthorizerCognitoIdentity {
317325
}
318326

319327
/// `ApiGatewayV2httpRequestContextHttpDescription` contains HTTP information for the request context.
328+
#[non_exhaustive]
320329
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
321330
#[serde(rename_all = "camelCase")]
322331
pub struct ApiGatewayV2httpRequestContextHttpDescription {
@@ -365,6 +374,7 @@ pub struct ApiGatewayV2httpResponse {
365374
}
366375

367376
/// `ApiGatewayRequestIdentity` contains identity information for the request caller.
377+
#[non_exhaustive]
368378
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
369379
#[serde(rename_all = "camelCase")]
370380
pub struct ApiGatewayRequestIdentity {
@@ -405,6 +415,7 @@ pub struct ApiGatewayRequestIdentity {
405415
}
406416

407417
/// `ApiGatewayWebsocketProxyRequest` contains data coming from the API Gateway proxy
418+
#[non_exhaustive]
408419
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
409420
#[serde(rename_all = "camelCase")]
410421
pub struct ApiGatewayWebsocketProxyRequest {
@@ -453,6 +464,7 @@ pub struct ApiGatewayWebsocketProxyRequest {
453464
/// `ApiGatewayWebsocketProxyRequestContext` contains the information to identify
454465
/// the AWS account and resources invoking the Lambda function. It also includes
455466
/// Cognito identity information for the caller.
467+
#[non_exhaustive]
456468
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
457469
#[serde(rename_all = "camelCase")]
458470
pub struct ApiGatewayWebsocketProxyRequestContext {
@@ -522,6 +534,7 @@ pub struct ApiGatewayWebsocketProxyRequestContext {
522534
}
523535

524536
/// `ApiGatewayCustomAuthorizerRequestTypeRequestIdentity` contains identity information for the request caller including certificate information if using mTLS.
537+
#[non_exhaustive]
525538
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
526539
#[serde(rename_all = "camelCase")]
527540
pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentity {
@@ -543,6 +556,7 @@ pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentity {
543556
}
544557

545558
/// `ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCert` contains certificate information for the request caller if using mTLS.
559+
#[non_exhaustive]
546560
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
547561
#[serde(rename_all = "camelCase")]
548562
pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCert {
@@ -567,6 +581,7 @@ pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCert {
567581
}
568582

569583
/// `ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCertValidity` contains certificate validity information for the request caller if using mTLS.
584+
#[non_exhaustive]
570585
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
571586
#[serde(rename_all = "camelCase")]
572587
pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCertValidity {
@@ -584,6 +599,7 @@ pub struct ApiGatewayCustomAuthorizerRequestTypeRequestIdentityClientCertValidit
584599
}
585600

586601
/// `ApiGatewayV2httpRequestContextAuthentication` contains authentication context information for the request caller including client certificate information if using mTLS.
602+
#[non_exhaustive]
587603
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
588604
#[serde(rename_all = "camelCase")]
589605
pub struct ApiGatewayV2httpRequestContextAuthentication {
@@ -599,6 +615,7 @@ pub struct ApiGatewayV2httpRequestContextAuthentication {
599615
}
600616

601617
/// `ApiGatewayV2httpRequestContextAuthenticationClientCert` contains client certificate information for the request caller if using mTLS.
618+
#[non_exhaustive]
602619
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
603620
#[serde(rename_all = "camelCase")]
604621
pub struct ApiGatewayV2httpRequestContextAuthenticationClientCert {
@@ -623,6 +640,7 @@ pub struct ApiGatewayV2httpRequestContextAuthenticationClientCert {
623640
}
624641

625642
/// `ApiGatewayV2httpRequestContextAuthenticationClientCertValidity` contains client certificate validity information for the request caller if using mTLS.
643+
#[non_exhaustive]
626644
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
627645
#[serde(rename_all = "camelCase")]
628646
pub struct ApiGatewayV2httpRequestContextAuthenticationClientCertValidity {
@@ -639,6 +657,7 @@ pub struct ApiGatewayV2httpRequestContextAuthenticationClientCertValidity {
639657
pub other: serde_json::Map<String, Value>,
640658
}
641659

660+
#[non_exhaustive]
642661
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
643662
#[serde(rename_all = "camelCase")]
644663
pub struct ApiGatewayV2CustomAuthorizerV1RequestTypeRequestContext {
@@ -669,6 +688,7 @@ pub struct ApiGatewayV2CustomAuthorizerV1RequestTypeRequestContext {
669688
pub other: serde_json::Map<String, Value>,
670689
}
671690

691+
#[non_exhaustive]
672692
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
673693
#[serde(rename_all = "camelCase")]
674694
pub struct ApiGatewayV2CustomAuthorizerV1Request {
@@ -711,6 +731,7 @@ pub struct ApiGatewayV2CustomAuthorizerV1Request {
711731
pub other: serde_json::Map<String, Value>,
712732
}
713733

734+
#[non_exhaustive]
714735
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
715736
#[serde(rename_all = "camelCase")]
716737
pub struct ApiGatewayV2CustomAuthorizerV2Request {
@@ -755,6 +776,7 @@ pub struct ApiGatewayV2CustomAuthorizerV2Request {
755776

756777
/// `ApiGatewayCustomAuthorizerContext` represents the expected format of an API Gateway custom authorizer response.
757778
/// Deprecated. Code should be updated to use the Authorizer map from APIGatewayRequestIdentity. Ex: Authorizer["principalId"]
779+
#[non_exhaustive]
758780
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
759781
#[serde(rename_all = "camelCase")]
760782
pub struct ApiGatewayCustomAuthorizerContext {
@@ -773,6 +795,7 @@ pub struct ApiGatewayCustomAuthorizerContext {
773795
}
774796

775797
/// `ApiGatewayCustomAuthorizerRequestTypeRequestContext` represents the expected format of an API Gateway custom authorizer response.
798+
#[non_exhaustive]
776799
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
777800
#[serde(rename_all = "camelCase")]
778801
pub struct ApiGatewayCustomAuthorizerRequestTypeRequestContext {
@@ -808,6 +831,7 @@ pub struct ApiGatewayCustomAuthorizerRequestTypeRequestContext {
808831
}
809832

810833
/// `ApiGatewayCustomAuthorizerRequest` contains data coming in to a custom API Gateway authorizer function.
834+
#[non_exhaustive]
811835
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
812836
#[serde(rename_all = "camelCase")]
813837
pub struct ApiGatewayCustomAuthorizerRequest {
@@ -828,6 +852,7 @@ pub struct ApiGatewayCustomAuthorizerRequest {
828852
}
829853

830854
/// `ApiGatewayCustomAuthorizerRequestTypeRequest` contains data coming in to a custom API Gateway authorizer function.
855+
#[non_exhaustive]
831856
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
832857
#[serde(rename_all = "camelCase")]
833858
pub struct ApiGatewayCustomAuthorizerRequestTypeRequest {
@@ -895,6 +920,7 @@ where
895920
}
896921

897922
/// `ApiGatewayV2CustomAuthorizerSimpleResponse` represents the simple format of an API Gateway V2 authorization response.
923+
#[non_exhaustive]
898924
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
899925
#[serde(rename_all = "camelCase")]
900926
pub struct ApiGatewayV2CustomAuthorizerSimpleResponse<T1 = Value>
@@ -914,6 +940,7 @@ where
914940
pub other: serde_json::Map<String, Value>,
915941
}
916942

943+
#[non_exhaustive]
917944
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
918945
#[serde(rename_all = "camelCase")]
919946
pub struct ApiGatewayV2CustomAuthorizerIamPolicyResponse<T1 = Value>

0 commit comments

Comments
 (0)