Add buildInfallibly to proto wrappers

This commit is contained in:
Max Radermacher
2023-02-06 11:37:42 -08:00
committed by GitHub
parent b95a1c4363
commit 2f8d76fed0
12 changed files with 1029 additions and 1206 deletions

View File

@@ -359,6 +359,13 @@ class BaseContext(object):
return True
return False
def is_field_a_proto_whose_init_throws(self, field):
matching_context = self.context_for_proto_type(field)
if matching_context is not None:
if type(matching_context) is MessageContext:
return matching_context.can_init_throw()
return False
def can_field_be_optional_objc(self, field):
return self.can_field_be_optional(field) and not self.is_field_primitive(field) and not self.is_field_an_enum(field)
@@ -488,6 +495,14 @@ class MessageContext(BaseContext):
def children(self):
return self.enums + self.messages + self.oneofs
def can_init_throw(self):
for field in self.fields():
if self.is_field_a_proto_whose_init_throws(field):
return True
if field.is_required and proto_syntax == "proto2":
return True
return False
def prepare(self):
self.swift_name = self.derive_swift_name()
self.swift_builder_name = "%sBuilder" % self.swift_name
@@ -830,16 +845,23 @@ public func serializedData() throws -> Data {
writer.add('public init(serializedData: Data) throws {')
writer.push_indent()
writer.add('let proto = try %s(serializedData: serializedData)' % ( wrapped_swift_name, ) )
writer.add('try self.init(proto)')
if self.can_init_throw():
writer.add('try self.init(proto)')
else:
writer.add('self.init(proto)')
writer.pop_indent()
writer.add('}')
writer.newline()
# init(proto:) func
chunks = ["fileprivate"]
if writer.needs_objc():
writer.add('fileprivate convenience init(_ proto: %s) throws {' % ( wrapped_swift_name, ) )
else:
writer.add('fileprivate init(_ proto: %s) throws {' % ( wrapped_swift_name, ) )
chunks.append("convenience")
chunks.append(f"init(_ proto: {wrapped_swift_name})")
if self.can_init_throw():
chunks.append("throws")
chunks.append("{")
writer.add(" ".join(chunks))
writer.push_indent()
for field in explict_fields:
@@ -856,8 +878,10 @@ public func serializedData() throws -> Data {
# TODO: Assert that rules is empty.
enum_context = self.context_for_proto_type(field)
writer.add('let %s = %s(proto.%s)' % ( field.name_swift, enum_context.wrap_func_name(), field.name_swift, ) )
elif self.is_field_a_proto(field):
elif self.is_field_a_proto_whose_init_throws(field):
writer.add('let %s = try %s(proto.%s)' % (field.name_swift, self.base_swift_type_for_field(field), field.name_swift)),
elif self.is_field_a_proto(field):
writer.add('let %s = %s(proto.%s)' % (field.name_swift, self.base_swift_type_for_field(field), field.name_swift)),
else:
writer.add('let %s = proto.%s' % ( field.name_swift, field.name_swift, ) )
writer.newline()
@@ -873,8 +897,10 @@ public func serializedData() throws -> Data {
if self.is_field_an_enum(field):
enum_context = self.context_for_proto_type(field)
writer.add('%s = proto.%s.map { %s($0) }' % ( field.name_swift, field.name_swift, enum_context.wrap_func_name(), ) )
elif self.is_field_a_proto(field):
elif self.is_field_a_proto_whose_init_throws(field):
writer.add('%s = try proto.%s.map { try %s($0) }' % ( field.name_swift, field.name_swift, self.base_swift_type_for_field(field), ) )
elif self.is_field_a_proto(field):
writer.add('%s = proto.%s.map { %s($0) }' % ( field.name_swift, field.name_swift, self.base_swift_type_for_field(field), ) )
else:
writer.add('%s = proto.%s' % ( field.name_swift, field.name_swift, ) )
else:
@@ -885,8 +911,10 @@ public func serializedData() throws -> Data {
# TODO: Assert that rules is empty.
enum_context = self.context_for_proto_type(field)
writer.add('%s = %s(proto.%s)' % ( field.name_swift, enum_context.wrap_func_name(), field.name_swift, ) )
elif self.is_field_a_proto(field):
elif self.is_field_a_proto_whose_init_throws(field):
writer.add('%s = try %s(proto.%s)' % (field.name_swift, self.base_swift_type_for_field(field), field.name_swift)),
elif self.is_field_a_proto(field):
writer.add('%s = %s(proto.%s)' % (field.name_swift, self.base_swift_type_for_field(field), field.name_swift)),
else:
writer.add('%s = proto.%s' % ( field.name_swift, field.name_swift, ) )
@@ -894,19 +922,6 @@ public func serializedData() throws -> Data {
writer.add('}')
writer.newline()
writer.add('// MARK: - Begin Validation Logic for %s -' % self.swift_name)
writer.newline()
# Preserve existing validation logic.
if self.swift_name in args.validation_map:
validation_block = args.validation_map[self.swift_name]
if validation_block:
writer.add_raw(validation_block)
writer.newline()
writer.add('// MARK: - End Validation Logic for %s -' % self.swift_name)
writer.newline()
initializer_prefix = 'self.init('
initializer_arguments = []
initializer_arguments.append('proto: proto')
@@ -1011,7 +1026,10 @@ public func serializedData() throws -> Data {
with writer.braced('extension %s' % self.swift_builder_name ) as writer:
writer.add_objc()
with writer.braced('public func buildIgnoringErrors() -> %s?' % self.swift_name) as writer:
writer.add('return try! self.build()')
if self.can_init_throw():
writer.add('return try! self.build()')
else:
writer.add('return self.buildInfallibly()')
writer.newline()
writer.add('#endif')
@@ -1255,11 +1273,23 @@ public func serializedData() throws -> Data {
writer.add_objc()
writer.add('public func build() throws -> %s {' % self.swift_name)
writer.push_indent()
writer.add('return try %s(proto)' % self.swift_name)
if self.can_init_throw():
writer.add('return try %s(proto)' % self.swift_name)
else:
writer.add('return %s(proto)' % self.swift_name)
writer.pop_indent()
writer.add('}')
writer.newline()
if not self.can_init_throw():
writer.add_objc()
writer.add('public func buildInfallibly() -> %s {' % self.swift_name)
writer.push_indent()
writer.add('return %s(proto)' % self.swift_name)
writer.pop_indent()
writer.add('}')
writer.newline()
# buildSerializedData() func
writer.add_objc()
writer.add('public func buildSerializedData() throws -> Data {')
@@ -1501,7 +1531,7 @@ class OneOfContext(BaseContext):
return None
def case_pairs(self):
def case_tuples(self):
result = []
for index in self.sorted_item_indices():
index_str = str(index)
@@ -1509,9 +1539,11 @@ class OneOfContext(BaseContext):
item_type = self.item_type_map[item_name]
case_name = lower_camel_case(item_name)
case_type = swift_type_for_proto_primitive_type(item_type)
case_throws = False
if case_type is None:
case_type = self.context_for_proto_type(item_type).swift_name
result.append( (case_name, case_type,) )
case_throws = self.is_field_a_proto_whose_init_throws(item_type)
result.append( (case_name, case_type, case_throws) )
return result
def generate(self, writer):
@@ -1525,7 +1557,7 @@ class OneOfContext(BaseContext):
writer.push_context(self.proto_name, self.swift_name)
for case_name, case_type in self.case_pairs():
for case_name, case_type, _ in self.case_tuples():
writer.add('case %s(%s)' % ( case_name, case_type, ) )
@@ -1534,16 +1566,19 @@ class OneOfContext(BaseContext):
writer.rstrip()
writer.add('}')
writer.newline()
wrapped_swift_name = self.derive_wrapped_swift_name()
# TODO: Only mark this throws if one of the cases throws.
writer.add('private func %sWrap(_ value: %s) throws -> %s {' % ( self.swift_name, wrapped_swift_name, self.swift_name, ) )
writer.push_indent()
writer.add('switch value {')
for case_name, case_type in self.case_pairs():
for case_name, case_type, case_throws in self.case_tuples():
if is_swift_primitive_type(case_type):
writer.add('case .%s(let value): return .%s(value)' % (case_name, case_name, ) )
else:
elif case_throws:
writer.add('case .%s(let value): return .%s(try %s(value))' % (case_name, case_name, case_type, ) )
else:
writer.add('case .%s(let value): return .%s(%s(value))' % (case_name, case_name, case_type, ) )
writer.add('}')
writer.pop_indent()
@@ -1553,7 +1588,7 @@ class OneOfContext(BaseContext):
writer.add('private func %sUnwrap(_ value: %s) -> %s {' % ( self.swift_name, self.swift_name, wrapped_swift_name, ) )
writer.push_indent()
writer.add('switch value {')
for case_name, case_type in self.case_pairs():
for case_name, case_type, case_throws in self.case_tuples():
if is_swift_primitive_type(case_type):
writer.add('case .%s(let value): return .%s(value)' % (case_name, case_name,))
else:
@@ -1820,43 +1855,6 @@ def parse_message(args, proto_file_path, parser, parent_context, message_name):
raise Exception('Invalid message syntax[%s]: %s' % (proto_file_path, line))
def preserve_validation_logic(args, proto_file_path, dst_file_path):
args.validation_map = {}
if os.path.exists(dst_file_path):
with open(dst_file_path, 'rt') as f:
old_text = f.read()
for match in validation_start_regex.finditer(old_text):
# print 'match'
name = match.group(1)
# print '\t name:', name
start = match.end(0)
# print '\t start:', start
end_marker = '// MARK: - End Validation Logic for %s -' % name
end = old_text.find(end_marker)
# print '\t end:', end
if end < start:
raise Exception('Malformed validation: %s, %s' % ( proto_file_path, name, ) )
validation_block = old_text[start:end]
# print '\t validation_block:', validation_block
# Strip trailing whitespace.
validation_lines = validation_block.split('\n')
validation_lines = [line.rstrip() for line in validation_lines]
# Strip leading empty lines.
while len(validation_lines) > 0 and validation_lines[0] == '':
validation_lines = validation_lines[1:]
# Strip trailing empty lines.
while len(validation_lines) > 0 and validation_lines[-1] == '':
validation_lines = validation_lines[:-1]
validation_block = '\n'.join(validation_lines)
if len(validation_block) > 0:
if args.verbose:
print('Preserving validation logic for:', name)
args.validation_map[name] = validation_block
def process_proto_file(args, proto_file_path, dst_file_path):
with open(proto_file_path, 'rt') as f:
text = f.read()
@@ -1912,8 +1910,6 @@ def process_proto_file(args, proto_file_path, dst_file_path):
raise Exception('Invalid syntax[%s]: %s' % (proto_file_path, line))
preserve_validation_logic(args, proto_file_path, dst_file_path)
writer = LineWriter(args)
context.prepare()
context.generate(writer)

View File

@@ -74,14 +74,7 @@ NS_ASSUME_NONNULL_BEGIN
SSKProtoContactDetailsAvatarBuilder *avatarBuilder = [SSKProtoContactDetailsAvatar builder];
[avatarBuilder setContentType:OWSMimeTypeImageJpeg];
[avatarBuilder setLength:(uint32_t)avatarJpegData.length];
NSError *error;
SSKProtoContactDetailsAvatar *_Nullable avatar = [avatarBuilder buildAndReturnError:&error];
if (error || !avatar) {
OWSLogError(@"could not build protobuf: %@", error);
return;
}
[contactBuilder setAvatar:avatar];
[contactBuilder setAvatar:[avatarBuilder buildInfallibly]];
}
if (profileKeyData) {

View File

@@ -1107,13 +1107,7 @@ NSUInteger const TSOutgoingMessageSchemaVersion = 1;
[storyContextBuilder setAuthorUuid:self.storyAuthorUuidString];
[storyContextBuilder setSentTimestamp:self.storyTimestamp.unsignedLongLongValue];
NSError *error;
SSKProtoDataMessageStoryContext *_Nullable storyContext = [storyContextBuilder buildAndReturnError:&error];
if (error || !storyContext) {
OWSFailDebug(@"Could not build storyContext protobuf: %@.", error);
} else {
[builder setStoryContext:storyContext];
}
[builder setStoryContext:[storyContextBuilder buildInfallibly]];
}
[builder setExpireTimer:self.expiresInSeconds];

View File

@@ -49,20 +49,16 @@ public struct DeviceTransferProtoFile: Codable, CustomDebugStringConvertible {
public init(serializedData: Data) throws {
let proto = try DeviceTransferProtos_File(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: DeviceTransferProtos_File) throws {
fileprivate init(_ proto: DeviceTransferProtos_File) {
let identifier = proto.identifier
let relativePath = proto.relativePath
let estimatedSize = proto.estimatedSize
// MARK: - Begin Validation Logic for DeviceTransferProtoFile -
// MARK: - End Validation Logic for DeviceTransferProtoFile -
self.init(proto: proto,
identifier: identifier,
relativePath: relativePath,
@@ -141,7 +137,11 @@ public struct DeviceTransferProtoFileBuilder {
}
public func build() throws -> DeviceTransferProtoFile {
return try DeviceTransferProtoFile(proto)
return DeviceTransferProtoFile(proto)
}
public func buildInfallibly() -> DeviceTransferProtoFile {
return DeviceTransferProtoFile(proto)
}
public func buildSerializedData() throws -> Data {
@@ -159,7 +159,7 @@ extension DeviceTransferProtoFile {
extension DeviceTransferProtoFileBuilder {
public func buildIgnoringErrors() -> DeviceTransferProtoFile? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -197,18 +197,14 @@ public struct DeviceTransferProtoDefault: Codable, CustomDebugStringConvertible
public init(serializedData: Data) throws {
let proto = try DeviceTransferProtos_Default(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: DeviceTransferProtos_Default) throws {
fileprivate init(_ proto: DeviceTransferProtos_Default) {
let key = proto.key
let encodedValue = proto.encodedValue
// MARK: - Begin Validation Logic for DeviceTransferProtoDefault -
// MARK: - End Validation Logic for DeviceTransferProtoDefault -
self.init(proto: proto,
key: key,
encodedValue: encodedValue)
@@ -281,7 +277,11 @@ public struct DeviceTransferProtoDefaultBuilder {
}
public func build() throws -> DeviceTransferProtoDefault {
return try DeviceTransferProtoDefault(proto)
return DeviceTransferProtoDefault(proto)
}
public func buildInfallibly() -> DeviceTransferProtoDefault {
return DeviceTransferProtoDefault(proto)
}
public func buildSerializedData() throws -> Data {
@@ -299,7 +299,7 @@ extension DeviceTransferProtoDefault {
extension DeviceTransferProtoDefaultBuilder {
public func buildIgnoringErrors() -> DeviceTransferProtoDefault? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -341,19 +341,15 @@ public struct DeviceTransferProtoDatabase: Codable, CustomDebugStringConvertible
public init(serializedData: Data) throws {
let proto = try DeviceTransferProtos_Database(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: DeviceTransferProtos_Database) throws {
fileprivate init(_ proto: DeviceTransferProtos_Database) {
let key = proto.key
let database = try DeviceTransferProtoFile(proto.database)
let database = DeviceTransferProtoFile(proto.database)
let wal = try DeviceTransferProtoFile(proto.wal)
// MARK: - Begin Validation Logic for DeviceTransferProtoDatabase -
// MARK: - End Validation Logic for DeviceTransferProtoDatabase -
let wal = DeviceTransferProtoFile(proto.wal)
self.init(proto: proto,
key: key,
@@ -439,7 +435,11 @@ public struct DeviceTransferProtoDatabaseBuilder {
}
public func build() throws -> DeviceTransferProtoDatabase {
return try DeviceTransferProtoDatabase(proto)
return DeviceTransferProtoDatabase(proto)
}
public func buildInfallibly() -> DeviceTransferProtoDatabase {
return DeviceTransferProtoDatabase(proto)
}
public func buildSerializedData() throws -> Data {
@@ -457,7 +457,7 @@ extension DeviceTransferProtoDatabase {
extension DeviceTransferProtoDatabaseBuilder {
public func buildIgnoringErrors() -> DeviceTransferProtoDatabase? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -514,29 +514,25 @@ public struct DeviceTransferProtoManifest: Codable, CustomDebugStringConvertible
public init(serializedData: Data) throws {
let proto = try DeviceTransferProtos_Manifest(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: DeviceTransferProtos_Manifest) throws {
fileprivate init(_ proto: DeviceTransferProtos_Manifest) {
let grdbSchemaVersion = proto.grdbSchemaVersion
var database: DeviceTransferProtoDatabase?
if proto.hasDatabase {
database = try DeviceTransferProtoDatabase(proto.database)
database = DeviceTransferProtoDatabase(proto.database)
}
var appDefaults: [DeviceTransferProtoDefault] = []
appDefaults = try proto.appDefaults.map { try DeviceTransferProtoDefault($0) }
appDefaults = proto.appDefaults.map { DeviceTransferProtoDefault($0) }
var standardDefaults: [DeviceTransferProtoDefault] = []
standardDefaults = try proto.standardDefaults.map { try DeviceTransferProtoDefault($0) }
standardDefaults = proto.standardDefaults.map { DeviceTransferProtoDefault($0) }
var files: [DeviceTransferProtoFile] = []
files = try proto.files.map { try DeviceTransferProtoFile($0) }
// MARK: - Begin Validation Logic for DeviceTransferProtoManifest -
// MARK: - End Validation Logic for DeviceTransferProtoManifest -
files = proto.files.map { DeviceTransferProtoFile($0) }
self.init(proto: proto,
grdbSchemaVersion: grdbSchemaVersion,
@@ -643,7 +639,11 @@ public struct DeviceTransferProtoManifestBuilder {
}
public func build() throws -> DeviceTransferProtoManifest {
return try DeviceTransferProtoManifest(proto)
return DeviceTransferProtoManifest(proto)
}
public func buildInfallibly() -> DeviceTransferProtoManifest {
return DeviceTransferProtoManifest(proto)
}
public func buildSerializedData() throws -> Data {
@@ -661,7 +661,7 @@ extension DeviceTransferProtoManifest {
extension DeviceTransferProtoManifestBuilder {
public func buildIgnoringErrors() -> DeviceTransferProtoManifest? {
return try! self.build()
return self.buildInfallibly()
}
}

View File

@@ -54,10 +54,6 @@ public class FingerprintProtoLogicalFingerprint: NSObject, Codable, NSSecureCodi
}
let identityData = proto.identityData
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprint -
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprint -
self.init(proto: proto,
identityData: identityData)
}
@@ -235,10 +231,6 @@ public class FingerprintProtoLogicalFingerprints: NSObject, Codable, NSSecureCod
}
let remoteFingerprint = try FingerprintProtoLogicalFingerprint(proto.remoteFingerprint)
// MARK: - Begin Validation Logic for FingerprintProtoLogicalFingerprints -
// MARK: - End Validation Logic for FingerprintProtoLogicalFingerprints -
self.init(proto: proto,
version: version,
localFingerprint: localFingerprint,

File diff suppressed because it is too large Load Diff

View File

@@ -55,29 +55,25 @@ public class KeyBackupProtoRequest: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_Request(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_Request) throws {
fileprivate convenience init(_ proto: KeyBackupProtos_Request) {
var backup: KeyBackupProtoBackupRequest?
if proto.hasBackup {
backup = try KeyBackupProtoBackupRequest(proto.backup)
backup = KeyBackupProtoBackupRequest(proto.backup)
}
var restore: KeyBackupProtoRestoreRequest?
if proto.hasRestore {
restore = try KeyBackupProtoRestoreRequest(proto.restore)
restore = KeyBackupProtoRestoreRequest(proto.restore)
}
var delete: KeyBackupProtoDeleteRequest?
if proto.hasDelete {
delete = try KeyBackupProtoDeleteRequest(proto.delete)
delete = KeyBackupProtoDeleteRequest(proto.delete)
}
// MARK: - Begin Validation Logic for KeyBackupProtoRequest -
// MARK: - End Validation Logic for KeyBackupProtoRequest -
self.init(proto: proto,
backup: backup,
restore: restore,
@@ -193,7 +189,12 @@ public class KeyBackupProtoRequestBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoRequest {
return try KeyBackupProtoRequest(proto)
return KeyBackupProtoRequest(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoRequest {
return KeyBackupProtoRequest(proto)
}
@objc
@@ -214,7 +215,7 @@ extension KeyBackupProtoRequest {
extension KeyBackupProtoRequestBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoRequest? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -262,29 +263,25 @@ public class KeyBackupProtoResponse: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_Response(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_Response) throws {
fileprivate convenience init(_ proto: KeyBackupProtos_Response) {
var backup: KeyBackupProtoBackupResponse?
if proto.hasBackup {
backup = try KeyBackupProtoBackupResponse(proto.backup)
backup = KeyBackupProtoBackupResponse(proto.backup)
}
var restore: KeyBackupProtoRestoreResponse?
if proto.hasRestore {
restore = try KeyBackupProtoRestoreResponse(proto.restore)
restore = KeyBackupProtoRestoreResponse(proto.restore)
}
var delete: KeyBackupProtoDeleteResponse?
if proto.hasDelete {
delete = try KeyBackupProtoDeleteResponse(proto.delete)
delete = KeyBackupProtoDeleteResponse(proto.delete)
}
// MARK: - Begin Validation Logic for KeyBackupProtoResponse -
// MARK: - End Validation Logic for KeyBackupProtoResponse -
self.init(proto: proto,
backup: backup,
restore: restore,
@@ -400,7 +397,12 @@ public class KeyBackupProtoResponseBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoResponse {
return try KeyBackupProtoResponse(proto)
return KeyBackupProtoResponse(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoResponse {
return KeyBackupProtoResponse(proto)
}
@objc
@@ -421,7 +423,7 @@ extension KeyBackupProtoResponse {
extension KeyBackupProtoResponseBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoResponse? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -532,14 +534,10 @@ public class KeyBackupProtoBackupRequest: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_BackupRequest(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_BackupRequest) throws {
// MARK: - Begin Validation Logic for KeyBackupProtoBackupRequest -
// MARK: - End Validation Logic for KeyBackupProtoBackupRequest -
fileprivate convenience init(_ proto: KeyBackupProtos_BackupRequest) {
self.init(proto: proto)
}
@@ -696,7 +694,12 @@ public class KeyBackupProtoBackupRequestBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoBackupRequest {
return try KeyBackupProtoBackupRequest(proto)
return KeyBackupProtoBackupRequest(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoBackupRequest {
return KeyBackupProtoBackupRequest(proto)
}
@objc
@@ -717,7 +720,7 @@ extension KeyBackupProtoBackupRequest {
extension KeyBackupProtoBackupRequestBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoBackupRequest? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -807,14 +810,10 @@ public class KeyBackupProtoBackupResponse: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_BackupResponse(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_BackupResponse) throws {
// MARK: - Begin Validation Logic for KeyBackupProtoBackupResponse -
// MARK: - End Validation Logic for KeyBackupProtoBackupResponse -
fileprivate convenience init(_ proto: KeyBackupProtos_BackupResponse) {
self.init(proto: proto)
}
@@ -907,7 +906,12 @@ public class KeyBackupProtoBackupResponseBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoBackupResponse {
return try KeyBackupProtoBackupResponse(proto)
return KeyBackupProtoBackupResponse(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoBackupResponse {
return KeyBackupProtoBackupResponse(proto)
}
@objc
@@ -928,7 +932,7 @@ extension KeyBackupProtoBackupResponse {
extension KeyBackupProtoBackupResponseBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoBackupResponse? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1018,14 +1022,10 @@ public class KeyBackupProtoRestoreRequest: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_RestoreRequest(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_RestoreRequest) throws {
// MARK: - Begin Validation Logic for KeyBackupProtoRestoreRequest -
// MARK: - End Validation Logic for KeyBackupProtoRestoreRequest -
fileprivate convenience init(_ proto: KeyBackupProtos_RestoreRequest) {
self.init(proto: proto)
}
@@ -1160,7 +1160,12 @@ public class KeyBackupProtoRestoreRequestBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoRestoreRequest {
return try KeyBackupProtoRestoreRequest(proto)
return KeyBackupProtoRestoreRequest(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoRestoreRequest {
return KeyBackupProtoRestoreRequest(proto)
}
@objc
@@ -1181,7 +1186,7 @@ extension KeyBackupProtoRestoreRequest {
extension KeyBackupProtoRestoreRequestBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoRestoreRequest? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1298,14 +1303,10 @@ public class KeyBackupProtoRestoreResponse: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_RestoreResponse(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_RestoreResponse) throws {
// MARK: - Begin Validation Logic for KeyBackupProtoRestoreResponse -
// MARK: - End Validation Logic for KeyBackupProtoRestoreResponse -
fileprivate convenience init(_ proto: KeyBackupProtos_RestoreResponse) {
self.init(proto: proto)
}
@@ -1420,7 +1421,12 @@ public class KeyBackupProtoRestoreResponseBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoRestoreResponse {
return try KeyBackupProtoRestoreResponse(proto)
return KeyBackupProtoRestoreResponse(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoRestoreResponse {
return KeyBackupProtoRestoreResponse(proto)
}
@objc
@@ -1441,7 +1447,7 @@ extension KeyBackupProtoRestoreResponse {
extension KeyBackupProtoRestoreResponseBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoRestoreResponse? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1498,14 +1504,10 @@ public class KeyBackupProtoDeleteRequest: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_DeleteRequest(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_DeleteRequest) throws {
// MARK: - Begin Validation Logic for KeyBackupProtoDeleteRequest -
// MARK: - End Validation Logic for KeyBackupProtoDeleteRequest -
fileprivate convenience init(_ proto: KeyBackupProtos_DeleteRequest) {
self.init(proto: proto)
}
@@ -1604,7 +1606,12 @@ public class KeyBackupProtoDeleteRequestBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoDeleteRequest {
return try KeyBackupProtoDeleteRequest(proto)
return KeyBackupProtoDeleteRequest(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoDeleteRequest {
return KeyBackupProtoDeleteRequest(proto)
}
@objc
@@ -1625,7 +1632,7 @@ extension KeyBackupProtoDeleteRequest {
extension KeyBackupProtoDeleteRequestBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoDeleteRequest? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1658,14 +1665,10 @@ public class KeyBackupProtoDeleteResponse: NSObject, Codable, NSSecureCoding {
@objc
public convenience init(serializedData: Data) throws {
let proto = try KeyBackupProtos_DeleteResponse(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate convenience init(_ proto: KeyBackupProtos_DeleteResponse) throws {
// MARK: - Begin Validation Logic for KeyBackupProtoDeleteResponse -
// MARK: - End Validation Logic for KeyBackupProtoDeleteResponse -
fileprivate convenience init(_ proto: KeyBackupProtos_DeleteResponse) {
self.init(proto: proto)
}
@@ -1736,7 +1739,12 @@ public class KeyBackupProtoDeleteResponseBuilder: NSObject {
@objc
public func build() throws -> KeyBackupProtoDeleteResponse {
return try KeyBackupProtoDeleteResponse(proto)
return KeyBackupProtoDeleteResponse(proto)
}
@objc
public func buildInfallibly() -> KeyBackupProtoDeleteResponse {
return KeyBackupProtoDeleteResponse(proto)
}
@objc
@@ -1757,7 +1765,7 @@ extension KeyBackupProtoDeleteResponse {
extension KeyBackupProtoDeleteResponseBuilder {
@objc
public func buildIgnoringErrors() -> KeyBackupProtoDeleteResponse? {
return try! self.build()
return self.buildInfallibly()
}
}

View File

@@ -54,10 +54,6 @@ public class ProvisioningProtoProvisioningUuid: NSObject, Codable, NSSecureCodin
}
let uuid = proto.uuid
// MARK: - Begin Validation Logic for ProvisioningProtoProvisioningUuid -
// MARK: - End Validation Logic for ProvisioningProtoProvisioningUuid -
self.init(proto: proto,
uuid: uuid)
}
@@ -225,10 +221,6 @@ public class ProvisioningProtoProvisionEnvelope: NSObject, Codable, NSSecureCodi
}
let body = proto.body
// MARK: - Begin Validation Logic for ProvisioningProtoProvisionEnvelope -
// MARK: - End Validation Logic for ProvisioningProtoProvisionEnvelope -
self.init(proto: proto,
publicKey: publicKey,
body: body)
@@ -519,10 +511,6 @@ public class ProvisioningProtoProvisionMessage: NSObject, Codable, NSSecureCodin
}
let profileKey = proto.profileKey
// MARK: - Begin Validation Logic for ProvisioningProtoProvisionMessage -
// MARK: - End Validation Logic for ProvisioningProtoProvisionMessage -
self.init(proto: proto,
aciIdentityKeyPublic: aciIdentityKeyPublic,
aciIdentityKeyPrivate: aciIdentityKeyPrivate,

File diff suppressed because it is too large Load Diff

View File

@@ -128,10 +128,6 @@ public class SignalIOSProtoBackupSnapshotBackupEntity: NSObject, Codable, NSSecu
}
let key = proto.key
// MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity -
// MARK: - End Validation Logic for SignalIOSProtoBackupSnapshotBackupEntity -
self.init(proto: proto,
entityData: entityData,
collection: collection,
@@ -321,10 +317,6 @@ public class SignalIOSProtoBackupSnapshot: NSObject, Codable, NSSecureCoding {
var entity: [SignalIOSProtoBackupSnapshotBackupEntity] = []
entity = try proto.entity.map { try SignalIOSProtoBackupSnapshotBackupEntity($0) }
// MARK: - Begin Validation Logic for SignalIOSProtoBackupSnapshot -
// MARK: - End Validation Logic for SignalIOSProtoBackupSnapshot -
self.init(proto: proto,
entity: entity)
}
@@ -495,10 +487,6 @@ public class SignalIOSProtoDeviceName: NSObject, Codable, NSSecureCoding {
}
let ciphertext = proto.ciphertext
// MARK: - Begin Validation Logic for SignalIOSProtoDeviceName -
// MARK: - End Validation Logic for SignalIOSProtoDeviceName -
self.init(proto: proto,
ephemeralPublic: ephemeralPublic,
syntheticIv: syntheticIv,

View File

@@ -95,18 +95,14 @@ public struct StorageServiceProtoStorageItem: Codable, CustomDebugStringConverti
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_StorageItem(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_StorageItem) throws {
fileprivate init(_ proto: StorageServiceProtos_StorageItem) {
let key = proto.key
let value = proto.value
// MARK: - Begin Validation Logic for StorageServiceProtoStorageItem -
// MARK: - End Validation Logic for StorageServiceProtoStorageItem -
self.init(proto: proto,
key: key,
value: value)
@@ -179,7 +175,11 @@ public struct StorageServiceProtoStorageItemBuilder {
}
public func build() throws -> StorageServiceProtoStorageItem {
return try StorageServiceProtoStorageItem(proto)
return StorageServiceProtoStorageItem(proto)
}
public func buildInfallibly() -> StorageServiceProtoStorageItem {
return StorageServiceProtoStorageItem(proto)
}
public func buildSerializedData() throws -> Data {
@@ -197,7 +197,7 @@ extension StorageServiceProtoStorageItem {
extension StorageServiceProtoStorageItemBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoStorageItem? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -231,16 +231,12 @@ public struct StorageServiceProtoStorageItems: Codable, CustomDebugStringConvert
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_StorageItems(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_StorageItems) throws {
fileprivate init(_ proto: StorageServiceProtos_StorageItems) {
var items: [StorageServiceProtoStorageItem] = []
items = try proto.items.map { try StorageServiceProtoStorageItem($0) }
// MARK: - Begin Validation Logic for StorageServiceProtoStorageItems -
// MARK: - End Validation Logic for StorageServiceProtoStorageItems -
items = proto.items.map { StorageServiceProtoStorageItem($0) }
self.init(proto: proto,
items: items)
@@ -296,7 +292,11 @@ public struct StorageServiceProtoStorageItemsBuilder {
}
public func build() throws -> StorageServiceProtoStorageItems {
return try StorageServiceProtoStorageItems(proto)
return StorageServiceProtoStorageItems(proto)
}
public func buildInfallibly() -> StorageServiceProtoStorageItems {
return StorageServiceProtoStorageItems(proto)
}
public func buildSerializedData() throws -> Data {
@@ -314,7 +314,7 @@ extension StorageServiceProtoStorageItems {
extension StorageServiceProtoStorageItemsBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoStorageItems? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -352,18 +352,14 @@ public struct StorageServiceProtoStorageManifest: Codable, CustomDebugStringConv
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_StorageManifest(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_StorageManifest) throws {
fileprivate init(_ proto: StorageServiceProtos_StorageManifest) {
let version = proto.version
let value = proto.value
// MARK: - Begin Validation Logic for StorageServiceProtoStorageManifest -
// MARK: - End Validation Logic for StorageServiceProtoStorageManifest -
self.init(proto: proto,
version: version,
value: value)
@@ -430,7 +426,11 @@ public struct StorageServiceProtoStorageManifestBuilder {
}
public func build() throws -> StorageServiceProtoStorageManifest {
return try StorageServiceProtoStorageManifest(proto)
return StorageServiceProtoStorageManifest(proto)
}
public func buildInfallibly() -> StorageServiceProtoStorageManifest {
return StorageServiceProtoStorageManifest(proto)
}
public func buildSerializedData() throws -> Data {
@@ -448,7 +448,7 @@ extension StorageServiceProtoStorageManifest {
extension StorageServiceProtoStorageManifestBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoStorageManifest? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -482,14 +482,10 @@ public struct StorageServiceProtoReadOperation: Codable, CustomDebugStringConver
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_ReadOperation(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_ReadOperation) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoReadOperation -
// MARK: - End Validation Logic for StorageServiceProtoReadOperation -
fileprivate init(_ proto: StorageServiceProtos_ReadOperation) {
self.init(proto: proto)
}
@@ -543,7 +539,11 @@ public struct StorageServiceProtoReadOperationBuilder {
}
public func build() throws -> StorageServiceProtoReadOperation {
return try StorageServiceProtoReadOperation(proto)
return StorageServiceProtoReadOperation(proto)
}
public func buildInfallibly() -> StorageServiceProtoReadOperation {
return StorageServiceProtoReadOperation(proto)
}
public func buildSerializedData() throws -> Data {
@@ -561,7 +561,7 @@ extension StorageServiceProtoReadOperation {
extension StorageServiceProtoReadOperationBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoReadOperation? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -610,21 +610,17 @@ public struct StorageServiceProtoWriteOperation: Codable, CustomDebugStringConve
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_WriteOperation(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_WriteOperation) throws {
fileprivate init(_ proto: StorageServiceProtos_WriteOperation) {
var manifest: StorageServiceProtoStorageManifest?
if proto.hasManifest {
manifest = try StorageServiceProtoStorageManifest(proto.manifest)
manifest = StorageServiceProtoStorageManifest(proto.manifest)
}
var insertItem: [StorageServiceProtoStorageItem] = []
insertItem = try proto.insertItem.map { try StorageServiceProtoStorageItem($0) }
// MARK: - Begin Validation Logic for StorageServiceProtoWriteOperation -
// MARK: - End Validation Logic for StorageServiceProtoWriteOperation -
insertItem = proto.insertItem.map { StorageServiceProtoStorageItem($0) }
self.init(proto: proto,
manifest: manifest,
@@ -710,7 +706,11 @@ public struct StorageServiceProtoWriteOperationBuilder {
}
public func build() throws -> StorageServiceProtoWriteOperation {
return try StorageServiceProtoWriteOperation(proto)
return StorageServiceProtoWriteOperation(proto)
}
public func buildInfallibly() -> StorageServiceProtoWriteOperation {
return StorageServiceProtoWriteOperation(proto)
}
public func buildSerializedData() throws -> Data {
@@ -728,7 +728,7 @@ extension StorageServiceProtoWriteOperation {
extension StorageServiceProtoWriteOperationBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoWriteOperation? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -831,18 +831,14 @@ public struct StorageServiceProtoManifestRecordKey: Codable, CustomDebugStringCo
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_ManifestRecord.Key(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_ManifestRecord.Key) throws {
fileprivate init(_ proto: StorageServiceProtos_ManifestRecord.Key) {
let data = proto.data
let type = StorageServiceProtoManifestRecordKeyTypeWrap(proto.type)
// MARK: - Begin Validation Logic for StorageServiceProtoManifestRecordKey -
// MARK: - End Validation Logic for StorageServiceProtoManifestRecordKey -
self.init(proto: proto,
data: data,
type: type)
@@ -909,7 +905,11 @@ public struct StorageServiceProtoManifestRecordKeyBuilder {
}
public func build() throws -> StorageServiceProtoManifestRecordKey {
return try StorageServiceProtoManifestRecordKey(proto)
return StorageServiceProtoManifestRecordKey(proto)
}
public func buildInfallibly() -> StorageServiceProtoManifestRecordKey {
return StorageServiceProtoManifestRecordKey(proto)
}
public func buildSerializedData() throws -> Data {
@@ -927,7 +927,7 @@ extension StorageServiceProtoManifestRecordKey {
extension StorageServiceProtoManifestRecordKeyBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoManifestRecordKey? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -972,18 +972,14 @@ public struct StorageServiceProtoManifestRecord: Codable, CustomDebugStringConve
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_ManifestRecord(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_ManifestRecord) throws {
fileprivate init(_ proto: StorageServiceProtos_ManifestRecord) {
let version = proto.version
var keys: [StorageServiceProtoManifestRecordKey] = []
keys = try proto.keys.map { try StorageServiceProtoManifestRecordKey($0) }
// MARK: - Begin Validation Logic for StorageServiceProtoManifestRecord -
// MARK: - End Validation Logic for StorageServiceProtoManifestRecord -
keys = proto.keys.map { StorageServiceProtoManifestRecordKey($0) }
self.init(proto: proto,
version: version,
@@ -1056,7 +1052,11 @@ public struct StorageServiceProtoManifestRecordBuilder {
}
public func build() throws -> StorageServiceProtoManifestRecord {
return try StorageServiceProtoManifestRecord(proto)
return StorageServiceProtoManifestRecord(proto)
}
public func buildInfallibly() -> StorageServiceProtoManifestRecord {
return StorageServiceProtoManifestRecord(proto)
}
public func buildSerializedData() throws -> Data {
@@ -1074,7 +1074,7 @@ extension StorageServiceProtoManifestRecord {
extension StorageServiceProtoManifestRecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoManifestRecord? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1092,11 +1092,11 @@ public enum StorageServiceProtoStorageRecordOneOfRecord {
private func StorageServiceProtoStorageRecordOneOfRecordWrap(_ value: StorageServiceProtos_StorageRecord.OneOf_Record) throws -> StorageServiceProtoStorageRecordOneOfRecord {
switch value {
case .contact(let value): return .contact(try StorageServiceProtoContactRecord(value))
case .groupV1(let value): return .groupV1(try StorageServiceProtoGroupV1Record(value))
case .groupV2(let value): return .groupV2(try StorageServiceProtoGroupV2Record(value))
case .account(let value): return .account(try StorageServiceProtoAccountRecord(value))
case .storyDistributionList(let value): return .storyDistributionList(try StorageServiceProtoStoryDistributionListRecord(value))
case .contact(let value): return .contact(StorageServiceProtoContactRecord(value))
case .groupV1(let value): return .groupV1(StorageServiceProtoGroupV1Record(value))
case .groupV2(let value): return .groupV2(StorageServiceProtoGroupV2Record(value))
case .account(let value): return .account(StorageServiceProtoAccountRecord(value))
case .storyDistributionList(let value): return .storyDistributionList(StorageServiceProtoStoryDistributionListRecord(value))
}
}
@@ -1152,14 +1152,10 @@ public struct StorageServiceProtoStorageRecord: Codable, CustomDebugStringConver
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_StorageRecord(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_StorageRecord) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoStorageRecord -
// MARK: - End Validation Logic for StorageServiceProtoStorageRecord -
fileprivate init(_ proto: StorageServiceProtos_StorageRecord) {
self.init(proto: proto)
}
@@ -1217,7 +1213,11 @@ public struct StorageServiceProtoStorageRecordBuilder {
}
public func build() throws -> StorageServiceProtoStorageRecord {
return try StorageServiceProtoStorageRecord(proto)
return StorageServiceProtoStorageRecord(proto)
}
public func buildInfallibly() -> StorageServiceProtoStorageRecord {
return StorageServiceProtoStorageRecord(proto)
}
public func buildSerializedData() throws -> Data {
@@ -1235,7 +1235,7 @@ extension StorageServiceProtoStorageRecord {
extension StorageServiceProtoStorageRecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoStorageRecord? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1526,14 +1526,10 @@ public struct StorageServiceProtoContactRecord: Codable, CustomDebugStringConver
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_ContactRecord(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_ContactRecord) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoContactRecord -
// MARK: - End Validation Logic for StorageServiceProtoContactRecord -
fileprivate init(_ proto: StorageServiceProtos_ContactRecord) {
self.init(proto: proto)
}
@@ -1772,7 +1768,11 @@ public struct StorageServiceProtoContactRecordBuilder {
}
public func build() throws -> StorageServiceProtoContactRecord {
return try StorageServiceProtoContactRecord(proto)
return StorageServiceProtoContactRecord(proto)
}
public func buildInfallibly() -> StorageServiceProtoContactRecord {
return StorageServiceProtoContactRecord(proto)
}
public func buildSerializedData() throws -> Data {
@@ -1790,7 +1790,7 @@ extension StorageServiceProtoContactRecord {
extension StorageServiceProtoContactRecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoContactRecord? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -1859,16 +1859,12 @@ public struct StorageServiceProtoGroupV1Record: Codable, CustomDebugStringConver
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_GroupV1Record(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_GroupV1Record) throws {
fileprivate init(_ proto: StorageServiceProtos_GroupV1Record) {
let id = proto.id
// MARK: - Begin Validation Logic for StorageServiceProtoGroupV1Record -
// MARK: - End Validation Logic for StorageServiceProtoGroupV1Record -
self.init(proto: proto,
id: id)
}
@@ -1964,7 +1960,11 @@ public struct StorageServiceProtoGroupV1RecordBuilder {
}
public func build() throws -> StorageServiceProtoGroupV1Record {
return try StorageServiceProtoGroupV1Record(proto)
return StorageServiceProtoGroupV1Record(proto)
}
public func buildInfallibly() -> StorageServiceProtoGroupV1Record {
return StorageServiceProtoGroupV1Record(proto)
}
public func buildSerializedData() throws -> Data {
@@ -1982,7 +1982,7 @@ extension StorageServiceProtoGroupV1Record {
extension StorageServiceProtoGroupV1RecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoGroupV1Record? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -2126,16 +2126,12 @@ public struct StorageServiceProtoGroupV2Record: Codable, CustomDebugStringConver
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_GroupV2Record(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_GroupV2Record) throws {
fileprivate init(_ proto: StorageServiceProtos_GroupV2Record) {
let masterKey = proto.masterKey
// MARK: - Begin Validation Logic for StorageServiceProtoGroupV2Record -
// MARK: - End Validation Logic for StorageServiceProtoGroupV2Record -
self.init(proto: proto,
masterKey: masterKey)
}
@@ -2245,7 +2241,11 @@ public struct StorageServiceProtoGroupV2RecordBuilder {
}
public func build() throws -> StorageServiceProtoGroupV2Record {
return try StorageServiceProtoGroupV2Record(proto)
return StorageServiceProtoGroupV2Record(proto)
}
public func buildInfallibly() -> StorageServiceProtoGroupV2Record {
return StorageServiceProtoGroupV2Record(proto)
}
public func buildSerializedData() throws -> Data {
@@ -2263,7 +2263,7 @@ extension StorageServiceProtoGroupV2Record {
extension StorageServiceProtoGroupV2RecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoGroupV2Record? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -2313,14 +2313,10 @@ public struct StorageServiceProtoAccountRecordPinnedConversationContact: Codable
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_AccountRecord.PinnedConversation.Contact(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_AccountRecord.PinnedConversation.Contact) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoAccountRecordPinnedConversationContact -
// MARK: - End Validation Logic for StorageServiceProtoAccountRecordPinnedConversationContact -
fileprivate init(_ proto: StorageServiceProtos_AccountRecord.PinnedConversation.Contact) {
self.init(proto: proto)
}
@@ -2391,7 +2387,11 @@ public struct StorageServiceProtoAccountRecordPinnedConversationContactBuilder {
}
public func build() throws -> StorageServiceProtoAccountRecordPinnedConversationContact {
return try StorageServiceProtoAccountRecordPinnedConversationContact(proto)
return StorageServiceProtoAccountRecordPinnedConversationContact(proto)
}
public func buildInfallibly() -> StorageServiceProtoAccountRecordPinnedConversationContact {
return StorageServiceProtoAccountRecordPinnedConversationContact(proto)
}
public func buildSerializedData() throws -> Data {
@@ -2409,7 +2409,7 @@ extension StorageServiceProtoAccountRecordPinnedConversationContact {
extension StorageServiceProtoAccountRecordPinnedConversationContactBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoAccountRecordPinnedConversationContact? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -2425,7 +2425,7 @@ public enum StorageServiceProtoAccountRecordPinnedConversationOneOfIdentifier {
private func StorageServiceProtoAccountRecordPinnedConversationOneOfIdentifierWrap(_ value: StorageServiceProtos_AccountRecord.PinnedConversation.OneOf_Identifier) throws -> StorageServiceProtoAccountRecordPinnedConversationOneOfIdentifier {
switch value {
case .contact(let value): return .contact(try StorageServiceProtoAccountRecordPinnedConversationContact(value))
case .contact(let value): return .contact(StorageServiceProtoAccountRecordPinnedConversationContact(value))
case .legacyGroupID(let value): return .legacyGroupID(value)
case .groupMasterKey(let value): return .groupMasterKey(value)
}
@@ -2481,14 +2481,10 @@ public struct StorageServiceProtoAccountRecordPinnedConversation: Codable, Custo
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_AccountRecord.PinnedConversation(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_AccountRecord.PinnedConversation) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoAccountRecordPinnedConversation -
// MARK: - End Validation Logic for StorageServiceProtoAccountRecordPinnedConversation -
fileprivate init(_ proto: StorageServiceProtos_AccountRecord.PinnedConversation) {
self.init(proto: proto)
}
@@ -2546,7 +2542,11 @@ public struct StorageServiceProtoAccountRecordPinnedConversationBuilder {
}
public func build() throws -> StorageServiceProtoAccountRecordPinnedConversation {
return try StorageServiceProtoAccountRecordPinnedConversation(proto)
return StorageServiceProtoAccountRecordPinnedConversation(proto)
}
public func buildInfallibly() -> StorageServiceProtoAccountRecordPinnedConversation {
return StorageServiceProtoAccountRecordPinnedConversation(proto)
}
public func buildSerializedData() throws -> Data {
@@ -2564,7 +2564,7 @@ extension StorageServiceProtoAccountRecordPinnedConversation {
extension StorageServiceProtoAccountRecordPinnedConversationBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoAccountRecordPinnedConversation? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -2611,14 +2611,10 @@ public struct StorageServiceProtoAccountRecordPayments: Codable, CustomDebugStri
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_AccountRecord.Payments(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_AccountRecord.Payments) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoAccountRecordPayments -
// MARK: - End Validation Logic for StorageServiceProtoAccountRecordPayments -
fileprivate init(_ proto: StorageServiceProtos_AccountRecord.Payments) {
self.init(proto: proto)
}
@@ -2683,7 +2679,11 @@ public struct StorageServiceProtoAccountRecordPaymentsBuilder {
}
public func build() throws -> StorageServiceProtoAccountRecordPayments {
return try StorageServiceProtoAccountRecordPayments(proto)
return StorageServiceProtoAccountRecordPayments(proto)
}
public func buildInfallibly() -> StorageServiceProtoAccountRecordPayments {
return StorageServiceProtoAccountRecordPayments(proto)
}
public func buildSerializedData() throws -> Data {
@@ -2701,7 +2701,7 @@ extension StorageServiceProtoAccountRecordPayments {
extension StorageServiceProtoAccountRecordPaymentsBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoAccountRecordPayments? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -3018,22 +3018,18 @@ public struct StorageServiceProtoAccountRecord: Codable, CustomDebugStringConver
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_AccountRecord(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_AccountRecord) throws {
fileprivate init(_ proto: StorageServiceProtos_AccountRecord) {
var pinnedConversations: [StorageServiceProtoAccountRecordPinnedConversation] = []
pinnedConversations = try proto.pinnedConversations.map { try StorageServiceProtoAccountRecordPinnedConversation($0) }
pinnedConversations = proto.pinnedConversations.map { StorageServiceProtoAccountRecordPinnedConversation($0) }
var payments: StorageServiceProtoAccountRecordPayments?
if proto.hasPayments {
payments = try StorageServiceProtoAccountRecordPayments(proto.payments)
payments = StorageServiceProtoAccountRecordPayments(proto.payments)
}
// MARK: - Begin Validation Logic for StorageServiceProtoAccountRecord -
// MARK: - End Validation Logic for StorageServiceProtoAccountRecord -
self.init(proto: proto,
pinnedConversations: pinnedConversations,
payments: payments)
@@ -3335,7 +3331,11 @@ public struct StorageServiceProtoAccountRecordBuilder {
}
public func build() throws -> StorageServiceProtoAccountRecord {
return try StorageServiceProtoAccountRecord(proto)
return StorageServiceProtoAccountRecord(proto)
}
public func buildInfallibly() -> StorageServiceProtoAccountRecord {
return StorageServiceProtoAccountRecord(proto)
}
public func buildSerializedData() throws -> Data {
@@ -3353,7 +3353,7 @@ extension StorageServiceProtoAccountRecord {
extension StorageServiceProtoAccountRecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoAccountRecord? {
return try! self.build()
return self.buildInfallibly()
}
}
@@ -3428,14 +3428,10 @@ public struct StorageServiceProtoStoryDistributionListRecord: Codable, CustomDeb
public init(serializedData: Data) throws {
let proto = try StorageServiceProtos_StoryDistributionListRecord(serializedData: serializedData)
try self.init(proto)
self.init(proto)
}
fileprivate init(_ proto: StorageServiceProtos_StoryDistributionListRecord) throws {
// MARK: - Begin Validation Logic for StorageServiceProtoStoryDistributionListRecord -
// MARK: - End Validation Logic for StorageServiceProtoStoryDistributionListRecord -
fileprivate init(_ proto: StorageServiceProtos_StoryDistributionListRecord) {
self.init(proto: proto)
}
@@ -3536,7 +3532,11 @@ public struct StorageServiceProtoStoryDistributionListRecordBuilder {
}
public func build() throws -> StorageServiceProtoStoryDistributionListRecord {
return try StorageServiceProtoStoryDistributionListRecord(proto)
return StorageServiceProtoStoryDistributionListRecord(proto)
}
public func buildInfallibly() -> StorageServiceProtoStoryDistributionListRecord {
return StorageServiceProtoStoryDistributionListRecord(proto)
}
public func buildSerializedData() throws -> Data {
@@ -3554,7 +3554,7 @@ extension StorageServiceProtoStoryDistributionListRecord {
extension StorageServiceProtoStoryDistributionListRecordBuilder {
public func buildIgnoringErrors() -> StorageServiceProtoStoryDistributionListRecord? {
return try! self.build()
return self.buildInfallibly()
}
}

View File

@@ -91,10 +91,6 @@ public class WebSocketProtoWebSocketRequestMessage: NSObject, Codable, NSSecureC
}
let requestID = proto.requestID
// MARK: - Begin Validation Logic for WebSocketProtoWebSocketRequestMessage -
// MARK: - End Validation Logic for WebSocketProtoWebSocketRequestMessage -
self.init(proto: proto,
verb: verb,
path: path,
@@ -336,10 +332,6 @@ public class WebSocketProtoWebSocketResponseMessage: NSObject, Codable, NSSecure
}
let status = proto.status
// MARK: - Begin Validation Logic for WebSocketProtoWebSocketResponseMessage -
// MARK: - End Validation Logic for WebSocketProtoWebSocketResponseMessage -
self.init(proto: proto,
requestID: requestID,
status: status)
@@ -592,10 +584,6 @@ public class WebSocketProtoWebSocketMessage: NSObject, Codable, NSSecureCoding {
response = try WebSocketProtoWebSocketResponseMessage(proto.response)
}
// MARK: - Begin Validation Logic for WebSocketProtoWebSocketMessage -
// MARK: - End Validation Logic for WebSocketProtoWebSocketMessage -
self.init(proto: proto,
request: request,
response: response)