@@ -24,125 +24,6 @@ import class Foundation.JSONDecoder
24
24
import class Foundation. JSONEncoder
25
25
#endif
26
26
27
- // MARK: - SimpleLambdaHandler Codable support
28
-
29
- /// Implementation of `ByteBuffer` to `Event` decoding.
30
- extension SimpleLambdaHandler where Event: Decodable {
31
- @inlinable
32
- public func decode( buffer: ByteBuffer ) throws -> Event {
33
- try self . decoder. decode ( Event . self, from: buffer)
34
- }
35
- }
36
-
37
- /// Implementation of `Output` to `ByteBuffer` encoding.
38
- extension SimpleLambdaHandler where Output: Encodable {
39
- @inlinable
40
- public func encode( value: Output , into buffer: inout ByteBuffer ) throws {
41
- try self . encoder. encode ( value, into: & buffer)
42
- }
43
- }
44
-
45
- /// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
46
- /// Advanced users who want to inject their own codec can do it by overriding these functions.
47
- extension SimpleLambdaHandler where Event: Decodable {
48
- public var decoder : LambdaCodableDecoder {
49
- Lambda . defaultJSONDecoder
50
- }
51
- }
52
-
53
- /// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
54
- /// Advanced users who want to inject their own codec can do it by overriding these functions.
55
- extension SimpleLambdaHandler where Output: Encodable {
56
- public var encoder : LambdaCodableEncoder {
57
- Lambda . defaultJSONEncoder
58
- }
59
- }
60
-
61
- // MARK: - LambdaHandler Codable support
62
-
63
- /// Implementation of `ByteBuffer` to `Event` decoding.
64
- extension LambdaHandler where Event: Decodable {
65
- @inlinable
66
- public func decode( buffer: ByteBuffer ) throws -> Event {
67
- try self . decoder. decode ( Event . self, from: buffer)
68
- }
69
- }
70
-
71
- /// Implementation of `Output` to `ByteBuffer` encoding.
72
- extension LambdaHandler where Output: Encodable {
73
- @inlinable
74
- public func encode( value: Output , into buffer: inout ByteBuffer ) throws {
75
- try self . encoder. encode ( value, into: & buffer)
76
- }
77
- }
78
-
79
- /// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
80
- /// Advanced users who want to inject their own codec can do it by overriding these functions.
81
- extension LambdaHandler where Event: Decodable {
82
- public var decoder : LambdaCodableDecoder {
83
- Lambda . defaultJSONDecoder
84
- }
85
- }
86
-
87
- /// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
88
- /// Advanced users who want to inject their own codec can do it by overriding these functions.
89
- extension LambdaHandler where Output: Encodable {
90
- public var encoder : LambdaCodableEncoder {
91
- Lambda . defaultJSONEncoder
92
- }
93
- }
94
-
95
- // MARK: - EventLoopLambdaHandler Codable support
96
-
97
- /// Implementation of `ByteBuffer` to `Event` decoding.
98
- extension EventLoopLambdaHandler where Event: Decodable {
99
- @inlinable
100
- public func decode( buffer: ByteBuffer ) throws -> Event {
101
- try self . decoder. decode ( Event . self, from: buffer)
102
- }
103
- }
104
-
105
- /// Implementation of `Output` to `ByteBuffer` encoding.
106
- extension EventLoopLambdaHandler where Output: Encodable {
107
- @inlinable
108
- public func encode( value: Output , into buffer: inout ByteBuffer ) throws {
109
- try self . encoder. encode ( value, into: & buffer)
110
- }
111
- }
112
-
113
- /// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
114
- /// Advanced users that want to inject their own codec can do it by overriding these functions.
115
- extension EventLoopLambdaHandler where Event: Decodable {
116
- public var decoder : LambdaCodableDecoder {
117
- Lambda . defaultJSONDecoder
118
- }
119
- }
120
-
121
- /// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
122
- /// Advanced users that want to inject their own codec can do it by overriding these functions.
123
- extension EventLoopLambdaHandler where Output: Encodable {
124
- public var encoder : LambdaCodableEncoder {
125
- Lambda . defaultJSONEncoder
126
- }
127
- }
128
-
129
- public protocol LambdaCodableDecoder {
130
- func decode< T: Decodable > ( _ type: T . Type , from buffer: ByteBuffer ) throws -> T
131
- }
132
-
133
- public protocol LambdaCodableEncoder {
134
- func encode< T: Encodable > ( _ value: T , into buffer: inout ByteBuffer ) throws
135
- }
136
-
137
- extension Lambda {
138
- fileprivate static let defaultJSONDecoder = JSONDecoder ( )
139
- fileprivate static let defaultJSONEncoder = JSONEncoder ( )
140
- }
141
-
142
- extension JSONDecoder : LambdaCodableDecoder { }
143
-
144
- extension JSONEncoder : LambdaCodableEncoder { }
145
-
146
27
extension JSONDecoder : AWSLambdaRuntimeCore . LambdaEventDecoder { }
147
28
148
29
@usableFromInline
0 commit comments