HAData
public enum HAData : Equatable
extension HAData: HADecodeTransformable
Data from a response
The root-level information in either the result for individual requests or event for subscriptions.
-
A dictionary response.
See also
get(_:)and associated methodsDeclaration
Swift
case dictionary([String : Any]) -
An array response.
Declaration
Swift
case array([HAData]) -
Any other response, e.g. a string or number
Declaration
Swift
case primitive(Any) -
An empty response, such as
nullDeclaration
Swift
case empty -
Convert an unknown value type into an enum case For use with direct response handling.
Declaration
Swift
public init(value: Any?)Parameters
valueThe value to convert
-
Declaration
Swift
public static func == (lhs: HAData, rhs: HAData) -> Bool -
Convenience access to the dictionary case for a particular key, with an expected type
Throws
If the key was not present in the dictionary or the type was not the expected type or convertableDeclaration
Swift
func decode<T>(_ key: String) throws -> TParameters
keyThe key to look up in
dictionarycaseReturn Value
The value from the dictionary
-
Convenience access to the dictionary case for a particular key, with an expected type, with a transform applied
Throws
If the key was not present in the dictionary or the type was not the expected type or the value couldn’t be transformedDeclaration
Swift
func decode<Value, Transform>(_ key: String, transform: (Value) throws -> Transform?) throws -> TransformParameters
keyThe key to look up in
dictionarycasetransformThe transform to apply to the value, when found
Return Value
The value from the dictionary
-
Convenience access to the dictionary case for a particular key, with an expected type
Throws
If the inner fallback block throwsDeclaration
Swift
func decode<T>(_ key: String, fallback: @autoclosure () throws -> T) rethrows -> TParameters
keyThe key to look up in
dictionarycasefallbackThe fallback value to use if not found in the dictionary
Return Value
The value from the dictionary
-
Allows HAData to be transformed from any underlying value
Declaration
Swift
public static func decode(unknown value: Any) -> `Self`?Parameters
valueAny value
Return Value
The
HAData-wrapped version of the value
View on GitHub