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)")
}
-
Represents the
xmlsuffix.Declaration
Swift
case xml -
Represents the
jsonsuffix.Declaration
Swift
case json -
Represents the
bersuffix.Declaration
Swift
case ber -
Represents the
cborsuffix.Declaration
Swift
case cbor -
Represents the
dersuffix.Declaration
Swift
case der -
Represents the
fastinfosetsuffix.Declaration
Swift
case fastinfoset -
Represents the
wbxmlsuffix.Declaration
Swift
case wbxml -
Represents the
zipsuffix.Declaration
Swift
case zip -
Represents the
tlvsuffix.Declaration
Swift
case tlv -
Represents the
jsonsuffix.Declaration
Swift
case jsonSeq -
Represents the
sqlite3suffix.Declaration
Swift
case sqlite3 -
Represents the
jwtsuffix.Declaration
Swift
case jwt -
Represents the
gzipsuffix.Declaration
Swift
case gzip -
Represents the
cborsuffix.Declaration
Swift
case cborSeq -
Represents the
zstdsuffix.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)