diff --git a/Sources/Bluetooth/Address.swift b/Sources/Bluetooth/Address.swift index eb549d7ac..24a1ce67e 100644 --- a/Sources/Bluetooth/Address.swift +++ b/Sources/Bluetooth/Address.swift @@ -10,7 +10,7 @@ import Foundation /// Bluetooth address. @frozen -public struct BluetoothAddress: ByteValue { +public struct BluetoothAddress: ByteValue, Sendable { // MARK: - ByteValueType diff --git a/Sources/Bluetooth/BitMaskOption.swift b/Sources/Bluetooth/BitMaskOption.swift index 13c4272f0..e60f136b9 100644 --- a/Sources/Bluetooth/BitMaskOption.swift +++ b/Sources/Bluetooth/BitMaskOption.swift @@ -105,6 +105,10 @@ public struct BitMaskOptionSet : RawRepresentable { } } +// MARK: - Sendable + +extension BitMaskOptionSet: Sendable where RawValue: Sendable { } + // MARK: - Sequence Conversion public extension BitMaskOptionSet { diff --git a/Sources/Bluetooth/BluetoothUUID.swift b/Sources/Bluetooth/BluetoothUUID.swift index b08a6ec7d..810d1b7fa 100644 --- a/Sources/Bluetooth/BluetoothUUID.swift +++ b/Sources/Bluetooth/BluetoothUUID.swift @@ -10,7 +10,7 @@ import Foundation /// Bluetooth UUID @frozen -public enum BluetoothUUID: Equatable { +public enum BluetoothUUID: Equatable, Hashable, Sendable { case bit16(UInt16) case bit32(UInt32) @@ -39,23 +39,6 @@ extension BluetoothUUID: CustomStringConvertible { } } -// MARK: - Hashable - -extension BluetoothUUID: Hashable { - - public func hash(into hasher: inout Hasher) { - - switch self { - case let .bit16(value): - return value.hash(into: &hasher) - case let .bit32(value): - return value.hash(into: &hasher) - case let .bit128(value): - return value.hash(into: &hasher) - } - } -} - // MARK: - RawRepresentable extension BluetoothUUID: RawRepresentable { diff --git a/Sources/Bluetooth/ClassOfDevice.swift b/Sources/Bluetooth/ClassOfDevice.swift index e8f71cfeb..be532c115 100644 --- a/Sources/Bluetooth/ClassOfDevice.swift +++ b/Sources/Bluetooth/ClassOfDevice.swift @@ -8,7 +8,7 @@ import Foundation -public struct ClassOfDevice: Equatable { +public struct ClassOfDevice: Equatable, Sendable { internal static let length = 3 @@ -100,7 +100,7 @@ public struct ClassOfDevice: Equatable { extension ClassOfDevice { - public struct FormatType: RawRepresentable, Equatable, Hashable { + public struct FormatType: RawRepresentable, Equatable, Hashable, Sendable { public static let min = FormatType(0b00) @@ -109,15 +109,12 @@ extension ClassOfDevice { public let rawValue: UInt8 public init?(rawValue: UInt8) { - guard rawValue <= type(of: self).max.rawValue, rawValue >= type(of: self).min.rawValue else { return nil } - self.rawValue = rawValue } private init(_ unsafe: UInt8) { - self.rawValue = unsafe } } @@ -125,7 +122,7 @@ extension ClassOfDevice { public extension ClassOfDevice { - enum MajorServiceClass: UInt16, BitMaskOption { + enum MajorServiceClass: UInt16, BitMaskOption, Sendable { /// Limited Discoverable Mode [Ref #1] case limitedDiscoverable = 0b01 @@ -170,7 +167,7 @@ public extension ClassOfDevice { public extension ClassOfDevice { - enum MajorDeviceClass: Equatable { + enum MajorDeviceClass: Equatable, Sendable { /// Miscellaneous case miscellaneous @@ -273,7 +270,7 @@ public extension ClassOfDevice { } } - enum MajorDeviceClassType: UInt8 { + enum MajorDeviceClassType: UInt8, Sendable { /// Miscellaneous case miscellaneous = 0b00 @@ -328,7 +325,7 @@ public extension ClassOfDevice { public extension ClassOfDevice.MinorDeviceClass { - enum Computer: UInt8 { + enum Computer: UInt8, Sendable { /// Uncategorized case uncategorized = 0b00 @@ -358,7 +355,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum Phone: UInt8 { + enum Phone: UInt8, Sendable { /// Uncategorized, code for device not assigned case uncategorized = 0b00 @@ -382,7 +379,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum NetworkAccessPoint: UInt8 { + enum NetworkAccessPoint: UInt8, Sendable { /// Fully available case fullyAvailable = 0b00 @@ -412,7 +409,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum AudioVideo: UInt8 { + enum AudioVideo: UInt8, Sendable { /// Uncategorized, code not assigned case uncategorized = 0b00 @@ -469,7 +466,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum PeripheralKeyboardPointing: UInt8 { + enum PeripheralKeyboardPointing: UInt8, Sendable { /// Not Keyboard / Not Pointing Device case notKeyboard = 0b00 @@ -484,7 +481,7 @@ public extension ClassOfDevice.MinorDeviceClass { case comboKeyboardPointingDevice = 0b11 } - enum PeripheralDevice: UInt8 { + enum PeripheralDevice: UInt8, Sendable { /// Uncategorized device case uncategorized = 0b00 @@ -520,7 +517,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum Imaging: UInt8, BitMaskOption { + enum Imaging: UInt8, BitMaskOption, Sendable, CaseIterable { /// Uncategorized case uncategorized = 0b00 @@ -536,20 +533,12 @@ public extension ClassOfDevice.MinorDeviceClass { /// Printer case printer = 0b1000 - - public static let allCases: [ClassOfDevice.MinorDeviceClass.Imaging] = [ - .uncategorized, - .display, - .camera, - .scanner, - .printer - ] } } public extension ClassOfDevice.MinorDeviceClass { - enum Wearable: UInt8 { + enum Wearable: UInt8, Sendable { /// Uncategorized case uncategorized = 0b00 @@ -573,7 +562,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum Toy: UInt8 { + enum Toy: UInt8, Sendable { /// Uncategorized case uncategorized = 0b00 @@ -597,7 +586,7 @@ public extension ClassOfDevice.MinorDeviceClass { public extension ClassOfDevice.MinorDeviceClass { - enum Health: UInt8 { + enum Health: UInt8, Sendable { /// Uncategorized case uncategorized = 0b00 diff --git a/Sources/Bluetooth/CompanyIdentifier.swift b/Sources/Bluetooth/CompanyIdentifier.swift index 93f55d066..e7dff969a 100644 --- a/Sources/Bluetooth/CompanyIdentifier.swift +++ b/Sources/Bluetooth/CompanyIdentifier.swift @@ -23,7 +23,7 @@ /// /// - SeeAlso: [Company Identifiers](https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers) @frozen -public struct CompanyIdentifier: RawRepresentable, Equatable, Hashable { +public struct CompanyIdentifier: RawRepresentable, Equatable, Hashable, Sendable { public var rawValue: UInt16 diff --git a/Sources/Bluetooth/LowEnergyAdvertisingData.swift b/Sources/Bluetooth/LowEnergyAdvertisingData.swift index eca2ed757..b5c8e31cb 100644 --- a/Sources/Bluetooth/LowEnergyAdvertisingData.swift +++ b/Sources/Bluetooth/LowEnergyAdvertisingData.swift @@ -12,7 +12,7 @@ import Foundation /// /// ![Image](https://github.com/PureSwift/Bluetooth/raw/master/Assets/LowEnergyAdvertisingDataExample1.png) @frozen -public struct LowEnergyAdvertisingData { +public struct LowEnergyAdvertisingData: Sendable { // MARK: - ByteValue diff --git a/Sources/Bluetooth/LowEnergyScanTimeInterval.swift b/Sources/Bluetooth/LowEnergyScanTimeInterval.swift index 70ebf7ce5..78d37a110 100644 --- a/Sources/Bluetooth/LowEnergyScanTimeInterval.swift +++ b/Sources/Bluetooth/LowEnergyScanTimeInterval.swift @@ -12,7 +12,7 @@ /// Time = N * 0.625 msec /// Time Range: 2.5 msec to 10240 msec @frozen -public struct LowEnergyScanTimeInterval: RawRepresentable, Equatable, Comparable, Hashable { +public struct LowEnergyScanTimeInterval: RawRepresentable, Equatable, Comparable, Hashable, Sendable { /// 2.5 msec public static let min = LowEnergyScanTimeInterval(0x0004) diff --git a/Sources/Bluetooth/RSSI.swift b/Sources/Bluetooth/RSSI.swift index 671c2b6b7..4e4575e01 100644 --- a/Sources/Bluetooth/RSSI.swift +++ b/Sources/Bluetooth/RSSI.swift @@ -12,7 +12,7 @@ /// Range: -127 ≤ N ≤ +20 /// Units: dBm @frozen -public struct RSSI: RawRepresentable, Equatable, Hashable { +public struct RSSI: RawRepresentable, Equatable, Hashable, Sendable { /// Units: dBm public let rawValue: Int8 diff --git a/Sources/Bluetooth/SFloat.swift b/Sources/Bluetooth/SFloat.swift index 83948a684..e4f8ec45e 100644 --- a/Sources/Bluetooth/SFloat.swift +++ b/Sources/Bluetooth/SFloat.swift @@ -30,7 +30,7 @@ public extension Float16 { /// IEEE-11073 16-bit SFLOAT @frozen -public struct SFloat: Equatable, Hashable, Codable { +public struct SFloat: Equatable, Hashable, Codable, Sendable { /// The bit pattern of the value’s encoding. public private(set) var bitPattern: UInt16 diff --git a/Sources/Bluetooth/SecurityLevel.swift b/Sources/Bluetooth/SecurityLevel.swift index b50518cef..1905b3d7f 100644 --- a/Sources/Bluetooth/SecurityLevel.swift +++ b/Sources/Bluetooth/SecurityLevel.swift @@ -7,7 +7,7 @@ // /// Bluetooth security level. -public enum SecurityLevel: UInt8 { +public enum SecurityLevel: UInt8, Sendable { case sdp = 0 case low = 1 diff --git a/Sources/Bluetooth/UInt128.swift b/Sources/Bluetooth/UInt128.swift index 364ac8667..8729cad3b 100644 --- a/Sources/Bluetooth/UInt128.swift +++ b/Sources/Bluetooth/UInt128.swift @@ -11,7 +11,7 @@ import Foundation /// /// Unlike `NSUUID` which is always stored in big endian. @frozen -public struct UInt128: ByteValue { +public struct UInt128: ByteValue, Sendable { public typealias ByteValue = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) diff --git a/Sources/Bluetooth/UInt24.swift b/Sources/Bluetooth/UInt24.swift index 778909dd1..445a8f24f 100644 --- a/Sources/Bluetooth/UInt24.swift +++ b/Sources/Bluetooth/UInt24.swift @@ -10,7 +10,7 @@ import Foundation /// A 24 bit number stored according to host endianness. @frozen -public struct UInt24: ByteValue { +public struct UInt24: ByteValue, Sendable { public typealias ByteValue = (UInt8, UInt8, UInt8) diff --git a/Sources/Bluetooth/UInt256.swift b/Sources/Bluetooth/UInt256.swift index 4d6f11c25..9dd0ff0a1 100644 --- a/Sources/Bluetooth/UInt256.swift +++ b/Sources/Bluetooth/UInt256.swift @@ -10,7 +10,7 @@ import Foundation /// A 256 bit number stored according to host endianness. @frozen -public struct UInt256: ByteValue { +public struct UInt256: ByteValue, Sendable { public typealias ByteValue = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) diff --git a/Sources/Bluetooth/UInt40.swift b/Sources/Bluetooth/UInt40.swift index b8012030d..d5fc3045c 100644 --- a/Sources/Bluetooth/UInt40.swift +++ b/Sources/Bluetooth/UInt40.swift @@ -10,7 +10,7 @@ import Foundation /// A 40 bit number stored according to host endianness. @frozen -public struct UInt40: ByteValue { +public struct UInt40: ByteValue, Sendable { public typealias ByteValue = (UInt8, UInt8, UInt8, UInt8, UInt8) diff --git a/Sources/Bluetooth/UInt48.swift b/Sources/Bluetooth/UInt48.swift index e1178685b..b698c0f41 100644 --- a/Sources/Bluetooth/UInt48.swift +++ b/Sources/Bluetooth/UInt48.swift @@ -9,7 +9,7 @@ import Foundation @frozen -public struct UInt48: ByteValue { +public struct UInt48: ByteValue, Sendable { public typealias ByteValue = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) diff --git a/Sources/Bluetooth/UInt512.swift b/Sources/Bluetooth/UInt512.swift index dba37d9f3..e1d960286 100644 --- a/Sources/Bluetooth/UInt512.swift +++ b/Sources/Bluetooth/UInt512.swift @@ -10,7 +10,7 @@ import Foundation /// A 512 bit number stored according to host endianness. @frozen -public struct UInt512: ByteValue { +public struct UInt512: ByteValue, Sendable { public typealias ByteValue = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) diff --git a/Sources/Bluetooth/UnitIdentifier.swift b/Sources/Bluetooth/UnitIdentifier.swift index 738a1b0b6..b2f4c7af9 100644 --- a/Sources/Bluetooth/UnitIdentifier.swift +++ b/Sources/Bluetooth/UnitIdentifier.swift @@ -9,12 +9,11 @@ import Foundation @frozen -public struct UnitIdentifier: RawRepresentable, Equatable, Hashable { +public struct UnitIdentifier: RawRepresentable, Equatable, Hashable, Sendable { public var rawValue: UInt16 public init(rawValue: UInt16) { - self.rawValue = rawValue } } @@ -24,7 +23,6 @@ public struct UnitIdentifier: RawRepresentable, Equatable, Hashable { extension UnitIdentifier: ExpressibleByIntegerLiteral { public init(integerLiteral value: UInt16) { - self.init(rawValue: value) } } diff --git a/Sources/Bluetooth/iBeacon.swift b/Sources/Bluetooth/iBeacon.swift index fe1613905..8b9b67386 100644 --- a/Sources/Bluetooth/iBeacon.swift +++ b/Sources/Bluetooth/iBeacon.swift @@ -18,7 +18,7 @@ import Foundation - SeeAlso: [Getting Started with iBeacon](https://developer.apple.com/ibeacon/Getting-Started-with-iBeacon.pdf). */ @frozen -public struct AppleBeacon: Equatable, Hashable { +public struct AppleBeacon: Equatable, Hashable, Sendable { #if !os(WASI) /// The company that created this specification.