Skip to content

Commit

Permalink
#177 Rename BluetoothMetadata.BluetoothUUID.File.init()
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Jan 12, 2025
1 parent c3d8868 commit 20f0bab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Sources/BluetoothMetadata/BluetoothUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,25 @@ public extension BluetoothUUID.File {
.init()
}

static func load(_ name: BluetoothUUID.Category) throws -> Self {
guard let fileName = Self.fileNames[name] else {
init(_ type: BluetoothUUID.Category) throws {
guard let fileName = Self.fileNames[type] else {
throw CocoaError(.fileNoSuchFile)
}
guard let fileURL = Bundle.module.url(
forResource: fileName,
withExtension: fileExtension
withExtension: Self.fileExtension
) else {
throw CocoaError(.fileNoSuchFile)
}
return try self.init(url: fileURL)
try self.init(url: fileURL)
}

static func load() throws -> [BluetoothUUID.Category: Self] {
let types = Self.fileNames.keys
var files = [BluetoothUUID.Category: Self]()
files.reserveCapacity(types.count)
for type in types {
let file = try load(type)
let file = try self.init(type)
files[type] = file
}
assert(files.count == types.count)
Expand Down
2 changes: 1 addition & 1 deletion Sources/GenerateBluetooth/BluetoothUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension GenerateTool {
static func parseUUIDFile(
type: BluetoothMetadata.BluetoothUUID.Category
) throws -> [UInt16: BluetoothMetadata.BluetoothUUID] {
let file = try BluetoothMetadata.BluetoothUUID.File.load(type)
let file = try BluetoothMetadata.BluetoothUUID.File(type)
var output = [UInt16: BluetoothMetadata.BluetoothUUID]()
output.reserveCapacity(file.uuids.count)
for element in file.uuids {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GenerateBluetooth/UnitIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension GenerateTool {

static func parseUnitIdentifiersFile(
) throws -> [UInt16: (id: String, name: String)] {
let file = try BluetoothMetadata.BluetoothUUID.File.load(.unit)
let file = try BluetoothMetadata.BluetoothUUID.File(.unit)
var output = [UInt16: (id: String, name: String)]()
output.reserveCapacity(file.uuids.count)
for element in file.uuids {
Expand Down

0 comments on commit 20f0bab

Please sign in to comment.