<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SensorKit",
  "identifier" : "/documentation/SensorKit/SRFetchResponse",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SensorKit"
    ],
    "preciseIdentifier" : "s:9SensorKit15SRFetchResponseV"
  },
  "title" : "SRFetchResponse"
}
-->

# SRFetchResponse

A generic container that holds sensor data samples retrieved from SensorKit data streams.

```
struct SRFetchResponse<Sample>
```

## Overview

`SRFetchResponse` is a type-safe container that wraps individual sensor data samples.
It serves as the primary data delivery mechanism
for sensor information retrieved through `SRReader.fetch(_:)` operations.

## Usage Example

```swift
let request = SRFetchRequest()
for try await response in reader.fetch(request) {
    // Extract the sensor sample
    switch response.sample {
    case .success(let sample):
        print("Sample data: \(sample)")
    case .failure(let error):
        print("Failed to decode sample: \(error)")
    }

    // Get the timestamp when data was recorded
    let timestamp = response.timestamp()
    print("Recorded at: \(Date(timeIntervalSinceReferenceDate: timestamp))")
}
```

## Topics

### Instance Properties

[`var sample: Result<Sample, any Error>`](/documentation/SensorKit/SRFetchResponse/sample)

Retrieves the sensor-specific data sample contained in this response.

[`var sourceDevice: SRSourceDevice?`](/documentation/SensorKit/SRFetchResponse/sourceDevice)

The source of the sample data.

[`var timestamp: SRAbsoluteTime`](/documentation/SensorKit/SRFetchResponse/timestamp)

Retrieves the timestamp when the sensor sample was written to the data store.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)