Image

public enum Image
extension Image: CustomStringConvertible
extension Image: RawRepresentable
extension Image: MediaSubtype
extension Image: Hashable

Represents the image media type. See the official documentation for details.

You typically use Image as a MediaType.

let image = Image.png()
let mediaType = MediaType.image(image) // Creates: image/png

You can use standard switch statement to access image values.

func isSupported(image: Image) -> Bool {
  switch image {
  case .png, .jpeg, .gif: return true
  default: return false
  }
}

isSupported(audio: .png()) // Returns: true
isSupported(audio: .jpeg()) // Returns: true
isSupported(audio: .gif()) // Returns: true
isSupported(audio: .bmp()) // Returns: false

See also

MediaType