FutureResult

public enum FutureResult<T>

Result of a future, being either rejected with an error or fulfilled with a value.

  • fulfilled: A fulfilled future result, with a value.
  • rejected: A rejected future result, with an error.
  • The value is fulfilled

    Declaration

    Swift

    case fulfilled(T)
  • The value is rejected

    Declaration

    Swift

    case rejected(Error)
  • Creates a new FutureResult<T>, capturing the return value, or throw error of a function.

    Declaration

    Swift

    public init(_ capturing: () throws -> T)

    Parameters

    capturing

    Function to invoke, resulting in an error or a value.

  • Creates a new fulfilled FutureResult<T>.

    Declaration

    Swift

    public init(_ value: T)

    Parameters

    value

    A fulfilled value.

  • Creates a new rejected FutureResult<T>.

    Declaration

    Swift

    public init(_ error: Error)

    Parameters

    error

    A rejection error

  • Returns the value, if fulfilled

    Declaration

    Swift

    public var value: T? { get }
  • Returns the error, if rejected

    Declaration

    Swift

    public var error: Error? { get }
  • Indicates whether the value is rejected

    Declaration

    Swift

    public var isError: Bool { get }
  • Returns the a fulfilled value, or throws a rejection error

    Throws

    A rejection error.

    Declaration

    Swift

    @discardableResult
    public func unwrap() throws -> T

    Return Value

    A fulfilled value.

  • The description of this FutureResult<T>

    Declaration

    Swift

    public var description: String { get }
  • Undocumented

    Declaration

    Swift

    static var success: FutureResult { get }