HealthKitRawDataApi.swift 17 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
// // Copyright 2013 The Flutter Authors. All rights reserved.
// Autogenerated from Pigeon (v25.5.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

import Foundation

#if os(iOS)
  import Flutter
#elseif os(macOS)
  import FlutterMacOS
#else
  #error("Unsupported platform.")
#endif


private func wrapResult(_ result: Any?) -> [Any?] {
  return [result]
}

private func wrapError(_ error: Any) -> [Any?] {
  if let pigeonError = error as? PigeonError {
    return [
      pigeonError.code,
      pigeonError.message,
      pigeonError.details,
    ]
  }
  if let flutterError = error as? FlutterError {
    return [
      flutterError.code,
      flutterError.message,
      flutterError.details,
    ]
  }
  return [
    "\(error)",
    "\(type(of: error))",
    "Stacktrace: \(Thread.callStackSymbols)",
  ]
}

private func isNullish(_ value: Any?) -> Bool {
  return value is NSNull || value == nil
}

private func nilOrValue<T>(_ value: Any?) -> T? {
  if value is NSNull { return nil }
  return value as! T?
}

func deepEqualsHealthKitRawDataApi(_ lhs: Any?, _ rhs: Any?) -> Bool {
  let cleanLhs = nilOrValue(lhs) as Any?
  let cleanRhs = nilOrValue(rhs) as Any?
  switch (cleanLhs, cleanRhs) {
  case (nil, nil):
    return true

  case (nil, _), (_, nil):
    return false

  case is (Void, Void):
    return true

  case let (cleanLhsHashable, cleanRhsHashable) as (AnyHashable, AnyHashable):
    return cleanLhsHashable == cleanRhsHashable

  case let (cleanLhsArray, cleanRhsArray) as ([Any?], [Any?]):
    guard cleanLhsArray.count == cleanRhsArray.count else { return false }
    for (index, element) in cleanLhsArray.enumerated() {
      if !deepEqualsHealthKitRawDataApi(element, cleanRhsArray[index]) {
        return false
      }
    }
    return true

  case let (cleanLhsDictionary, cleanRhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]):
    guard cleanLhsDictionary.count == cleanRhsDictionary.count else { return false }
    for (key, cleanLhsValue) in cleanLhsDictionary {
      guard cleanRhsDictionary.index(forKey: key) != nil else { return false }
      if !deepEqualsHealthKitRawDataApi(cleanLhsValue, cleanRhsDictionary[key]!) {
        return false
      }
    }
    return true

  default:
    // Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue.
    return false
  }
}

func deepHashHealthKitRawDataApi(value: Any?, hasher: inout Hasher) {
  if let valueList = value as? [AnyHashable] {
     for item in valueList { deepHashHealthKitRawDataApi(value: item, hasher: &hasher) }
     return
  }

  if let valueDict = value as? [AnyHashable: AnyHashable] {
    for key in valueDict.keys { 
      hasher.combine(key)
      deepHashHealthKitRawDataApi(value: valueDict[key]!, hasher: &hasher)
    }
    return
  }

  if let hashableValue = value as? AnyHashable {
    hasher.combine(hashableValue.hashValue)
  }

  return hasher.combine(String(describing: value))
}

    

/// Generated class from Pigeon that represents data sent in messages.
struct HealthKitRawDataPoint: Hashable {
  var dataType: Int64
  var startTime: Int64
  var endTime: Int64
  var value: Double? = nil
  var isMotionLike: Bool? = nil


  // swift-format-ignore: AlwaysUseLowerCamelCase
  static func fromList(_ pigeonVar_list: [Any?]) -> HealthKitRawDataPoint? {
    let dataType = pigeonVar_list[0] as! Int64
    let startTime = pigeonVar_list[1] as! Int64
    let endTime = pigeonVar_list[2] as! Int64
    let value: Double? = nilOrValue(pigeonVar_list[3])
    let isMotionLike: Bool? = nilOrValue(pigeonVar_list[4])

    return HealthKitRawDataPoint(
      dataType: dataType,
      startTime: startTime,
      endTime: endTime,
      value: value,
      isMotionLike: isMotionLike
    )
  }
  func toList() -> [Any?] {
    return [
      dataType,
      startTime,
      endTime,
      value,
      isMotionLike,
    ]
  }
  static func == (lhs: HealthKitRawDataPoint, rhs: HealthKitRawDataPoint) -> Bool {
    return deepEqualsHealthKitRawDataApi(lhs.toList(), rhs.toList())  }
  func hash(into hasher: inout Hasher) {
    deepHashHealthKitRawDataApi(value: toList(), hasher: &hasher)
  }
}

/// Generated class from Pigeon that represents data sent in messages.
struct HealthKitRawSleepDataPoint: Hashable {
  var dataType: Int64
  var sleepDataPoints: [HealthKitRawDataPoint]


  // swift-format-ignore: AlwaysUseLowerCamelCase
  static func fromList(_ pigeonVar_list: [Any?]) -> HealthKitRawSleepDataPoint? {
    let dataType = pigeonVar_list[0] as! Int64
    let sleepDataPoints = pigeonVar_list[1] as! [HealthKitRawDataPoint]

    return HealthKitRawSleepDataPoint(
      dataType: dataType,
      sleepDataPoints: sleepDataPoints
    )
  }
  func toList() -> [Any?] {
    return [
      dataType,
      sleepDataPoints,
    ]
  }
  static func == (lhs: HealthKitRawSleepDataPoint, rhs: HealthKitRawSleepDataPoint) -> Bool {
    return deepEqualsHealthKitRawDataApi(lhs.toList(), rhs.toList())  }
  func hash(into hasher: inout Hasher) {
    deepHashHealthKitRawDataApi(value: toList(), hasher: &hasher)
  }
}

/// Generated class from Pigeon that represents data sent in messages.
struct HealthKitRawWorkoutDataPoint: Hashable {
  var workoutType: Int64
  var startTime: Int64
  var endTime: Int64


  // swift-format-ignore: AlwaysUseLowerCamelCase
  static func fromList(_ pigeonVar_list: [Any?]) -> HealthKitRawWorkoutDataPoint? {
    let workoutType = pigeonVar_list[0] as! Int64
    let startTime = pigeonVar_list[1] as! Int64
    let endTime = pigeonVar_list[2] as! Int64

    return HealthKitRawWorkoutDataPoint(
      workoutType: workoutType,
      startTime: startTime,
      endTime: endTime
    )
  }
  func toList() -> [Any?] {
    return [
      workoutType,
      startTime,
      endTime,
    ]
  }
  static func == (lhs: HealthKitRawWorkoutDataPoint, rhs: HealthKitRawWorkoutDataPoint) -> Bool {
    return deepEqualsHealthKitRawDataApi(lhs.toList(), rhs.toList())  }
  func hash(into hasher: inout Hasher) {
    deepHashHealthKitRawDataApi(value: toList(), hasher: &hasher)
  }
}

/// Generated class from Pigeon that represents data sent in messages.
struct HealthKitRawMotionDataPoint: Hashable {
  var motionType: Int64
  var startTime: Int64
  var endTime: Int64


  // swift-format-ignore: AlwaysUseLowerCamelCase
  static func fromList(_ pigeonVar_list: [Any?]) -> HealthKitRawMotionDataPoint? {
    let motionType = pigeonVar_list[0] as! Int64
    let startTime = pigeonVar_list[1] as! Int64
    let endTime = pigeonVar_list[2] as! Int64

    return HealthKitRawMotionDataPoint(
      motionType: motionType,
      startTime: startTime,
      endTime: endTime
    )
  }
  func toList() -> [Any?] {
    return [
      motionType,
      startTime,
      endTime,
    ]
  }
  static func == (lhs: HealthKitRawMotionDataPoint, rhs: HealthKitRawMotionDataPoint) -> Bool {
    return deepEqualsHealthKitRawDataApi(lhs.toList(), rhs.toList())  }
  func hash(into hasher: inout Hasher) {
    deepHashHealthKitRawDataApi(value: toList(), hasher: &hasher)
  }
}

/// Generated class from Pigeon that represents data sent in messages.
struct HealthKitRawActivityDataPoint: Hashable {
  var endTime: Int64
  var activeEnergyBurned: Double? = nil
  var activeEnergyBurnedGoal: Double? = nil
  var appleMoveTime: Double? = nil
  var appleMoveTimeGoal: Double? = nil
  var appleExerciseTime: Double? = nil
  var exerciseTimeGoal: Double? = nil
  var appleStandHours: Double? = nil
  var standHoursGoal: Double? = nil


