Skip to content
Snippets Groups Projects
Commit 46351d04 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Make model en/decoding public

parent c0832083
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
......@@ -19,21 +19,21 @@ extension Fact: Codable {
case type = "Type"
}
static func decode(_ data: Data) throws -> Fact {
public static func decode(_ data: Data) throws -> Fact {
try JSONDecoder().decode(Self.self, from: data)
}
func encode() throws -> Data {
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
extension Array where Element == Fact {
static func decode(_ data: Data) throws -> [Fact] {
public static func decode(_ data: Data) throws -> [Fact] {
try JSONDecoder().decode(Self.self, from: data)
}
func encode() throws -> Data {
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
......@@ -47,11 +47,11 @@ extension Message: Codable {
case roundId = "RoundId"
}
static func decode(_ data: Data) throws -> Message {
public static func decode(_ data: Data) throws -> Message {
try JSONDecoder().decode(Self.self, from: data)
}
func encode() throws -> Data {
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
......@@ -23,11 +23,11 @@ extension MessageSendReport: Codable {
case timestamp = "Timestamp"
}
static func decode(_ data: Data) throws -> MessageSendReport {
public static func decode(_ data: Data) throws -> MessageSendReport {
try JSONDecoder().decode(Self.self, from: data)
}
func encode() throws -> Data {
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
......@@ -27,11 +27,11 @@ extension ReceptionIdentity: Codable {
case dhKeyPrivate = "DHKeyPrivate"
}
static func decode(_ data: Data) throws -> ReceptionIdentity {
public static func decode(_ data: Data) throws -> ReceptionIdentity {
try JSONDecoder().decode(Self.self, from: data)
}
func encode() throws -> Data {
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
......@@ -35,11 +35,11 @@ extension RestlikeMessage: Codable {
case error = "Error"
}
static func decode(_ data: Data) throws -> RestlikeMessage {
public static func decode(_ data: Data) throws -> RestlikeMessage {
try JSONDecoder().decode(Self.self, from: data)
}
func encode() throws -> Data {
public func encode() throws -> Data {
try JSONEncoder().encode(self)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment