DeviceType

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 a HomeError 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

    Extension method

    The device type’s identifier.

    Declaration

    Swift

    var identifier: String { get }
  • ==(_:_:)

    Extension method

    Returns a Boolean value indicating whether two values are equal.

    Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

    Declaration

    Swift

    static func == (lhs: Self, rhs: Self) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

  • hash(into:)

    Extension method

    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. Call hasher.combine(_:) with each of these components.

    Important

    In your implementation of hash(into:), don’t call finalize() on the hasher 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)