  // swift-format-ignore: AlwaysUseLowerCamelCase
  static func fromList(_ pigeonVar_list: [Any?]) -> HealthKitRawActivityDataPoint? {
    let endTime = pigeonVar_list[0] as! Int64
    let activeEnergyBurned: Double? = nilOrValue(pigeonVar_list[1])
    let activeEnergyBurnedGoal: Double? = nilOrValue(pigeonVar_list[2])
    let appleMoveTime: Double? = nilOrValue(pigeonVar_list[3])
    let appleMoveTimeGoal: Double? = nilOrValue(pigeonVar_list[4])
    let appleExerciseTime: Double? = nilOrValue(pigeonVar_list[5])
    let exerciseTimeGoal: Double? = nilOrValue(pigeonVar_list[6])
    let appleStandHours: Double? = nilOrValue(pigeonVar_list[7])
    let standHoursGoal: Double? = nilOrValue(pigeonVar_list[8])

    return HealthKitRawActivityDataPoint(
      endTime: endTime,
      activeEnergyBurned: activeEnergyBurned,
      activeEnergyBurnedGoal: activeEnergyBurnedGoal,
      appleMoveTime: appleMoveTime,
      appleMoveTimeGoal: appleMoveTimeGoal,
      appleExerciseTime: appleExerciseTime,
      exerciseTimeGoal: exerciseTimeGoal,
      appleStandHours: appleStandHours,
      standHoursGoal: standHoursGoal
    )
  }
  func toList() -> [Any?] {
    return [
      endTime,
      activeEnergyBurned,
      activeEnergyBurnedGoal,
      appleMoveTime,
      appleMoveTimeGoal,
      appleExerciseTime,
      exerciseTimeGoal,
      appleStandHours,
      standHoursGoal,
    ]
  }
  static func == (lhs: HealthKitRawActivityDataPoint, rhs: HealthKitRawActivityDataPoint) -> Bool {
    return deepEqualsHealthKitRawDataApi(lhs.toList(), rhs.toList())  }
  func hash(into hasher: inout Hasher) {
    deepHashHealthKitRawDataApi(value: toList(), hasher: &hasher)
  }
}

private class HealthKitRawDataApiPigeonCodecReader: FlutterStandardReader {
  override func readValue(ofType type: UInt8) -> Any? {
    switch type {
    case 129:
      return HealthKitRawDataPoint.fromList(self.readValue() as! [Any?])
    case 130:
      return HealthKitRawSleepDataPoint.fromList(self.readValue() as! [Any?])
    case 131:
      return HealthKitRawWorkoutDataPoint.fromList(self.readValue() as! [Any?])
    case 132:
      return HealthKitRawMotionDataPoint.fromList(self.readValue() as! [Any?])
    case 133:
      return HealthKitRawActivityDataPoint.fromList(self.readValue() as! [Any?])
    default:
      return super.readValue(ofType: type)
    }
  }
}

private class HealthKitRawDataApiPigeonCodecWriter: FlutterStandardWriter {
  override func writeValue(_ value: Any) {
    if let value = value as? HealthKitRawDataPoint {
      super.writeByte(129)
      super.writeValue(value.toList())
    } else if let value = value as? HealthKitRawSleepDataPoint {
      super.writeByte(130)
      super.writeValue(value.toList())
    } else if let value = value as? HealthKitRawWorkoutDataPoint {
      super.writeByte(131)
      super.writeValue(value.toList())
    } else if let value = value as? HealthKitRawMotionDataPoint {
      super.writeByte(132)
      super.writeValue(value.toList())
    } else if let value = value as? HealthKitRawActivityDataPoint {
      super.writeByte(133)
      super.writeValue(value.toList())
    } else {
      super.writeValue(value)
    }
  }
}

private class HealthKitRawDataApiPigeonCodecReaderWriter: FlutterStandardReaderWriter {
  override func reader(with data: Data) -> FlutterStandardReader {
    return HealthKitRawDataApiPigeonCodecReader(data: data)
  }

  override func writer(with data: NSMutableData) -> FlutterStandardWriter {
    return HealthKitRawDataApiPigeonCodecWriter(data: data)
  }
}

class HealthKitRawDataApiPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
  static let shared = HealthKitRawDataApiPigeonCodec(readerWriter: HealthKitRawDataApiPigeonCodecReaderWriter())
}


/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
protocol HealthKitRawDataHostApi {
  /// 从AppleHealth 中读取原始数据
  func getHealthKitRawData(dataType: Int64, startTime: Int64, endTime: Int64, completion: @escaping (Result<[HealthKitRawDataPoint], Error>) -> Void)
  /// 从从AppleHealth中读取睡眠数据
  func getHealthKitRawSleepData(startTime: Int64, endTime: Int64, completion: @escaping (Result<[HealthKitRawSleepDataPoint], Error>) -> Void)
  /// 从从AppleHealth中读取活动统计数据
  func getHealthKitRawActivityData(startTime: Int64, endTime: Int64, completion: @escaping (Result<[HealthKitRawActivityDataPoint], Error>) -> Void)
  /// 从从AppleHealth中读取锻炼数据
  func getHealthKitRawWorkoutData(startTime: Int64, endTime: Int64, completion: @escaping (Result<[HealthKitRawWorkoutDataPoint], Error>) -> Void)
  /// 从从AppleHealth中读取锻炼数据
  func getHealthKitRawMotionData(startTime: Int64, endTime: Int64, completion: @escaping (Result<[HealthKitRawMotionDataPoint], Error>) -> Void)
}

