15
15
import struct Foundation. Date
16
16
17
17
// https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html
18
- public struct DynamoDB {
18
+ public enum DynamoDB {
19
19
public struct Event : Decodable {
20
20
public let records : [ EventRecord ]
21
21
@@ -311,14 +311,12 @@ extension DynamoDB {
311
311
public init ( ) { }
312
312
313
313
@inlinable public func decode< T: Decodable > ( _ type: T . Type , from image: [ String : AttributeValue ] )
314
- throws -> T
315
- {
314
+ throws -> T {
316
315
try self . decode ( type, from: . map( image) )
317
316
}
318
317
319
318
@inlinable public func decode< T: Decodable > ( _ type: T . Type , from value: AttributeValue )
320
- throws -> T
321
- {
319
+ throws -> T {
322
320
let decoder = _DecoderImpl ( userInfo: userInfo, from: value, codingPath: [ ] )
323
321
return try decoder. decode ( T . self)
324
322
}
@@ -511,7 +509,7 @@ extension DynamoDB {
511
509
512
510
func nestedContainer< NestedKey> ( keyedBy type: NestedKey . Type , forKey key: K ) throws
513
511
-> KeyedDecodingContainer < NestedKey > where NestedKey: CodingKey {
514
- return try self . decoderForKey ( key) . container ( keyedBy: type)
512
+ try self . decoderForKey ( key) . container ( keyedBy: type)
515
513
}
516
514
517
515
func nestedUnkeyedContainer( forKey key: K ) throws -> UnkeyedDecodingContainer {
@@ -557,8 +555,7 @@ extension DynamoDB {
557
555
}
558
556
559
557
@inline ( __always) private func decodeFixedWidthInteger< T: FixedWidthInteger > ( key: Self . Key )
560
- throws -> T
561
- {
558
+ throws -> T {
562
559
let value = try getValue ( forKey: key)
563
560
564
561
guard case . number( let number) = value else {
@@ -577,8 +574,7 @@ extension DynamoDB {
577
574
}
578
575
579
576
@inline ( __always) private func decodeLosslessStringConvertible< T: LosslessStringConvertible > (
580
- key: Self . Key ) throws -> T
581
- {
577
+ key: Self . Key ) throws -> T {
582
578
let value = try getValue ( forKey: key)
583
579
584
580
guard case . number( let number) = value else {
@@ -677,7 +673,7 @@ extension DynamoDB {
677
673
}
678
674
679
675
func decode< T> ( _: T . Type ) throws -> T where T: Decodable {
680
- return try T ( from: self . impl)
676
+ try T ( from: self . impl)
681
677
}
682
678
683
679
@inline ( __always) private func createTypeMismatchError( type: Any . Type , value: AttributeValue ) -> DecodingError {
@@ -688,8 +684,7 @@ extension DynamoDB {
688
684
}
689
685
690
686
@inline ( __always) private func decodeFixedWidthInteger< T: FixedWidthInteger > ( ) throws
691
- -> T
692
- {
687
+ -> T {
693
688
guard case . number( let number) = self . value else {
694
689
throw self . createTypeMismatchError ( type: T . self, value: self . value)
695
690
}
@@ -705,8 +700,7 @@ extension DynamoDB {
705
700
}
706
701
707
702
@inline ( __always) private func decodeLosslessStringConvertible< T: LosslessStringConvertible > ( )
708
- throws -> T
709
- {
703
+ throws -> T {
710
704
guard case . number( let number) = self . value else {
711
705
throw self . createTypeMismatchError ( type: T . self, value: self . value)
712
706
}
@@ -850,7 +844,7 @@ extension DynamoDB {
850
844
851
845
mutating func nestedContainer< NestedKey> ( keyedBy type: NestedKey . Type ) throws
852
846
-> KeyedDecodingContainer < NestedKey > where NestedKey: CodingKey {
853
- return try self . impl. container ( keyedBy: type)
847
+ try self . impl. container ( keyedBy: type)
854
848
}
855
849
856
850
mutating func nestedUnkeyedContainer( ) throws -> UnkeyedDecodingContainer {
@@ -869,8 +863,7 @@ extension DynamoDB {
869
863
}
870
864
871
865
@inline ( __always) private mutating func decodeFixedWidthInteger< T: FixedWidthInteger > ( ) throws
872
- -> T
873
- {
866
+ -> T {
874
867
defer {
875
868
currentIndex += 1
876
869
if currentIndex == count {
@@ -891,8 +884,7 @@ extension DynamoDB {
891
884
}
892
885
893
886
@inline ( __always) private mutating func decodeLosslessStringConvertible< T: LosslessStringConvertible > ( )
894
- throws -> T
895
- {
887
+ throws -> T {
896
888
defer {
897
889
currentIndex += 1
898
890
if currentIndex == count {
0 commit comments