@@ -18,15 +18,15 @@ import struct Foundation.Date
1818
1919public enum CMQ {
2020 public enum Topic {
21- public struct Event : Codable , Equatable {
21+ public struct Event : Decodable , Equatable {
2222 public let records : [ Record ]
2323
2424 public enum CodingKeys : String , CodingKey {
2525 case records = " Records "
2626 }
2727 }
2828
29- public struct Record : Codable , Equatable {
29+ public struct Record : Decodable , Equatable {
3030 internal static let type : String = " topic "
3131
3232 public let topicOwner : UInt64
@@ -58,19 +58,9 @@ public enum CMQ {
5858 topicName = try container. decode ( String . self, forKey: . topicName)
5959 subscriptionName = try container. decode ( String . self, forKey: . subscriptionName)
6060 }
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- }
7161 }
7262
73- public struct Message : Codable , Equatable {
63+ public struct Message : Decodable , Equatable {
7464 internal static let separator : Character = " , "
7565
7666 public let id : String
@@ -100,15 +90,6 @@ public enum CMQ {
10090 requestId = try container. decode ( String . self, forKey: . requestId)
10191 publishTime = try container. decode ( Date . self, forKey: . publishTime, using: DateCoding . ISO8601WithFractionalSeconds. self)
10292 }
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- }
11293 }
11394 }
11495}
0 commit comments