/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
class HealthKitRawDataHostApiSetup {
  static var codec: FlutterStandardMessageCodec { HealthKitRawDataApiPigeonCodec.shared }
  /// Sets up an instance of `HealthKitRawDataHostApi` to handle messages through the `binaryMessenger`.
  static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HealthKitRawDataHostApi?, messageChannelSuffix: String = "") {
    let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
    /// 从AppleHealth 中读取原始数据
    let getHealthKitRawDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.doublefeel_flutter.HealthKitRawDataHostApi.getHealthKitRawData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
    if let api = api {
      getHealthKitRawDataChannel.setMessageHandler { message, reply in
        let args = message as! [Any?]
        let dataTypeArg = args[0] as! Int64
        let startTimeArg = args[1] as! Int64
        let endTimeArg = args[2] as! Int64
        api.getHealthKitRawData(dataType: dataTypeArg, startTime: startTimeArg, endTime: endTimeArg) { result in
          switch result {
          case .success(let res):
            reply(wrapResult(res))
          case .failure(let error):
            reply(wrapError(error))
          }
        }
      }
    } else {
      getHealthKitRawDataChannel.setMessageHandler(nil)
    }
    /// 从从AppleHealth中读取睡眠数据
    let getHealthKitRawSleepDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.doublefeel_flutter.HealthKitRawDataHostApi.getHealthKitRawSleepData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
    if let api = api {
      getHealthKitRawSleepDataChannel.setMessageHandler { message, reply in
        let args = message as! [Any?]
        let startTimeArg = args[0] as! Int64
        let endTimeArg = args[1] as! Int64
        api.getHealthKitRawSleepData(startTime: startTimeArg, endTime: endTimeArg) { result in
          switch result {
          case .success(let res):
            reply(wrapResult(res))
          case .failure(let error):
            reply(wrapError(error))
          }
        }
      }
    } else {
      getHealthKitRawSleepDataChannel.setMessageHandler(nil)
    }
    /// 从从AppleHealth中读取活动统计数据
    let getHealthKitRawActivityDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.doublefeel_flutter.HealthKitRawDataHostApi.getHealthKitRawActivityData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
    if let api = api {
      getHealthKitRawActivityDataChannel.setMessageHandler { message, reply in
        let args = message as! [Any?]
        let startTimeArg = args[0] as! Int64
        let endTimeArg = args[1] as! Int64
        api.getHealthKitRawActivityData(startTime: startTimeArg, endTime: endTimeArg) { result in
          switch result {
          case .success(let res):
            reply(wrapResult(res))
          case .failure(let error):
            reply(wrapError(error))
          }
        }
      }
    } else {
      getHealthKitRawActivityDataChannel.setMessageHandler(nil)
    }
    /// 从从AppleHealth中读取锻炼数据
    let getHealthKitRawWorkoutDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.doublefeel_flutter.HealthKitRawDataHostApi.getHealthKitRawWorkoutData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
    if let api = api {
      getHealthKitRawWorkoutDataChannel.setMessageHandler { message, reply in
        let args = message as! [Any?]
        let startTimeArg = args[0] as! Int64
        let endTimeArg = args[1] as! Int64
        api.getHealthKitRawWorkoutData(startTime: startTimeArg, endTime: endTimeArg) { result in
          switch result {
          case .success(let res):
            reply(wrapResult(res))
          case .failure(let error):
            reply(wrapError(error))
          }
        }
      }
    } else {
      getHealthKitRawWorkoutDataChannel.setMessageHandler(nil)
    }
    /// 从从AppleHealth中读取锻炼数据
    let getHealthKitRawMotionDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.doublefeel_flutter.HealthKitRawDataHostApi.getHealthKitRawMotionData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
    if let api = api {
      getHealthKitRawMotionDataChannel.setMessageHandler { message, reply in
        let args = message as! [Any?]
        let startTimeArg = args[0] as! Int64
        let endTimeArg = args[1] as! Int64
        api.getHealthKitRawMotionData(startTime: startTimeArg, endTime: endTimeArg) { result in
          switch result {
          case .success(let res):
            reply(wrapResult(res))
          case .failure(let error):
            reply(wrapError(error))
          }
        }
      }
    } else {
      getHealthKitRawMotionDataChannel.setMessageHandler(nil)
    }
  }
}