ExplainOptions.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2025 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. public struct ExplainOptions: OptionProtocol, Sendable, Equatable, Hashable {
  15. public struct Mode: Sendable, Equatable, Hashable {
  16. let rawValue: String
  17. public static let execute = Mode(rawValue: "execute")
  18. public static let explain = Mode(rawValue: "explain")
  19. public static let analyze = Mode(rawValue: "analyze")
  20. init(rawValue: String) {
  21. self.rawValue = rawValue
  22. }
  23. }
  24. public struct OutputFormat: Sendable, Equatable, Hashable {
  25. let rawValue: String
  26. public static let text = OutputFormat(rawValue: "text")
  27. public static let json = OutputFormat(rawValue: "json")
  28. public static let `struct` = OutputFormat(rawValue: "struct")
  29. init(rawValue: String) {
  30. self.rawValue = rawValue
  31. }
  32. }
  33. public struct Verbosity: Sendable, Equatable, Hashable {
  34. let rawValue: String
  35. public static let summaryOnly = Verbosity(rawValue: "summary_only")
  36. public static let executionTree = Verbosity(rawValue: "execution_tree")
  37. init(rawValue: String) {
  38. self.rawValue = rawValue
  39. }
  40. }
  41. public struct Profiles: Sendable, Equatable, Hashable {
  42. let rawValue: String
  43. public static let latency = Profiles(rawValue: "latency")
  44. public static let recordsCount = Profiles(rawValue: "records_count")
  45. public static let bytesThroughput = Profiles(rawValue: "bytes_throughput")
  46. init(rawValue: String) {
  47. self.rawValue = rawValue
  48. }
  49. }
  50. public let mode: Mode?
  51. public let outputFormat: OutputFormat?
  52. public let verbosity: Verbosity?
  53. public let indexRecommendation: Bool?
  54. public let profiles: Profiles?
  55. public let redact: Bool?
  56. public init(mode: Mode? = nil,
  57. outputFormat: OutputFormat? = nil,
  58. verbosity: Verbosity? = nil,
  59. indexRecommendation: Bool? = nil,
  60. profiles: Profiles? = nil,
  61. redact: Bool? = nil) {
  62. self.mode = mode
  63. self.outputFormat = outputFormat
  64. self.verbosity = verbosity
  65. self.indexRecommendation = indexRecommendation
  66. self.profiles = profiles
  67. self.redact = redact
  68. }
  69. }