Value

public struct Value : ExpressibleByStringLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, CustomStringConvertible, Equatable, Hashable

A RequestHeaders.Value is a value type used to describe values in a header dictionary.

You can create values 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
  • Using integer literals
  • Using floating point literals

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

Initializers

  • Create a Value from a CustomStringConvertible

    Declaration

    Swift

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

    Parameters

    value

    The string convertible value

  • Create a Value from a RawRepresentable

    Declaration

    Swift

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

    Parameters

    value

    The raw representable value

  • Create a Value from a String

    Declaration

    Swift

    public init(_ value: String)

    Parameters

    value

    The string

CustomStringConvertibble

  • Declaration

    Swift

    public let description: String

ExpressibleByStringLiteral

ExpressibleByIntegerLiteral

ExpressibleByFloatLiteral

Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)

Equatable

  • Declaration

    Swift

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

Factory Methods

  • Create a header value from a String

    Declaration

    Swift

    static func string(_ value: String) -> RequestHeaders.Value

    Parameters

    value

    The String value

    Return Value

    The header value

  • Create a header from an Int

    Declaration

    Swift

    static func int(_ value: Int) -> RequestHeaders.Value

    Parameters

    value

    The Int value

    Return Value

    The header value

  • Create a header from a Double

    Declaration

    Swift

    static func double(_ value: Double) -> RequestHeaders.Value

    Parameters

    value

    The Double value

    Return Value

    The header value

  • A value for the Content-Type header field

    Declaration

    Swift

    static func contentType(_ contentType: ContentType) -> RequestHeaders.Value

    Parameters

    contentType

    The content type value

    Return Value

    The header value

  • A value for the Cache-Control header field

    Declaration

    Swift

    static func cacheControlType(_ type: CacheControlType) -> RequestHeaders.Value

    Parameters

    type

    The cache control typr

    Return Value

    The header value

API

  • Available content types

    See more

    Declaration

    Swift

    enum ContentType : String, CustomStringConvertible, Equatable, Hashable
  • Available cache control types

    See more

    Declaration

    Swift

    enum CacheControlType : ExpressibleByStringLiteral, CustomStringConvertible, Equatable, Hashable