ContentModality.swift 793 B

12345678910111213141516171819202122232425
  1. import Foundation
  2. /// Represents the different content modalities that can be used in a response.
  3. @available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
  4. public struct ContentModality: Codable, Hashable {
  5. let rawValue: String
  6. public static let text = ContentModality(rawValue: "TEXT")
  7. public static let image = ContentModality(rawValue: "IMAGE")
  8. public static let audio = ContentModality(rawValue: "AUDIO")
  9. public func hash(into hasher: inout Hasher) -> Int {
  10. return rawValue.hashValue
  11. }
  12. init(rawValue: String) {
  13. self.rawValue = rawValue
  14. }
  15. }
  16. extension ContentModality: Equatable {
  17. public static func == (lhs: ContentModality, rhs: ContentModality) -> Bool {
  18. return lhs.rawValue == rhs.rawValue
  19. }
  20. }