Code generate Swift wrappers for protocol buffers.

pull/1/head
Matthew Chen 7 years ago
parent 377634a1f7
commit 0d23b06cbc

@ -14,112 +14,112 @@ public enum FingerprintProtoError: Error {
@objc public class FingerprintProtoLogicalFingerprint: NSObject { @objc public class FingerprintProtoLogicalFingerprint: NSObject {
@objc public let identityData: Data? @objc public let identityData: Data?
@objc public init(identityData: Data?) { @objc public init(identityData: Data?) {
self.identityData = identityData self.identityData = identityData
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint { @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprint {
let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData) let proto = try FingerprintProtos_LogicalFingerprint(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint { fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprint) throws -> FingerprintProtoLogicalFingerprint {
var identityData: Data? = nil var identityData: Data? = nil
if proto.hasIdentityData { if proto.hasIdentityData {
identityData = proto.identityData 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) let result = FingerprintProtoLogicalFingerprint(identityData: identityData)
return result return result
} }
fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint { fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprint {
let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in let proto = FingerprintProtos_LogicalFingerprint.with { (builder) in
if let identityData = self.identityData { if let identityData = self.identityData {
builder.identityData = identityData builder.identityData = identityData
} }
} }
return proto return proto
} }
} }
// MARK: - FingerprintProtoLogicalFingerprints // MARK: - FingerprintProtoLogicalFingerprints
@objc public class FingerprintProtoLogicalFingerprints: NSObject { @objc public class FingerprintProtoLogicalFingerprints: NSObject {
@objc public let version: UInt32 @objc public let version: UInt32
@objc public let localFingerprint: FingerprintProtoLogicalFingerprint? @objc public let localFingerprint: FingerprintProtoLogicalFingerprint?
@objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint? @objc public let remoteFingerprint: FingerprintProtoLogicalFingerprint?
@objc public init(version: UInt32, @objc public init(version: UInt32,
localFingerprint: FingerprintProtoLogicalFingerprint?, localFingerprint: FingerprintProtoLogicalFingerprint?,
remoteFingerprint: FingerprintProtoLogicalFingerprint?) { remoteFingerprint: FingerprintProtoLogicalFingerprint?) {
self.version = version self.version = version
self.localFingerprint = localFingerprint self.localFingerprint = localFingerprint
self.remoteFingerprint = remoteFingerprint self.remoteFingerprint = remoteFingerprint
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints { @objc public class func parseData(_ serializedData: Data) throws -> FingerprintProtoLogicalFingerprints {
let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData) let proto = try FingerprintProtos_LogicalFingerprints(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints { fileprivate class func parseProto(_ proto: FingerprintProtos_LogicalFingerprints) throws -> FingerprintProtoLogicalFingerprints {
var version: UInt32 = 0 var version: UInt32 = 0
if proto.hasVersion { if proto.hasVersion {
version = proto.version version = proto.version
} }
var localFingerprint: FingerprintProtoLogicalFingerprint? = nil var localFingerprint: FingerprintProtoLogicalFingerprint? = nil
if proto.hasLocalFingerprint { if proto.hasLocalFingerprint {
localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint) localFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.localFingerprint)
} }
var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil var remoteFingerprint: FingerprintProtoLogicalFingerprint? = nil
if proto.hasRemoteFingerprint { if proto.hasRemoteFingerprint {
remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint) remoteFingerprint = try FingerprintProtoLogicalFingerprint.parseProto(proto.remoteFingerprint)
} }
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints - // MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints -
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints - // MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints -
let result = FingerprintProtoLogicalFingerprints(version: version, let result = FingerprintProtoLogicalFingerprints(version: version,
localFingerprint: localFingerprint, localFingerprint: localFingerprint,
remoteFingerprint: remoteFingerprint) remoteFingerprint: remoteFingerprint)
return result return result
} }
fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints { fileprivate var asProtobuf: FingerprintProtos_LogicalFingerprints {
let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in let proto = FingerprintProtos_LogicalFingerprints.with { (builder) in
builder.version = self.version builder.version = self.version
if let localFingerprint = self.localFingerprint { if let localFingerprint = self.localFingerprint {
builder.localFingerprint = localFingerprint.asProtobuf builder.localFingerprint = localFingerprint.asProtobuf
} }
if let remoteFingerprint = self.remoteFingerprint { if let remoteFingerprint = self.remoteFingerprint {
builder.remoteFingerprint = remoteFingerprint.asProtobuf builder.remoteFingerprint = remoteFingerprint.asProtobuf
} }
} }
return proto return proto
} }
} }

@ -14,177 +14,177 @@ public enum ProvisioningProtoError: Error {
@objc public class ProvisioningProtoProvisionEnvelope: NSObject { @objc public class ProvisioningProtoProvisionEnvelope: NSObject {
@objc public let publicKey: Data? @objc public let publicKey: Data?
@objc public let body: Data? @objc public let body: Data?
@objc public init(publicKey: Data?, @objc public init(publicKey: Data?,
body: Data?) { body: Data?) {
self.publicKey = publicKey self.publicKey = publicKey
self.body = body self.body = body
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope { @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionEnvelope {
let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData) let proto = try ProvisioningProtos_ProvisionEnvelope(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope { fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionEnvelope) throws -> ProvisioningProtoProvisionEnvelope {
var publicKey: Data? = nil var publicKey: Data? = nil
if proto.hasPublicKey { if proto.hasPublicKey {
publicKey = proto.publicKey publicKey = proto.publicKey
} }
var body: Data? = nil var body: Data? = nil
if proto.hasBody { if proto.hasBody {
body = proto.body body = proto.body
} }
// MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope -
// MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope - // MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope -
let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey, let result = ProvisioningProtoProvisionEnvelope(publicKey: publicKey,
body: body) body: body)
return result return result
} }
fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope { fileprivate var asProtobuf: ProvisioningProtos_ProvisionEnvelope {
let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in let proto = ProvisioningProtos_ProvisionEnvelope.with { (builder) in
if let publicKey = self.publicKey { if let publicKey = self.publicKey {
builder.publicKey = publicKey builder.publicKey = publicKey
} }
if let body = self.body { if let body = self.body {
builder.body = body builder.body = body
} }
} }
return proto return proto
} }
} }
// MARK: - ProvisioningProtoProvisionMessage // MARK: - ProvisioningProtoProvisionMessage
@objc public class ProvisioningProtoProvisionMessage: NSObject { @objc public class ProvisioningProtoProvisionMessage: NSObject {
@objc public let identityKeyPublic: Data? @objc public let identityKeyPublic: Data?
@objc public let identityKeyPrivate: Data? @objc public let identityKeyPrivate: Data?
@objc public let number: String? @objc public let number: String?
@objc public let provisioningCode: String? @objc public let provisioningCode: String?
@objc public let userAgent: String? @objc public let userAgent: String?
@objc public let profileKey: Data? @objc public let profileKey: Data?
@objc public let readReceipts: Bool @objc public let readReceipts: Bool
@objc public init(identityKeyPublic: Data?, @objc public init(identityKeyPublic: Data?,
identityKeyPrivate: Data?, identityKeyPrivate: Data?,
number: String?, number: String?,
provisioningCode: String?, provisioningCode: String?,
userAgent: String?, userAgent: String?,
profileKey: Data?, profileKey: Data?,
readReceipts: Bool) { readReceipts: Bool) {
self.identityKeyPublic = identityKeyPublic self.identityKeyPublic = identityKeyPublic
self.identityKeyPrivate = identityKeyPrivate self.identityKeyPrivate = identityKeyPrivate
self.number = number self.number = number
self.provisioningCode = provisioningCode self.provisioningCode = provisioningCode
self.userAgent = userAgent self.userAgent = userAgent
self.profileKey = profileKey self.profileKey = profileKey
self.readReceipts = readReceipts self.readReceipts = readReceipts
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage { @objc public class func parseData(_ serializedData: Data) throws -> ProvisioningProtoProvisionMessage {
let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData) let proto = try ProvisioningProtos_ProvisionMessage(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage { fileprivate class func parseProto(_ proto: ProvisioningProtos_ProvisionMessage) throws -> ProvisioningProtoProvisionMessage {
var identityKeyPublic: Data? = nil var identityKeyPublic: Data? = nil
if proto.hasIdentityKeyPublic { if proto.hasIdentityKeyPublic {
identityKeyPublic = proto.identityKeyPublic identityKeyPublic = proto.identityKeyPublic
} }
var identityKeyPrivate: Data? = nil var identityKeyPrivate: Data? = nil
if proto.hasIdentityKeyPrivate { if proto.hasIdentityKeyPrivate {
identityKeyPrivate = proto.identityKeyPrivate identityKeyPrivate = proto.identityKeyPrivate
} }
var number: String? = nil var number: String? = nil
if proto.hasNumber { if proto.hasNumber {
number = proto.number number = proto.number
} }
var provisioningCode: String? = nil var provisioningCode: String? = nil
if proto.hasProvisioningCode { if proto.hasProvisioningCode {
provisioningCode = proto.provisioningCode provisioningCode = proto.provisioningCode
} }
var userAgent: String? = nil var userAgent: String? = nil
if proto.hasUserAgent { if proto.hasUserAgent {
userAgent = proto.userAgent userAgent = proto.userAgent
} }
var profileKey: Data? = nil var profileKey: Data? = nil
if proto.hasProfileKey { if proto.hasProfileKey {
profileKey = proto.profileKey profileKey = proto.profileKey
} }
var readReceipts: Bool = false var readReceipts: Bool = false
if proto.hasReadReceipts { if proto.hasReadReceipts {
readReceipts = proto.readReceipts readReceipts = proto.readReceipts
} }
// MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage - // MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage -
// MARK: - End Validation Logic for ProvisioningProtoProvisionMessage - // MARK: - End Validation Logic for ProvisioningProtoProvisionMessage -
let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic, let result = ProvisioningProtoProvisionMessage(identityKeyPublic: identityKeyPublic,
identityKeyPrivate: identityKeyPrivate, identityKeyPrivate: identityKeyPrivate,
number: number, number: number,
provisioningCode: provisioningCode, provisioningCode: provisioningCode,
userAgent: userAgent, userAgent: userAgent,
profileKey: profileKey, profileKey: profileKey,
readReceipts: readReceipts) readReceipts: readReceipts)
return result return result
} }
fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage { fileprivate var asProtobuf: ProvisioningProtos_ProvisionMessage {
let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in let proto = ProvisioningProtos_ProvisionMessage.with { (builder) in
if let identityKeyPublic = self.identityKeyPublic { if let identityKeyPublic = self.identityKeyPublic {
builder.identityKeyPublic = identityKeyPublic builder.identityKeyPublic = identityKeyPublic
} }
if let identityKeyPrivate = self.identityKeyPrivate { if let identityKeyPrivate = self.identityKeyPrivate {
builder.identityKeyPrivate = identityKeyPrivate builder.identityKeyPrivate = identityKeyPrivate
} }
if let number = self.number { if let number = self.number {
builder.number = number builder.number = number
} }
if let provisioningCode = self.provisioningCode { if let provisioningCode = self.provisioningCode {
builder.provisioningCode = provisioningCode builder.provisioningCode = provisioningCode
} }
if let userAgent = self.userAgent { if let userAgent = self.userAgent {
builder.userAgent = userAgent builder.userAgent = userAgent
} }
if let profileKey = self.profileKey { if let profileKey = self.profileKey {
builder.profileKey = profileKey builder.profileKey = profileKey
} }
builder.readReceipts = self.readReceipts builder.readReceipts = self.readReceipts
} }
return proto return proto
} }
} }

@ -14,132 +14,132 @@ public enum SignalIOSProtoError: Error {
@objc public class SignalIOSProtoBackupSnapshotBackupEntity: NSObject { @objc public class SignalIOSProtoBackupSnapshotBackupEntity: NSObject {
// MARK: - SignalIOSProtoBackupSnapshotBackupEntityType // MARK: - SignalIOSProtoBackupSnapshotBackupEntityType
@objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 { @objc public enum SignalIOSProtoBackupSnapshotBackupEntityType: Int32 {
case unknown = 0 case unknown = 0
case migration = 1 case migration = 1
case thread = 2 case thread = 2
case interaction = 3 case interaction = 3
case attachment = 4 case attachment = 4
} }
private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType { private class func SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(_ value: IOSProtos_BackupSnapshot.BackupEntity.TypeEnum) -> SignalIOSProtoBackupSnapshotBackupEntityType {
switch value { switch value {
case .unknown: return .unknown case .unknown: return .unknown
case .migration: return .migration case .migration: return .migration
case .thread: return .thread case .thread: return .thread
case .interaction: return .interaction case .interaction: return .interaction
case .attachment: return .attachment case .attachment: return .attachment
} }
} }
private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum { private class func SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(_ value: SignalIOSProtoBackupSnapshotBackupEntityType) -> IOSProtos_BackupSnapshot.BackupEntity.TypeEnum {
switch value { switch value {
case .unknown: return .unknown case .unknown: return .unknown
case .migration: return .migration case .migration: return .migration
case .thread: return .thread case .thread: return .thread
case .interaction: return .interaction case .interaction: return .interaction
case .attachment: return .attachment case .attachment: return .attachment
} }
} }
@objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType @objc public let type: SignalIOSProtoBackupSnapshotBackupEntityType
@objc public let entityData: Data? @objc public let entityData: Data?
@objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType, @objc public init(type: SignalIOSProtoBackupSnapshotBackupEntityType,
entityData: Data?) { entityData: Data?) {
self.type = type self.type = type
self.entityData = entityData self.entityData = entityData
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity { @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshotBackupEntity {
let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData) let proto = try IOSProtos_BackupSnapshot.BackupEntity(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity { fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot.BackupEntity) throws -> SignalIOSProtoBackupSnapshotBackupEntity {
var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown var type: SignalIOSProtoBackupSnapshotBackupEntityType = .unknown
if proto.hasType { if proto.hasType {
type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type) type = SignalIOSProtoBackupSnapshotBackupEntityTypeWrap(proto.type)
} }
var entityData: Data? = nil var entityData: Data? = nil
if proto.hasEntityData { if proto.hasEntityData {
entityData = proto.entityData entityData = proto.entityData
} }
// MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - // MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity -
// MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity - // MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity -
let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type, let result = SignalIOSProtoBackupSnapshotBackupEntity(type: type,
entityData: entityData) entityData: entityData)
return result return result
} }
fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity { fileprivate var asProtobuf: IOSProtos_BackupSnapshot.BackupEntity {
let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in let proto = IOSProtos_BackupSnapshot.BackupEntity.with { (builder) in
builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type) builder.type = SignalIOSProtoBackupSnapshotBackupEntity.SignalIOSProtoBackupSnapshotBackupEntityTypeUnwrap(self.type)
if let entityData = self.entityData { if let entityData = self.entityData {
builder.entityData = entityData builder.entityData = entityData
} }
} }
return proto return proto
} }
} }
// MARK: - SignalIOSProtoBackupSnapshot // MARK: - SignalIOSProtoBackupSnapshot
@objc public class SignalIOSProtoBackupSnapshot: NSObject { @objc public class SignalIOSProtoBackupSnapshot: NSObject {
@objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity] @objc public let entity: [SignalIOSProtoBackupSnapshotBackupEntity]
@objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) { @objc public init(entity: [SignalIOSProtoBackupSnapshotBackupEntity]) {
self.entity = entity self.entity = entity
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot { @objc public class func parseData(_ serializedData: Data) throws -> SignalIOSProtoBackupSnapshot {
let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData) let proto = try IOSProtos_BackupSnapshot(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot { fileprivate class func parseProto(_ proto: IOSProtos_BackupSnapshot) throws -> SignalIOSProtoBackupSnapshot {
var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = [] var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = []
for item in proto.entity { for item in proto.entity {
let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item) let wrapped = try SignalIOSProtoBackupSnapshotBackupEntity.parseProto(item)
entity.append(wrapped) 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) let result = SignalIOSProtoBackupSnapshot(entity: entity)
return result return result
} }
fileprivate var asProtobuf: IOSProtos_BackupSnapshot { fileprivate var asProtobuf: IOSProtos_BackupSnapshot {
let proto = IOSProtos_BackupSnapshot.with { (builder) in let proto = IOSProtos_BackupSnapshot.with { (builder) in
var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]() var entityUnwrapped = [IOSProtos_BackupSnapshot.BackupEntity]()
for item in entity { for item in entity {
entityUnwrapped.append(item.asProtobuf) entityUnwrapped.append(item.asProtobuf)
} }
builder.entity = entityUnwrapped builder.entity = entityUnwrapped
} }
return proto return proto
} }
} }

@ -14,285 +14,285 @@ public enum WebSocketProtoError: Error {
@objc public class WebSocketProtoWebSocketRequestMessage: NSObject { @objc public class WebSocketProtoWebSocketRequestMessage: NSObject {
@objc public let verb: String? @objc public let verb: String?
@objc public let path: String? @objc public let path: String?
@objc public let body: Data? @objc public let body: Data?
@objc public let headers: [String] @objc public let headers: [String]
@objc public let requestId: UInt64 @objc public let requestId: UInt64
@objc public init(verb: String?, @objc public init(verb: String?,
path: String?, path: String?,
body: Data?, body: Data?,
headers: [String], headers: [String],
requestId: UInt64) { requestId: UInt64) {
self.verb = verb self.verb = verb
self.path = path self.path = path
self.body = body self.body = body
self.headers = headers self.headers = headers
self.requestId = requestId self.requestId = requestId
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage { @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketRequestMessage {
let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData) let proto = try WebSocketProtos_WebSocketRequestMessage(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage { fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketRequestMessage) throws -> WebSocketProtoWebSocketRequestMessage {
var verb: String? = nil var verb: String? = nil
if proto.hasVerb { if proto.hasVerb {
verb = proto.verb verb = proto.verb
} }
var path: String? = nil var path: String? = nil
if proto.hasPath { if proto.hasPath {
path = proto.path path = proto.path
} }
var body: Data? = nil var body: Data? = nil
if proto.hasBody { if proto.hasBody {
body = proto.body body = proto.body
} }
var headers: [String] = [] var headers: [String] = []
for item in proto.headers { for item in proto.headers {
let wrapped = item let wrapped = item
headers.append(wrapped) headers.append(wrapped)
} }
var requestId: UInt64 = 0 var requestId: UInt64 = 0
if proto.hasRequestId { if proto.hasRequestId {
requestId = proto.requestId requestId = proto.requestId
} }
// MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage -
// MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage - // MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage -
let result = WebSocketProtoWebSocketRequestMessage(verb: verb, let result = WebSocketProtoWebSocketRequestMessage(verb: verb,
path: path, path: path,
body: body, body: body,
headers: headers, headers: headers,
requestId: requestId) requestId: requestId)
return result return result
} }
fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage { fileprivate var asProtobuf: WebSocketProtos_WebSocketRequestMessage {
let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in let proto = WebSocketProtos_WebSocketRequestMessage.with { (builder) in
if let verb = self.verb { if let verb = self.verb {
builder.verb = verb builder.verb = verb
} }
if let path = self.path { if let path = self.path {
builder.path = path builder.path = path
} }
if let body = self.body { if let body = self.body {
builder.body = body builder.body = body
} }
var headersUnwrapped = [String]() var headersUnwrapped = [String]()
for item in headers { for item in headers {
headersUnwrapped.append(item) headersUnwrapped.append(item)
} }
builder.headers = headersUnwrapped builder.headers = headersUnwrapped
builder.requestId = self.requestId builder.requestId = self.requestId
} }
return proto return proto
} }
} }
// MARK: - WebSocketProtoWebSocketResponseMessage // MARK: - WebSocketProtoWebSocketResponseMessage
@objc public class WebSocketProtoWebSocketResponseMessage: NSObject { @objc public class WebSocketProtoWebSocketResponseMessage: NSObject {
@objc public let requestId: UInt64 @objc public let requestId: UInt64
@objc public let status: UInt32 @objc public let status: UInt32
@objc public let message: String? @objc public let message: String?
@objc public let headers: [String] @objc public let headers: [String]
@objc public let body: Data? @objc public let body: Data?
@objc public init(requestId: UInt64, @objc public init(requestId: UInt64,
status: UInt32, status: UInt32,
message: String?, message: String?,
headers: [String], headers: [String],
body: Data?) { body: Data?) {
self.requestId = requestId self.requestId = requestId
self.status = status self.status = status
self.message = message self.message = message
self.headers = headers self.headers = headers
self.body = body self.body = body
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage { @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketResponseMessage {
let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData) let proto = try WebSocketProtos_WebSocketResponseMessage(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage { fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketResponseMessage) throws -> WebSocketProtoWebSocketResponseMessage {
var requestId: UInt64 = 0 var requestId: UInt64 = 0
if proto.hasRequestId { if proto.hasRequestId {
requestId = proto.requestId requestId = proto.requestId
} }
var status: UInt32 = 0 var status: UInt32 = 0
if proto.hasStatus { if proto.hasStatus {
status = proto.status status = proto.status
} }
var message: String? = nil var message: String? = nil
if proto.hasMessage { if proto.hasMessage {
message = proto.message message = proto.message
} }
var headers: [String] = [] var headers: [String] = []
for item in proto.headers { for item in proto.headers {
let wrapped = item let wrapped = item
headers.append(wrapped) headers.append(wrapped)
} }
var body: Data? = nil var body: Data? = nil
if proto.hasBody { if proto.hasBody {
body = proto.body body = proto.body
} }
// MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage -
// MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage - // MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage -
let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId, let result = WebSocketProtoWebSocketResponseMessage(requestId: requestId,
status: status, status: status,
message: message, message: message,
headers: headers, headers: headers,
body: body) body: body)
return result return result
} }
fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage { fileprivate var asProtobuf: WebSocketProtos_WebSocketResponseMessage {
let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in let proto = WebSocketProtos_WebSocketResponseMessage.with { (builder) in
builder.requestId = self.requestId builder.requestId = self.requestId
builder.status = self.status builder.status = self.status
if let message = self.message { if let message = self.message {
builder.message = message builder.message = message
} }
var headersUnwrapped = [String]() var headersUnwrapped = [String]()
for item in headers { for item in headers {
headersUnwrapped.append(item) headersUnwrapped.append(item)
} }
builder.headers = headersUnwrapped builder.headers = headersUnwrapped
if let body = self.body { if let body = self.body {
builder.body = body builder.body = body
} }
} }
return proto return proto
} }
} }
// MARK: - WebSocketProtoWebSocketMessage // MARK: - WebSocketProtoWebSocketMessage
@objc public class WebSocketProtoWebSocketMessage: NSObject { @objc public class WebSocketProtoWebSocketMessage: NSObject {
// MARK: - WebSocketProtoWebSocketMessageType // MARK: - WebSocketProtoWebSocketMessageType
@objc public enum WebSocketProtoWebSocketMessageType: Int32 { @objc public enum WebSocketProtoWebSocketMessageType: Int32 {
case unknown = 0 case unknown = 0
case request = 1 case request = 1
case response = 2 case response = 2
} }
private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType { private class func WebSocketProtoWebSocketMessageTypeWrap(_ value: WebSocketProtos_WebSocketMessage.TypeEnum) -> WebSocketProtoWebSocketMessageType {
switch value { switch value {
case .unknown: return .unknown case .unknown: return .unknown
case .request: return .request case .request: return .request
case .response: return .response case .response: return .response
} }
} }
private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum { private class func WebSocketProtoWebSocketMessageTypeUnwrap(_ value: WebSocketProtoWebSocketMessageType) -> WebSocketProtos_WebSocketMessage.TypeEnum {
switch value { switch value {
case .unknown: return .unknown case .unknown: return .unknown
case .request: return .request case .request: return .request
case .response: return .response case .response: return .response
} }
} }
@objc public let type: WebSocketProtoWebSocketMessageType @objc public let type: WebSocketProtoWebSocketMessageType
@objc public let request: WebSocketProtoWebSocketRequestMessage? @objc public let request: WebSocketProtoWebSocketRequestMessage?
@objc public let response: WebSocketProtoWebSocketResponseMessage? @objc public let response: WebSocketProtoWebSocketResponseMessage?
@objc public init(type: WebSocketProtoWebSocketMessageType, @objc public init(type: WebSocketProtoWebSocketMessageType,
request: WebSocketProtoWebSocketRequestMessage?, request: WebSocketProtoWebSocketRequestMessage?,
response: WebSocketProtoWebSocketResponseMessage?) { response: WebSocketProtoWebSocketResponseMessage?) {
self.type = type self.type = type
self.request = request self.request = request
self.response = response self.response = response
} }
@objc @objc
public func serializedData() throws -> Data { public func serializedData() throws -> Data {
return try self.asProtobuf.serializedData() return try self.asProtobuf.serializedData()
} }
@objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage { @objc public class func parseData(_ serializedData: Data) throws -> WebSocketProtoWebSocketMessage {
let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData) let proto = try WebSocketProtos_WebSocketMessage(serializedData: serializedData)
return try parseProto(proto) return try parseProto(proto)
} }
fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage { fileprivate class func parseProto(_ proto: WebSocketProtos_WebSocketMessage) throws -> WebSocketProtoWebSocketMessage {
var type: WebSocketProtoWebSocketMessageType = .unknown var type: WebSocketProtoWebSocketMessageType = .unknown
if proto.hasType { if proto.hasType {
type = WebSocketProtoWebSocketMessageTypeWrap(proto.type) type = WebSocketProtoWebSocketMessageTypeWrap(proto.type)
} }
var request: WebSocketProtoWebSocketRequestMessage? = nil var request: WebSocketProtoWebSocketRequestMessage? = nil
if proto.hasRequest { if proto.hasRequest {
request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request) request = try WebSocketProtoWebSocketRequestMessage.parseProto(proto.request)
} }
var response: WebSocketProtoWebSocketResponseMessage? = nil var response: WebSocketProtoWebSocketResponseMessage? = nil
if proto.hasResponse { if proto.hasResponse {
response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response) response = try WebSocketProtoWebSocketResponseMessage.parseProto(proto.response)
} }
// MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage - // MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage -
// MARK: - End Validation Logic for WebSocketProtoWebSocketMessage - // MARK: - End Validation Logic for WebSocketProtoWebSocketMessage -
let result = WebSocketProtoWebSocketMessage(type: type, let result = WebSocketProtoWebSocketMessage(type: type,
request: request, request: request,
response: response) response: response)
return result return result
} }
fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage { fileprivate var asProtobuf: WebSocketProtos_WebSocketMessage {
let proto = WebSocketProtos_WebSocketMessage.with { (builder) in let proto = WebSocketProtos_WebSocketMessage.with { (builder) in
builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type) builder.type = WebSocketProtoWebSocketMessage.WebSocketProtoWebSocketMessageTypeUnwrap(self.type)
if let request = self.request { if let request = self.request {
builder.request = request.asProtobuf builder.request = request.asProtobuf
} }
if let response = self.response { if let response = self.response {
builder.response = response.asProtobuf builder.response = response.asProtobuf
} }
} }
return proto return proto
} }
} }

Loading…
Cancel
Save