2018-08-01 17:28:52 +02:00
|
|
|
//
|
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
// WARNING: This code is generated. Only edit within the markers.
|
|
|
|
|
|
|
|
public enum FingerprintProtoError: Error {
|
|
|
|
case invalidProtobuf(description: String)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - FingerprintProtoLogicalFingerprint
|
|
|
|
|
|
|
|
@objc public class FingerprintProtoLogicalFingerprint: NSObject {
|
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc public let identityData: Data?
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc public init(identityData: Data?) {
|
|
|
|
self.identityData = identityData
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc
|
|
|
|
public func serializedData() throws -> Data {
|
|
|
|
return try self.asProtobuf.serializedData()
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint {
|
|
|
|
let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData)
|
|
|
|
return try parseProto(proto)
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint {
|
|
|
|
var identityData: Data? = nil
|
|
|
|
if proto.hasIdentityData {
|
|
|
|
identityData = proto.identityData
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint -
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint -
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
let result = FingerprintProtoLogicalFingerprint(identityData: identityData)
|
|
|
|
return result
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint {
|
|
|
|
let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in
|
|
|
|
if let identityData = self.identityData {
|
|
|
|
builder.identityData = identityData
|
|
|
|
}
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
return proto
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - FingerprintProtoLogicalFingerprints
|
|
|
|
|
|
|
|
@objc public class FingerprintProtoLogicalFingerprints: NSObject {
|
|
|
|
|
2018-08-01 17:44:29 +02:00
|
|
|
@objc public let version: UInt32
|
|
|
|
@objc public let localFingerprint: FingerprintProtoLogicalFingerprint?
|
|
|
|
@objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint?
|
|
|
|
|
|
|
|
@objc public init(version: UInt32,
|
|
|
|
localFingerprint: FingerprintProtoLogicalFingerprint?,
|
|
|
|
remoteFingerprint: FingerprintProtoLogicalFingerprint?) {
|
|
|
|
self.version = version
|
|
|
|
self.localFingerprint = localFingerprint
|
|
|
|
self.remoteFingerprint = remoteFingerprint
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc
|
|
|
|
public func serializedData() throws -> Data {
|
|
|
|
return try self.asProtobuf.serializedData()
|
|
|
|
}
|
|
|
|
|
|
|
|
@objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints {
|
|
|
|
let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData)
|
|
|
|
return try parseProto(proto)
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints {
|
|
|
|
var version: UInt32 = 0
|
|
|
|
if proto.hasVersion {
|
|
|
|
version = proto.version
|
|
|
|
}
|
|
|
|
|
|
|
|
var localFingerprint: FingerprintProtoLogicalFingerprint? = nil
|
|
|
|
if proto.hasLocalFingerprint {
|
|
|
|
localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint)
|
|
|
|
}
|
|
|
|
|
|
|
|
var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil
|
|
|
|
if proto.hasRemoteFingerprint {
|
|
|
|
remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints -
|
|
|
|
|
|
|
|
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints -
|
|
|
|
|
|
|
|
let result = FingerprintProtoLogicalFingerprints(version: version,
|
|
|
|
localFingerprint: localFingerprint,
|
|
|
|
remoteFingerprint: remoteFingerprint)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints {
|
|
|
|
let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in
|
|
|
|
builder.version = self.version
|
|
|
|
|
|
|
|
if let localFingerprint = self.localFingerprint {
|
|
|
|
builder.localFingerprint = localFingerprint.asProtobuf
|
|
|
|
}
|
|
|
|
|
|
|
|
if let remoteFingerprint = self.remoteFingerprint {
|
|
|
|
builder.remoteFingerprint = remoteFingerprint.asProtobuf
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return proto
|
|
|
|
}
|
2018-08-01 17:28:52 +02:00
|
|
|
}
|