Key

public struct Key : ExpressibleByStringLiteral, Equatable, Hashable, CustomStringConvertible

A RequestHeaders.Key is a value type used to describe keys in a header dictionary.

You can create headers in a few ways:

  • Using any type that conforms to RawRepresentable where RawValue is String
  • Using any type that conforms to CustomStringConvertible
  • Using strings or string literals

Commonly used values and additional factory methods are declared in an extension to reduce boilerplate and increase type safety.

Initializers

  • Create a Key from a CustomStringConvertible

    Declaration

    Swift

    public init<T>(_ value: T) where T : CustomStringConvertible

    Parameters

    value

    The string convertible value

  • Create a Key from a RawRepresentable

    Declaration

    Swift

    public init<T>(_ value: T) where T : RawRepresentable, T.RawValue == String

    Parameters

    value

    The raw representable value

  • Create a Key from a String

    Declaration

    Swift

    public init(_ value: String)

    Parameters

    value

    The string

ExpressibleByStringLiteral

Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)

Equatable

  • Declaration

    Swift

    public static func == (lhs: Key, rhs: Key) -> Bool

CustomStringConvertible

  • Declaration

    Swift

    public let description: String

Factory Methods