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 methods

    Declaration

    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 null

    Declaration

    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

    value

    The 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 convertable

    Declaration

    Swift

    func decode<T>(_ key: String) throws -> T

    Parameters

    key

    The key to look up in dictionary case

    Return 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 transformed

    Declaration

    Swift

    func decode<Value, Transform>(_ key: String, transform: (Value) throws -> Transform?) throws -> Transform

    Parameters

    key

    The key to look up in dictionary case

    transform

    The 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 throws

    Declaration

    Swift

    func decode<T>(_ key: String, fallback: @autoclosure () throws -> T) rethrows -> T

    Parameters

    key

    The key to look up in dictionary case

    fallback

    The fallback value to use if not found in the dictionary

    Return Value

    The value from the dictionary

Values

  • Allows HAData to be transformed from any underlying value

    Declaration

    Swift

    public static func decode(unknown value: Any) -> `Self`?

    Parameters

    value

    Any value

    Return Value

    The HAData-wrapped version of the value