Contents

SRDataSensor

SRDataSensor serves as the foundational protocol for all sensor types, providing type safety and consistency across the SensorKit ecosystem. Each conforming sensor type specifies the kind of data it produces, enabling compile-time verification and type-safe data access patterns.

Declaration

protocol SRDataSensor : Hashable, Sendable

Protocol Requirements

Usage Example

// Using a specific sensor type
let temperatureSensor: SRWristTemperatureSensor = .wristTemperature

// Creating a reader with type safety
guard let reader = SRReader(sensor: temperatureSensor) else {
    print("Failed to create reader")
    return
}

// The reader automatically knows the sample type
for try await response in reader.fetch(request) {
    if let sample: SRWristTemperatureSession = response.sample() {
        // Type-safe access to temperature data
        print("Temperature: \(sample.temperature)")
    }
}

Topics

Associated Types

Type Properties