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
}
}
-
resumeDataDefault implementationThe resume data.
Default Implementation
nilDeclaration
Swift
var resumeData: Data? { get } -
destinationDefault implementationThe download file destination.
Default Implementation
nilDeclaration
Swift
var destination: DownloadRequest.Destination? { get } -
validationBlockDefault implementationThe Alamofire data request validation.
Default Implementation
Validation.default.downloadValidationDeclaration
Swift
var validationBlock: DownloadRequest.Validation? { get } -
request(_:didCompleteWithValue:)Default implementationCalled when the Request succeeds.
Default Implementation
Does NothingDeclaration
Swift
func request(_ request: DownloadOperation<Self>, didCompleteWithValue value: Response)Parameters
requestThe Alamofire.DownloadRequest
valueThe Response
-
request(_:didFailWithError:)Default implementationCalled when the Request fails
Default Implementation
Does NothingDeclaration
Swift
func request(_ request: DownloadOperation<Self>, didFailWithError error: Error)Parameters
requestThe Alamofire.DownloadRequest
errorThe Error
-
Creates a
DownloadOperationfor the specifiedDownloadableobject.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
downloadProgressHandlerA closure to be executed once the download progresses.
nilby default.completionHandlerA closure to be executed once the request has finished.
nilby default.Return Value
The created
DownloadOperation. -
Creates a
DownloadOperationfor the specifiedDownloadableobject 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 -> CancellableParameters
downloadProgressHandlerA closure to be executed once the download progresses.
nilby default.completionHandlerA closure to be executed once the download has finished.
nilby default.Return Value
The created
Cancellable. -
Creates a
DownloadOperationfor the specifiedDownloadableobject.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
downloadProgressHandlerA closure to be executed once the download progresses.
nilby default.completionHandlerA closure to be executed once the request has finished.
nilby default.Return Value
The created
RequestOperation. -
Creates a
DownloadOperationfor the specifiedDownloadableobject 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 -> CancellableParameters
downloadProgressHandlerA closure to be executed once the download progresses.
nilby default.completionHandlerA closure to be executed once the download has finished.
nilby default.Return Value
The created
Cancellable.
Downloadable Protocol Reference