Suffix

public enum Suffix
extension Suffix: RawRepresentable
extension Suffix: CustomStringConvertible
extension Suffix: ExpressibleByStringLiteral
extension Suffix: Hashable

Represents the media type suffixes.

The library allows all MediaTypes to have a suffix. Keep in mind though, that not all such combinations are registered (see the official site for details).

It is also possible to create completely custom suffixes by using either the other(_:) case directly or a string literal.

MediaType.application(.jose(.json)) // Creates: application/jose+json
MediaType.application(.jose(.other("custom"))) // Creates: application/jose+custom
MediaType.image(.svg("zip")) // Creates: image/svg+zip

You can access a media type’s suffix by matching using a switch statement:

let mediaType = MediaType.application(.calendar(.xml))
switch mediaType {
case .application(.calendar(let suffix, _)):
  guard let suffix = suffix else { break }
  print("Suffix: \(suffix)", "Suffix: +xml")
default:
  print("Unsupported media type: \(mediaType)")
}
  • xml

    Represents the xml suffix.

    Declaration

    Swift

    case xml
  • Represents the json suffix.

    Declaration

    Swift

    case json
  • ber

    Represents the ber suffix.

    Declaration

    Swift

    case ber
  • Represents the cbor suffix.

    Declaration

    Swift

    case cbor
  • der

    Represents the der suffix.

    Declaration

    Swift

    case der
  • Represents the fastinfoset suffix.

    Declaration

    Swift

    case fastinfoset
  • Represents the wbxml suffix.

    Declaration

    Swift

    case wbxml
  • zip

    Represents the zip suffix.

    Declaration

    Swift

    case zip
  • tlv

    Represents the tlv suffix.

    Declaration

    Swift

    case tlv
  • Represents the json suffix.

    Declaration

    Swift

    case jsonSeq
  • Represents the sqlite3 suffix.

    Declaration

    Swift

    case sqlite3
  • jwt

    Represents the jwt suffix.

    Declaration

    Swift

    case jwt
  • Represents the gzip suffix.

    Declaration

    Swift

    case gzip
  • Represents the cbor suffix.

    Declaration

    Swift

    case cborSeq
  • Represents the zstd suffix.

    Declaration

    Swift

    case zstd
  • Represents a custom suffix.

    Declaration

    Swift

    case other(CustomStringConvertible)
  • Declaration

    Swift

    public init(rawValue: String)
  • Declaration

    Swift

    public var rawValue: String { get }
  • Declaration

    Swift

    public var description: String { get }
  • Declaration

    Swift

    public init(stringLiteral value: String)
  • Declaration

    Swift

    public static func == (lhs: `Self`, rhs: `Self`) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)