Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lambda-events/src/encodings/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,39 +264,39 @@ mod tests {
fn from_str() {
match Body::from(String::from("foo").as_str()) {
Body::Text(_) => (),
not => panic!("expected Body::Text(...) got {:?}", not),
not => panic!("expected Body::Text(...) got {not:?}"),
}
}

#[test]
fn from_string() {
match Body::from(String::from("foo")) {
Body::Text(_) => (),
not => panic!("expected Body::Text(...) got {:?}", not),
not => panic!("expected Body::Text(...) got {not:?}"),
}
}

#[test]
fn from_cow_str() {
match Body::from(Cow::from("foo")) {
Body::Text(_) => (),
not => panic!("expected Body::Text(...) got {:?}", not),
not => panic!("expected Body::Text(...) got {not:?}"),
}
}

#[test]
fn from_cow_bytes() {
match Body::from(Cow::from("foo".as_bytes())) {
Body::Binary(_) => (),
not => panic!("expected Body::Binary(...) got {:?}", not),
not => panic!("expected Body::Binary(...) got {not:?}"),
}
}

#[test]
fn from_bytes() {
match Body::from("foo".as_bytes()) {
Body::Binary(_) => (),
not => panic!("expected Body::Binary(...) got {:?}", not),
not => panic!("expected Body::Binary(...) got {not:?}"),
}
}

Expand Down Expand Up @@ -325,12 +325,12 @@ mod tests {
fn serialize_from_maybe_encoded() {
match Body::from_maybe_encoded(false, "foo") {
Body::Text(_) => (),
not => panic!("expected Body::Text(...) got {:?}", not),
not => panic!("expected Body::Text(...) got {not:?}"),
}

match Body::from_maybe_encoded(true, "Zm9v") {
Body::Binary(b) => assert_eq!(&[102, 111, 111], b.as_slice()),
not => panic!("expected Body::Text(...) got {:?}", not),
not => panic!("expected Body::Text(...) got {not:?}"),
}
}
}
30 changes: 18 additions & 12 deletions lambda-events/src/event/appsync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::HashMap;
use crate::custom_serde::deserialize_lambda_map;

/// Deprecated: `AppSyncResolverTemplate` does not represent resolver events sent by AppSync. Instead directly model your input schema, or use `map[string]string`, `json.RawMessage`,` interface{}`, etc..
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncResolverTemplate<T1 = Value>
where
Expand All @@ -27,7 +27,7 @@ where
}

/// `AppSyncIamIdentity` contains information about the caller authed via IAM.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncIamIdentity {
#[serde(default)]
Expand Down Expand Up @@ -55,7 +55,7 @@ pub struct AppSyncIamIdentity {
}

/// `AppSyncCognitoIdentity` contains information about the caller authed via Cognito.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncCognitoIdentity<T1 = Value>
where
Expand Down Expand Up @@ -87,7 +87,7 @@ where
pub type AppSyncOperation = String;

/// `AppSyncLambdaAuthorizerRequest` contains an authorization request from AppSync.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncLambdaAuthorizerRequest {
#[serde(default)]
Expand All @@ -104,7 +104,7 @@ pub struct AppSyncLambdaAuthorizerRequest {

/// `AppSyncLambdaAuthorizerRequestContext` contains the parameters of the AppSync invocation which triggered
/// this authorization request.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncLambdaAuthorizerRequestContext<T1 = Value>
where
Expand Down Expand Up @@ -136,7 +136,7 @@ where
}

/// `AppSyncLambdaAuthorizerResponse` represents the expected format of an authorization response to AppSync.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncLambdaAuthorizerResponse<T1 = Value>
where
Expand Down Expand Up @@ -171,7 +171,7 @@ where
///
/// See also:
/// - [AppSync resolver mapping template context reference](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html)
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
pub struct AppSyncDirectResolverEvent<TArguments = Value, TSource = Value, TStash = Value>
where
TArguments: Serialize + DeserializeOwned,
Expand Down Expand Up @@ -200,7 +200,7 @@ where

/// `AppSyncRequest` contains request-related metadata for a resolver invocation,
/// including client-sent headers and optional custom domain name.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncRequest {
#[serde(deserialize_with = "deserialize_lambda_map")]
Expand All @@ -219,7 +219,7 @@ pub struct AppSyncRequest {
}

/// `AppSyncInfo` contains metadata about the current GraphQL field being resolved.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncInfo<T = Value>
where
Expand All @@ -243,7 +243,7 @@ where
}

/// `AppSyncPrevResult` contains the result of the previous step in a pipeline resolver.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
pub struct AppSyncPrevResult<T = Value>
where
T: Serialize + DeserializeOwned,
Expand All @@ -270,8 +270,14 @@ pub enum AppSyncIdentity {
Lambda(AppSyncIdentityLambda),
}

impl Default for AppSyncIdentity {
fn default() -> Self {
AppSyncIdentity::IAM(AppSyncIamIdentity::default())
}
}

