From 0d23b06cbc048d670a9d9ff84cb9e409e2dcb09b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 1 Aug 2018 11:44:29 -0400 Subject: [PATCH] Code generate Swift wrappers for protocol buffers. --- .../Protos/Generated/FingerprintProto.swift | 186 +++--- .../Protos/Generated/ProvisioningProto.swift | 334 +++++------ .../src/Protos/Generated/SignalIOSProto.swift | 226 ++++---- .../src/Protos/Generated/WebSocketProto.swift | 538 +++++++++--------- 4 files changed, 642 insertions(+), 642 deletions(-) diff --git a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift index 4048fdc56..9c4ad211e 100644 --- a/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift +++ b/SignalServiceKit/src/Protos/Generated/FingerprintProto.swift @@ -14,112 +14,112 @@ public enum FingerprintProtoError: Error { @objc public class FingerprintProtoLogicalFingerprint: NSObject { - @objc public let identityData: Data? + @objc public let identityData: Data? - @objc public init(identityData: Data?) { - self.identityData = identityData - } + @objc public init(identityData: Data?) { + self.identityData = identityData + } - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } - @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { - let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData) - return try parseProto(proto) - } + @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { + let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData) + return try parseProto(proto) + } - fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { - var identityData: Data? = nil - if proto.hasIdentityData { - identityData = proto.identityData - } + fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { + var identityData: Data? = nil + if proto.hasIdentityData { + identityData = proto.identityData + } - // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - + // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint - - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - + // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint - - let result = FingerprintProtoLogicalFingerprint(identityData: identityData) - return result - } + let result = FingerprintProtoLogicalFingerprint(identityData: identityData) + return result + } - fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { - let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in - if let identityData = self.identityData { - builder.identityData = identityData - } - } + fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { + let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in + if let identityData = self.identityData { + builder.identityData = identityData + } + } - return proto - } + return proto + } } // MARK: - FingerprintProtoLogicalFingerprints @objc public class FingerprintProtoLogicalFingerprints: NSObject { - @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 - } + @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 + } } diff --git a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift index e044b6c50..bea712bc8 100644 --- a/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift +++ b/SignalServiceKit/src/Protos/Generated/ProvisioningProto.swift @@ -14,177 +14,177 @@ public enum ProvisioningProtoError: Error { @objc public class ProvisioningProtoProvisionEnvelope: NSObject { - @objc public let publicKey: Data? - @objc public let body: Data? - - @objc public init(publicKey: Data?, - body: Data?) { - self.publicKey = publicKey - self.body = body - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { - let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { - var publicKey: Data? = nil - if proto.hasPublicKey { - publicKey = proto.publicKey - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - - - // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - - - let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, - body: body) - return result - } - - fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { - let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in - if let publicKey = self.publicKey { - builder.publicKey = publicKey - } - - if let body = self.body { - builder.body = body - } - } - - return proto - } + @objc public let publicKey: Data? + @objc public let body: Data? + + @objc public init(publicKey: Data?, + body: Data?) { + self.publicKey = publicKey + self.body = body + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { + let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { + var publicKey: Data? = nil + if proto.hasPublicKey { + publicKey = proto.publicKey + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - + + let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, + body: body) + return result + } + + fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { + let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in + if let publicKey = self.publicKey { + builder.publicKey = publicKey + } + + if let body = self.body { + builder.body = body + } + } + + return proto + } } // MARK: - ProvisioningProtoProvisionMessage @objc public class ProvisioningProtoProvisionMessage: NSObject { - @objc public let identityKeyPublic: Data? - @objc public let identityKeyPrivate: Data? - @objc public let number: String? - @objc public let provisioningCode: String? - @objc public let userAgent: String? - @objc public let profileKey: Data? - @objc public let readReceipts: Bool - - @objc public init(identityKeyPublic: Data?, - identityKeyPrivate: Data?, - number: String?, - provisioningCode: String?, - userAgent: String?, - profileKey: Data?, - readReceipts: Bool) { - self.identityKeyPublic = identityKeyPublic - self.identityKeyPrivate = identityKeyPrivate - self.number = number - self.provisioningCode = provisioningCode - self.userAgent = userAgent - self.profileKey = profileKey - self.readReceipts = readReceipts - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { - let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { - var identityKeyPublic: Data? = nil - if proto.hasIdentityKeyPublic { - identityKeyPublic = proto.identityKeyPublic - } - - var identityKeyPrivate: Data? = nil - if proto.hasIdentityKeyPrivate { - identityKeyPrivate = proto.identityKeyPrivate - } - - var number: String? = nil - if proto.hasNumber { - number = proto.number - } - - var provisioningCode: String? = nil - if proto.hasProvisioningCode { - provisioningCode = proto.provisioningCode - } - - var userAgent: String? = nil - if proto.hasUserAgent { - userAgent = proto.userAgent - } - - var profileKey: Data? = nil - if proto.hasProfileKey { - profileKey = proto.profileKey - } - - var readReceipts: Bool = false - if proto.hasReadReceipts { - readReceipts = proto.readReceipts - } - - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - - - // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - - - let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, - identityKeyPrivate: identityKeyPrivate, - number: number, - provisioningCode: provisioningCode, - userAgent: userAgent, - profileKey: profileKey, - readReceipts: readReceipts) - return result - } - - fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { - let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in - if let identityKeyPublic = self.identityKeyPublic { - builder.identityKeyPublic = identityKeyPublic - } - - if let identityKeyPrivate = self.identityKeyPrivate { - builder.identityKeyPrivate = identityKeyPrivate - } - - if let number = self.number { - builder.number = number - } - - if let provisioningCode = self.provisioningCode { - builder.provisioningCode = provisioningCode - } - - if let userAgent = self.userAgent { - builder.userAgent = userAgent - } - - if let profileKey = self.profileKey { - builder.profileKey = profileKey - } - - builder.readReceipts = self.readReceipts - } - - return proto - } + @objc public let identityKeyPublic: Data? + @objc public let identityKeyPrivate: Data? + @objc public let number: String? + @objc public let provisioningCode: String? + @objc public let userAgent: String? + @objc public let profileKey: Data? + @objc public let readReceipts: Bool + + @objc public init(identityKeyPublic: Data?, + identityKeyPrivate: Data?, + number: String?, + provisioningCode: String?, + userAgent: String?, + profileKey: Data?, + readReceipts: Bool) { + self.identityKeyPublic = identityKeyPublic + self.identityKeyPrivate = identityKeyPrivate + self.number = number + self.provisioningCode = provisioningCode + self.userAgent = userAgent + self.profileKey = profileKey + self.readReceipts = readReceipts + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { + let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { + var identityKeyPublic: Data? = nil + if proto.hasIdentityKeyPublic { + identityKeyPublic = proto.identityKeyPublic + } + + var identityKeyPrivate: Data? = nil + if proto.hasIdentityKeyPrivate { + identityKeyPrivate = proto.identityKeyPrivate + } + + var number: String? = nil + if proto.hasNumber { + number = proto.number + } + + var provisioningCode: String? = nil + if proto.hasProvisioningCode { + provisioningCode = proto.provisioningCode + } + + var userAgent: String? = nil + if proto.hasUserAgent { + userAgent = proto.userAgent + } + + var profileKey: Data? = nil + if proto.hasProfileKey { + profileKey = proto.profileKey + } + + var readReceipts: Bool = false + if proto.hasReadReceipts { + readReceipts = proto.readReceipts + } + + // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - + + // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - + + let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, + identityKeyPrivate: identityKeyPrivate, + number: number, + provisioningCode: provisioningCode, + userAgent: userAgent, + profileKey: profileKey, + readReceipts: readReceipts) + return result + } + + fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { + let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in + if let identityKeyPublic = self.identityKeyPublic { + builder.identityKeyPublic = identityKeyPublic + } + + if let identityKeyPrivate = self.identityKeyPrivate { + builder.identityKeyPrivate = identityKeyPrivate + } + + if let number = self.number { + builder.number = number + } + + if let provisioningCode = self.provisioningCode { + builder.provisioningCode = provisioningCode + } + + if let userAgent = self.userAgent { + builder.userAgent = userAgent + } + + if let profileKey = self.profileKey { + builder.profileKey = profileKey + } + + builder.readReceipts = self.readReceipts + } + + return proto + } } diff --git a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift index d79a5deef..ad0cb083d 100644 --- a/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift +++ b/SignalServiceKit/src/Protos/Generated/SignalIOSProto.swift @@ -14,132 +14,132 @@ public enum SignalIOSProtoError: Error { @objc public class SignalIOSProtoBackupSnapshotBackupEntity: NSObject { - // MARK: - SignalIOSProtoBackupSnapshotBackupEntityType - - @objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 { - case unknown = 0 - case migration = 1 - case thread = 2 - case interaction = 3 - case attachment = 4 - } - - private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType { - switch value { - case .unknown: return .unknown - case .migration: return .migration - case .thread: return .thread - case .interaction: return .interaction - case .attachment: return .attachment - } - } - - private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { - switch value { - case .unknown: return .unknown - case .migration: return .migration - case .thread: return .thread - case .interaction: return .interaction - case .attachment: return .attachment - } - } - - @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType - @objc public let entityData: Data? - - @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, - entityData: Data?) { - self.type = type - self.entityData = entityData - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { - let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { - var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown - if proto.hasType { - type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) - } - - var entityData: Data? = nil - if proto.hasEntityData { - entityData = proto.entityData - } - - // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - - - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - - - let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, - entityData: entityData) - return result - } - - fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { - let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in - builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) - - if let entityData = self.entityData { - builder.entityData = entityData - } - } - - return proto - } + // MARK: - SignalIOSProtoBackupSnapshotBackupEntityType + + @objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 { + case unknown = 0 + case migration = 1 + case thread = 2 + case interaction = 3 + case attachment = 4 + } + + private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType { + switch value { + case .unknown: return .unknown + case .migration: return .migration + case .thread: return .thread + case .interaction: return .interaction + case .attachment: return .attachment + } + } + + private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { + switch value { + case .unknown: return .unknown + case .migration: return .migration + case .thread: return .thread + case .interaction: return .interaction + case .attachment: return .attachment + } + } + + @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType + @objc public let entityData: Data? + + @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, + entityData: Data?) { + self.type = type + self.entityData = entityData + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { + var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown + if proto.hasType { + type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) + } + + var entityData: Data? = nil + if proto.hasEntityData { + entityData = proto.entityData + } + + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - + + // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - + + let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, + entityData: entityData) + return result + } + + fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { + let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in + builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) + + if let entityData = self.entityData { + builder.entityData = entityData + } + } + + return proto + } } // MARK: - SignalIOSProtoBackupSnapshot @objc public class SignalIOSProtoBackupSnapshot: NSObject { - @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] + @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] - @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { - self.entity = entity - } + @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { + self.entity = entity + } - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } - @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { - let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData) - return try parseProto(proto) - } + @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { + let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData) + return try parseProto(proto) + } - fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot { - var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = [] - for item in proto.entity { - let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item) - entity.append(wrapped) - } + fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot { + var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = [] + for item in proto.entity { + let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item) + entity.append(wrapped) + } - // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshot - + // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshot - - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot - + // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot - - let result = SignalIOSProtoBackupSnapshot(entity: entity) - return result - } + let result = SignalIOSProtoBackupSnapshot(entity: entity) + return result + } - fileprivate var asProtobuf: IOSProtos_BackupSnapshot { - let proto = IOSProtos_BackupSnapshot.with { (builder) in - var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() - for item in entity { - entityUnwrapped.append(item.asProtobuf) - } - builder.entity = entityUnwrapped - } + fileprivate var asProtobuf: IOSProtos_BackupSnapshot { + let proto = IOSProtos_BackupSnapshot.with { (builder) in + var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() + for item in entity { + entityUnwrapped.append(item.asProtobuf) + } + builder.entity = entityUnwrapped + } - return proto - } + return proto + } } diff --git a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift index 57d0d7722..84ad7babe 100644 --- a/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift +++ b/SignalServiceKit/src/Protos/Generated/WebSocketProto.swift @@ -14,285 +14,285 @@ public enum WebSocketProtoError: Error { @objc public class WebSocketProtoWebSocketRequestMessage: NSObject { - @objc public let verb: String? - @objc public let path: String? - @objc public let body: Data? - @objc public let headers: [String] - @objc public let requestId: UInt64 - - @objc public init(verb: String?, - path: String?, - body: Data?, - headers: [String], - requestId: UInt64) { - self.verb = verb - self.path = path - self.body = body - self.headers = headers - self.requestId = requestId - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { - let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { - var verb: String? = nil - if proto.hasVerb { - verb = proto.verb - } - - var path: String? = nil - if proto.hasPath { - path = proto.path - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - - var headers: [String] = [] - for item in proto.headers { - let wrapped = item - headers.append(wrapped) - } - - var requestId: UInt64 = 0 - if proto.hasRequestId { - requestId = proto.requestId - } - - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - - - // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - - - let result = WebSocketProtoWebSocketRequestMessage(verb: verb, - path: path, - body: body, - headers: headers, - requestId: requestId) - return result - } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { - let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in - if let verb = self.verb { - builder.verb = verb - } - - if let path = self.path { - builder.path = path - } - - if let body = self.body { - builder.body = body - } - - var headersUnwrapped = [String]() - for item in headers { - headersUnwrapped.append(item) - } - builder.headers = headersUnwrapped - - builder.requestId = self.requestId - } - - return proto - } + @objc public let verb: String? + @objc public let path: String? + @objc public let body: Data? + @objc public let headers: [String] + @objc public let requestId: UInt64 + + @objc public init(verb: String?, + path: String?, + body: Data?, + headers: [String], + requestId: UInt64) { + self.verb = verb + self.path = path + self.body = body + self.headers = headers + self.requestId = requestId + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { + let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { + var verb: String? = nil + if proto.hasVerb { + verb = proto.verb + } + + var path: String? = nil + if proto.hasPath { + path = proto.path + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + var headers: [String] = [] + for item in proto.headers { + let wrapped = item + headers.append(wrapped) + } + + var requestId: UInt64 = 0 + if proto.hasRequestId { + requestId = proto.requestId + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - + + let result = WebSocketProtoWebSocketRequestMessage(verb: verb, + path: path, + body: body, + headers: headers, + requestId: requestId) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { + let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in + if let verb = self.verb { + builder.verb = verb + } + + if let path = self.path { + builder.path = path + } + + if let body = self.body { + builder.body = body + } + + var headersUnwrapped = [String]() + for item in headers { + headersUnwrapped.append(item) + } + builder.headers = headersUnwrapped + + builder.requestId = self.requestId + } + + return proto + } } // MARK: - WebSocketProtoWebSocketResponseMessage @objc public class WebSocketProtoWebSocketResponseMessage: NSObject { - @objc public let requestId: UInt64 - @objc public let status: UInt32 - @objc public let message: String? - @objc public let headers: [String] - @objc public let body: Data? - - @objc public init(requestId: UInt64, - status: UInt32, - message: String?, - headers: [String], - body: Data?) { - self.requestId = requestId - self.status = status - self.message = message - self.headers = headers - self.body = body - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { - let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { - var requestId: UInt64 = 0 - if proto.hasRequestId { - requestId = proto.requestId - } - - var status: UInt32 = 0 - if proto.hasStatus { - status = proto.status - } - - var message: String? = nil - if proto.hasMessage { - message = proto.message - } - - var headers: [String] = [] - for item in proto.headers { - let wrapped = item - headers.append(wrapped) - } - - var body: Data? = nil - if proto.hasBody { - body = proto.body - } - - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - - - // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - - - let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, - status: status, - message: message, - headers: headers, - body: body) - return result - } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { - let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in - builder.requestId = self.requestId - - builder.status = self.status - - if let message = self.message { - builder.message = message - } - - var headersUnwrapped = [String]() - for item in headers { - headersUnwrapped.append(item) - } - builder.headers = headersUnwrapped - - if let body = self.body { - builder.body = body - } - } - - return proto - } + @objc public let requestId: UInt64 + @objc public let status: UInt32 + @objc public let message: String? + @objc public let headers: [String] + @objc public let body: Data? + + @objc public init(requestId: UInt64, + status: UInt32, + message: String?, + headers: [String], + body: Data?) { + self.requestId = requestId + self.status = status + self.message = message + self.headers = headers + self.body = body + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { + let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { + var requestId: UInt64 = 0 + if proto.hasRequestId { + requestId = proto.requestId + } + + var status: UInt32 = 0 + if proto.hasStatus { + status = proto.status + } + + var message: String? = nil + if proto.hasMessage { + message = proto.message + } + + var headers: [String] = [] + for item in proto.headers { + let wrapped = item + headers.append(wrapped) + } + + var body: Data? = nil + if proto.hasBody { + body = proto.body + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - + + let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, + status: status, + message: message, + headers: headers, + body: body) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { + let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in + builder.requestId = self.requestId + + builder.status = self.status + + if let message = self.message { + builder.message = message + } + + var headersUnwrapped = [String]() + for item in headers { + headersUnwrapped.append(item) + } + builder.headers = headersUnwrapped + + if let body = self.body { + builder.body = body + } + } + + return proto + } } // MARK: - WebSocketProtoWebSocketMessage @objc public class WebSocketProtoWebSocketMessage: NSObject { - // MARK: - WebSocketProtoWebSocketMessageType - - @objc public enum WebSocketProtoWebSocketMessageType: Int32 { - case unknown = 0 - case request = 1 - case response = 2 - } - - private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType { - switch value { - case .unknown: return .unknown - case .request: return .request - case .response: return .response - } - } - - private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum { - switch value { - case .unknown: return .unknown - case .request: return .request - case .response: return .response - } - } - - @objc public let type: WebSocketProtoWebSocketMessageType - @objc public let request: WebSocketProtoWebSocketRequestMessage? - @objc public let response: WebSocketProtoWebSocketResponseMessage? - - @objc public init(type: WebSocketProtoWebSocketMessageType, - request: WebSocketProtoWebSocketRequestMessage?, - response: WebSocketProtoWebSocketResponseMessage?) { - self.type = type - self.request = request - self.response = response - } - - @objc - public func serializedData() throws -> Data { - return try self.asProtobuf.serializedData() - } - - @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { - let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData) - return try parseProto(proto) - } - - fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { - var type: WebSocketProtoWebSocketMessageType = .unknown - if proto.hasType { - type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) - } - - var request: WebSocketProtoWebSocketRequestMessage? = nil - if proto.hasRequest { - request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) - } - - var response: WebSocketProtoWebSocketResponseMessage? = nil - if proto.hasResponse { - response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response) - } - - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage - - - // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - - - let result = WebSocketProtoWebSocketMessage(type: type, - request: request, - response: response) - return result - } - - fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { - let proto = WebSocketProtos_WebSocketMessage.with { (builder) in - builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) - - if let request = self.request { - builder.request = request.asProtobuf - } - - if let response = self.response { - builder.response = response.asProtobuf - } - } - - return proto - } + // MARK: - WebSocketProtoWebSocketMessageType + + @objc public enum WebSocketProtoWebSocketMessageType: Int32 { + case unknown = 0 + case request = 1 + case response = 2 + } + + private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType { + switch value { + case .unknown: return .unknown + case .request: return .request + case .response: return .response + } + } + + private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum { + switch value { + case .unknown: return .unknown + case .request: return .request + case .response: return .response + } + } + + @objc public let type: WebSocketProtoWebSocketMessageType + @objc public let request: WebSocketProtoWebSocketRequestMessage? + @objc public let response: WebSocketProtoWebSocketResponseMessage? + + @objc public init(type: WebSocketProtoWebSocketMessageType, + request: WebSocketProtoWebSocketRequestMessage?, + response: WebSocketProtoWebSocketResponseMessage?) { + self.type = type + self.request = request + self.response = response + } + + @objc + public func serializedData() throws -> Data { + return try self.asProtobuf.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { + let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { + var type: WebSocketProtoWebSocketMessageType = .unknown + if proto.hasType { + type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) + } + + var request: WebSocketProtoWebSocketRequestMessage? = nil + if proto.hasRequest { + request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) + } + + var response: WebSocketProtoWebSocketResponseMessage? = nil + if proto.hasResponse { + response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response) + } + + // MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage - + + // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - + + let result = WebSocketProtoWebSocketMessage(type: type, + request: request, + response: response) + return result + } + + fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { + let proto = WebSocketProtos_WebSocketMessage.with { (builder) in + builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) + + if let request = self.request { + builder.request = request.asProtobuf + } + + if let response = self.response { + builder.response = response.asProtobuf + } + } + + return proto + } }