@@ -18,15 +18,15 @@ import struct Foundation.Date
18
18
19
19
public enum CMQ {
20
20
public enum Topic {
21
- public struct Event : Codable , Equatable {
21
+ public struct Event : Decodable , Equatable {
22
22
public let records : [ Record ]
23
23
24
24
public enum CodingKeys : String , CodingKey {
25
25
case records = " Records "
26
26
}
27
27
}
28
28
29
- public struct Record : Codable , Equatable {
29
+ public struct Record : Decodable , Equatable {
30
30
internal static let type : String = " topic "
31
31
32
32
public let topicOwner : UInt64
@@ -58,19 +58,9 @@ public enum CMQ {
58
58
topicName = try container. decode ( String . self, forKey: . topicName)
59
59
subscriptionName = try container. decode ( String . self, forKey: . subscriptionName)
60
60
}
61
-
62
- public func encode( to encoder: Encoder ) throws {
63
- var wrapperContainer = encoder. container ( keyedBy: WrappingCodingKeys . self)
64
- try wrapperContainer. encode ( message, forKey: . cmq)
65
- var container = wrapperContainer. nestedContainer ( keyedBy: CodingKeys . self, forKey: . cmq)
66
- try container. encode ( Self . type, forKey: . type)
67
- try container. encode ( topicOwner, forKey: . topicOwner)
68
- try container. encode ( topicName, forKey: . topicName)
69
- try container. encode ( subscriptionName, forKey: . subscriptionName)
70
- }
71
61
}
72
62
73
- public struct Message : Codable , Equatable {
63
+ public struct Message : Decodable , Equatable {
74
64
internal static let separator : Character = " , "
75
65
76
66
public let id : String
@@ -100,15 +90,6 @@ public enum CMQ {
100
90
requestId = try container. decode ( String . self, forKey: . requestId)
101
91
publishTime = try container. decode ( Date . self, forKey: . publishTime, using: DateCoding . ISO8601WithFractionalSeconds. self)
102
92
}
103
-
104
- public func encode( to encoder: Encoder ) throws {
105
- var container = encoder. container ( keyedBy: CodingKeys . self)
106
- try container. encode ( id, forKey: . messageId)
107
- try container. encode ( body, forKey: . messageBody)
108
- try container. encode ( tags. joined ( separator: . init( Self . separator) ) , forKey: . messageTags)
109
- try container. encode ( publishTime, forKey: . publishTime, using: DateCoding . ISO8601WithFractionalSeconds. self)
110
- try container. encode ( requestId, forKey: . requestId)
111
- }
112
93
}
113
94
}
114
95
}
0 commit comments