Downloadable

public protocol Downloadable : BaseRequestable

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

  • Creates a DownloadOperation for the specified Downloadable object.

    Declaration

    Swift

    @discardableResult
    public func operation(
        parameters: Any? = nil,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        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 DownloadOperation.

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

    Declaration

    Swift

    @discardableResult
    public func enqueue(
        parameters: Any? = nil,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        completionHandler: ((DownloadResponse<Response>) -> Void)? = nil
    ) throws -> Cancellable

    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 Cancellable.

  • Creates a DownloadOperation for the specified Downloadable object.

    Declaration

    Swift

    @discardableResult
    public func operation<T: Encodable>(
        parameters: T,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        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 Downloadable object and asynchronously executes it.

    Declaration

    Swift

    @discardableResult
    public func enqueue<T: Encodable>(
        parameters: T,
        downloadProgressHandler: ((Progress) -> Void, queue: DispatchQueue?)? = nil,
        completionQueue: DispatchQueue = .main,
        completionHandler: ((DownloadResponse<Response>) -> Void)? = nil
    ) throws -> Cancellable

    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 Cancellable.