protocol DeviceType : CustomDebugStringConvertible, Hashable, Sendable
extension DeviceType : Equatable
Protocol implemented by all the generated DeviceType
structs.
A device type represents a collection of traits with connected functionality.
-
The device type’s identifier.
Declaration
Swift
static var identifier: String { get }
-
Additional information about this device type.
Declaration
Swift
var metadata: DeviceTypeMetadata { get }
-
The traits that make up this device type.
Use this to access traits that are not directly exposed as properties on the
DeviceType
, like custom traits and traits belonging to utility types.Declaration
Swift
var traits: TraitCollection { get }
-
Entrypoint to subscribe to events on this DeviceType.
Declaration
Swift
var events: any EventController { get }
-
Creates a new
DeviceType
from the given trait collection.Throws
Throws aHomeError
if the given collection is missing one or more required traits for the given device type.Declaration
Swift
init(traits: TraitCollection, eventController: any EventController, metadataBuilder: ([any Trait]?) -> DeviceTypeMetadata) throws
-
identifier
The device type’s identifier.
Declaration
Swift
var identifier: String { get }
-
==(_:_:)
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Swift
static func == (lhs: Self, rhs: Self) -> Bool
Parameters
lhs
A value to compare.
rhs
Another value to compare.
-
hash(into:)
Hashes the essential components of this value by feeding them into the given hasher.
Implement this method to conform to the
Hashable
protocol. The components used for hashing must be the same as the components compared in your type’s==
operator implementation. Callhasher.combine(_:)
with each of these components.Important
In your implementation of
hash(into:)
, don’t callfinalize()
on thehasher
instance provided, or replace it with a different instance. Doing so may become a compile-time error in the future.Declaration
Swift
func hash(into hasher: inout Hasher)