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
whereRawValue
isString
- 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.
-
Create a
Value
from aCustomStringConvertible
Declaration
Swift
public init<T>(_ value: T) where T : CustomStringConvertible
Parameters
value
The string convertible value
-
Create a
Value
from aRawRepresentable
Declaration
Swift
public init<T>(_ value: T) where T : RawRepresentable, T.RawValue == String
Parameters
value
The raw representable value
-
Create a
Value
from aString
Declaration
Swift
public init(_ value: String)
Parameters
value
The string
-
Declaration
Swift
public let description: String
-
Declaration
Swift
public typealias StringLiteralType = String
-
Declaration
Swift
public init(stringLiteral value: String)
-
Declaration
Swift
public typealias IntegerLiteralType = Int
-
Declaration
Swift
public init(integerLiteral value: Int)
-
Declaration
Swift
public typealias FloatLiteralType = Double
-
Declaration
Swift
public init(floatLiteral value: Double)
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Declaration
Swift
public static func == (lhs: Value, rhs: Value) -> Bool
-
Create a header value from a
String
Declaration
Swift
static func string(_ value: String) -> RequestHeaders.Value
Parameters
value
The
String
valueReturn Value
The header value
-
Create a header from an
Int
Declaration
Swift
static func int(_ value: Int) -> RequestHeaders.Value
Parameters
value
The
Int
valueReturn Value
The header value
-
Create a header from a
Double
Declaration
Swift
static func double(_ value: Double) -> RequestHeaders.Value
Parameters
value
The
Double
valueReturn Value
The header value
-
A value for the
Content-Type
header fieldDeclaration
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 fieldDeclaration
Swift
static func cacheControlType(_ type: CacheControlType) -> RequestHeaders.Value
Parameters
type
The cache control typr
Return Value
The header value