Refactor SyncCore

This commit is contained in:
Peter
2019-10-21 16:58:00 +04:00
parent 75aa77faa8
commit 10692a323e
1162 changed files with 12205 additions and 10925 deletions

View File

@@ -0,0 +1,29 @@
import Postbox
public enum TelegramDeviceContactImportedData: PostboxCoding {
case imported(data: ImportableDeviceContactData, importedByCount: Int32)
case retryLater
public init(decoder: PostboxDecoder) {
switch decoder.decodeInt32ForKey("_t", orElse: 0) {
case 0:
self = .imported(data: decoder.decodeObjectForKey("d", decoder: { ImportableDeviceContactData(decoder: $0) }) as! ImportableDeviceContactData, importedByCount: decoder.decodeInt32ForKey("c", orElse: 0))
case 1:
self = .retryLater
default:
assertionFailure()
self = .retryLater
}
}
public func encode(_ encoder: PostboxEncoder) {
switch self {
case let .imported(data, importedByCount):
encoder.encodeInt32(0, forKey: "_t")
encoder.encodeObject(data, forKey: "d")
encoder.encodeInt32(importedByCount, forKey: "c")
case .retryLater:
encoder.encodeInt32(1, forKey: "_t")
}
}
}