Downloadable

public protocol Downloadable : _Requestable

Represents a Downloadable for Restofire.

protocol HTTPBinDownloadService: Downloadable {

    typealias Response = Data

    var path: String? = "bytes/\(4 * 1024 * 1024)"
    var destination: DownloadFileDestination?

    init(destination: @escaping DownloadFileDestination) {
        self.destination = destination
    }

}
  • resumeData Default implementation

    The resume data.

    Default Implementation

    nil

    Declaration

    Swift

    var resumeData: Data? { get }
  • destination Default implementation

    The download file destination.

    Default Implementation

    nil

    Declaration

    Swift

    var destination: DownloadRequest.Destination? { get }
  • validationBlock Default implementation

    The Alamofire data request validation.

    Default Implementation

    Validation.default.downloadValidation

    Declaration

    Swift

    var validationBlock: DownloadRequest.Validation? { get }
  • request(_:didCompleteWithValue:) Default implementation

    Called when the Request succeeds.

    Default Implementation

    Does Nothing

    Declaration

    Swift

    func request(_ request: DownloadOperation<Self>, didCompleteWithValue value: Response)

    Parameters

    request

    The Alamofire.DownloadRequest

    value

    The Response

  • request(_:didFailWithError:) Default implementation

    Called when the Request fails

    Default Implementation

    Does Nothing

    Declaration

    Swift

    func request(_ request: DownloadOperation<Self>, didFailWithError error: Error)

    Parameters

    request

    The Alamofire.DownloadRequest

    error

    The Error

  • asRequest() Extension method

    Creates a DownloadRequest to retrieve the contents of a URL based on the specified Requestable

    Declaration

    Swift

    func asRequest() throws -> DownloadRequest

    Return Value

    The created DownloadRequest.

  • Creates a DownloadOperation for the specified Requestable object.

    Declaration

    Swift

    @discardableResult
    public func operation(
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DownloadResponse<Response>) -> Void)? = nil
    ) throws -> DownloadOperation<Self>

    Parameters

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the request has finished. nil by default.

    Return Value

    The created RequestOperation.

  • Creates a DownloadOperation for the specified Requestable object.

    Declaration

    Swift

    public func operation(
        request: @autoclosure @escaping () -> DownloadRequest,
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DownloadResponse<Response>) -> Void)? = nil
    ) -> DownloadOperation<Self>

    Parameters

    request

    A data request instance

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the request has finished. nil by default.

    Return Value

    The created RequestOperation.

  • Creates a DownloadOperation for the specified Requestable object and asynchronously executes it.

    Declaration

    Swift

    @discardableResult
    public func execute(
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DownloadResponse<Response>) -> Void)? = nil
    ) throws -> DownloadOperation<Self>

    Parameters

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the download has finished. nil by default.

    Return Value

    The created DownloadOperation.

  • Creates a DownloadOperation for the specified Requestable object and asynchronously executes it.

    Declaration

    Swift

    @discardableResult
    public func execute(
        request: @autoclosure @escaping () -> DownloadRequest,
        downloadProgressHandler: ((Progress) -> Void)? = nil,
        completionHandler: ((DownloadResponse<Response>) -> Void)? = nil
    ) -> DownloadOperation<Self>

    Parameters

    request

    A download request instance

    downloadProgressHandler

    A closure to be executed once the download progresses. nil by default.

    completionHandler

    A closure to be executed once the download has finished. nil by default.

    Return Value

    The created DownloadOperation.