OrefFunction.swift 864 B

1234567891011121314151617181920212223242526272829
  1. /// After the port from Javascript to Swift is complete, we should remove the logging module:
  2. /// https://github.com/nightscout/Trio-dev/issues/293
  3. enum OrefFunctionResult {
  4. case success(RawJSON)
  5. case failure(Error)
  6. func returnOrThrow() throws -> RawJSON {
  7. switch self {
  8. case let .success(json): return json
  9. case let .failure(error): throw error
  10. }
  11. }
  12. }
  13. enum OrefFunction: String, Codable {
  14. case makeProfile
  15. // since we're removing some keys from our Profile that exist in Javascript
  16. // we need to let the difference function know which keys to ignore when
  17. // calculating differences
  18. func keysToIgnore() -> Set<String> {
  19. switch self {
  20. case .makeProfile:
  21. return Set(["calc_glucose_noise", "enableEnliteBgproxy", "exercise_mode", "offline_hotspot"])
  22. }
  23. }
  24. }