/// `AppSyncIdentityOIDC` represents identity information when using OIDC-based authorization.
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
pub struct AppSyncIdentityOIDC<T = Value>
where
T: Serialize + DeserializeOwned,
Expand All @@ -290,7 +296,7 @@ where
}

/// `AppSyncIdentityLambda` represents identity information when using AWS Lambda
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AppSyncIdentityLambda<T = Value>
where
Expand Down
4 changes: 2 additions & 2 deletions lambda-events/src/event/clientvpn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "catch-all-fields")]
use serde_json::Value;

#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ClientVpnConnectionHandlerRequest {
#[serde(default)]
Expand Down Expand Up @@ -40,7 +40,7 @@ pub struct ClientVpnConnectionHandlerRequest {
pub other: serde_json::Map<String, Value>,
}

#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ClientVpnConnectionHandlerResponse {
pub allow: bool,
Expand Down
4 changes: 2 additions & 2 deletions lambda-events/src/event/cloudformation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
pub other: serde_json::Map<String, Value>,
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct UpdateRequest<P1 = Value, P2 = Value>
where
Expand Down Expand Up @@ -79,7 +79,7 @@ where
pub other: serde_json::Map<String, Value>,
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteRequest<P2 = Value>
where
Expand Down
4 changes: 2 additions & 2 deletions lambda-events/src/event/cloudformation/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where
// No `other` catch-all here; any additional fields will be caught in `common.other` instead
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct UpdateRequest<P1 = Value, P2 = Value>
where
Expand All @@ -56,7 +56,7 @@ where
// No `other` catch-all here; any additional fields will be caught in `common.other` instead
}

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DeleteRequest<P2 = Value>
where
Expand Down
6 changes: 3 additions & 3 deletions lambda-events/src/event/code_commit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct CodeCommitEvent {
pub type CodeCommitEventTime = DateTime<Utc>;

/// `CodeCommitRecord` represents a CodeCommit record
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitRecord {
#[serde(default)]
Expand Down Expand Up @@ -63,7 +63,7 @@ pub struct CodeCommitRecord {
}

/// `CodeCommitCodeCommit` represents a CodeCommit object in a record
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitCodeCommit {
pub references: Vec<CodeCommitReference>,
Expand All @@ -80,7 +80,7 @@ pub struct CodeCommitCodeCommit {
}

/// `CodeCommitReference` represents a Reference object in a CodeCommit object
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeCommitReference {
#[serde(default)]
Expand Down
4 changes: 2 additions & 2 deletions lambda-events/src/event/codebuild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub struct CodeBuildEnvironment {
}

/// `CodeBuildEnvironmentVariable` encapsulate environment variables for the code build
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeBuildEnvironmentVariable {
/// Name is the name of the environment variable.
Expand Down Expand Up @@ -239,7 +239,7 @@ pub struct CodeBuildLogs {
}

/// `CodeBuildPhase` represents the phase of a build and its details
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CodeBuildPhase<T1 = Value>
where
Expand Down
20 changes: 10 additions & 10 deletions lambda-events/src/event/dynamodb/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod test {
let attr: AttributeValue = serde_json::from_value(value.clone()).unwrap();
match attr {
AttributeValue::Null(true) => {}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -31,7 +31,7 @@ mod test {
let attr: AttributeValue = serde_json::from_value(value.clone()).unwrap();
match attr {
AttributeValue::S(ref s) => assert_eq!("value", s.as_str()),
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -47,7 +47,7 @@ mod test {
let attr: AttributeValue = serde_json::from_value(value.clone()).unwrap();
match attr {
AttributeValue::N(ref n) => assert_eq!("123.45", n.as_str()),
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -68,7 +68,7 @@ mod test {
.unwrap();
assert_eq!(&expected, b)
}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -84,7 +84,7 @@ mod test {
let attr: AttributeValue = serde_json::from_value(value.clone()).unwrap();
match attr {
AttributeValue::Bool(b) => assert!(b),
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -103,7 +103,7 @@ mod test {
let expected = vec!["Giraffe", "Hippo", "Zebra"];
assert_eq!(expected, s.iter().collect::<Vec<_>>());
}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -122,7 +122,7 @@ mod test {
let expected = vec!["42.2", "-19", "7.5", "3.14"];
assert_eq!(expected, s.iter().collect::<Vec<_>>());
}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -144,7 +144,7 @@ mod test {
.collect::<Vec<_>>();
assert_eq!(&expected, s);
}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -167,7 +167,7 @@ mod test {
];
assert_eq!(&expected, s);
}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}

let reparsed = serde_json::to_value(attr).unwrap();
Expand All @@ -188,7 +188,7 @@ mod test {
expected.insert("Age".into(), AttributeValue::N("35".into()));
assert_eq!(expected, s);
}
other => panic!("unexpected value {:?}", other),
other => panic!("unexpected value {other:?}"),
}
}
}
Loading
Loading