ResponseBodyWrapper

@propertyWrapper
public struct ResponseBodyWrapper<Body, BodyStrategy> where Body : Decodable, BodyStrategy : ResponseBodyDecodingStrategy
extension ResponseBodyWrapper: Decodable

A property wrapper that wraps a response body.

The ResponseBodyWrapper property wrapper is used to wrap a response body value. It provides a wrappedValue property that holds the response body value.

Example usage:

@ResponseBodyWrapper var responseBody: MyResponseType?
  • The wrapped value representing the decoded response body.

    This property holds the decoded response body that is managed by this property wrapper.

    Declaration

    Swift

    public var wrappedValue: Body?
  • Initializes a new instance of ResponseBodyWrapper with a nil value.

    Example usage:

    @ResponseBodyWrapper var responseBody: MyResponseType?
    

    Declaration

    Swift

    public init()
  • Initializes a new instance of ResponseBodyWrapper with the specified wrapped value.

    Example usage:

    @ResponseBodyWrapper var responseBody: MyResponseType? = MyResponseType()
    

    Declaration

    Swift

    public init(wrappedValue: Body?)

    Parameters

    wrappedValue

    The wrapped value representing the decoded response body.

Decodable

  • Initializes a new instance of ResponseBodyWrapper from a decoder.

    Throws

    An error if the decoder is not a ResponseDecoding instance or if the response body cannot be decoded.

    Example usage:

    let responseBody: MyResponseType? = try ResponseBodyWrapper(from: decoder)
    

    Declaration

    Swift

    public init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use for decoding the response body.