pub unsafe trait NSURLDownloadDelegate: NSObjectProtocol {
Show 14 methods
// Provided methods
unsafe fn downloadDidBegin(&self, download: &NSURLDownload)
where Self: Sized + Message { ... }
unsafe fn download_willSendRequest_redirectResponse(
&self,
download: &NSURLDownload,
request: &NSURLRequest,
redirect_response: Option<&NSURLResponse>,
) -> Option<Retained<NSURLRequest>>
where Self: Sized + Message { ... }
unsafe fn download_canAuthenticateAgainstProtectionSpace(
&self,
connection: &NSURLDownload,
protection_space: &NSURLProtectionSpace,
) -> bool
where Self: Sized + Message { ... }
unsafe fn download_didReceiveAuthenticationChallenge(
&self,
download: &NSURLDownload,
challenge: &NSURLAuthenticationChallenge,
)
where Self: Sized + Message { ... }
unsafe fn download_didCancelAuthenticationChallenge(
&self,
download: &NSURLDownload,
challenge: &NSURLAuthenticationChallenge,
)
where Self: Sized + Message { ... }
unsafe fn downloadShouldUseCredentialStorage(
&self,
download: &NSURLDownload,
) -> bool
where Self: Sized + Message { ... }
unsafe fn download_didReceiveResponse(
&self,
download: &NSURLDownload,
response: &NSURLResponse,
)
where Self: Sized + Message { ... }
unsafe fn download_willResumeWithResponse_fromByte(
&self,
download: &NSURLDownload,
response: &NSURLResponse,
starting_byte: c_longlong,
)
where Self: Sized + Message { ... }
unsafe fn download_didReceiveDataOfLength(
&self,
download: &NSURLDownload,
length: NSUInteger,
)
where Self: Sized + Message { ... }
unsafe fn download_shouldDecodeSourceDataOfMIMEType(
&self,
download: &NSURLDownload,
encoding_type: &NSString,
) -> bool
where Self: Sized + Message { ... }
unsafe fn download_decideDestinationWithSuggestedFilename(
&self,
download: &NSURLDownload,
filename: &NSString,
)
where Self: Sized + Message { ... }
unsafe fn download_didCreateDestination(
&self,
download: &NSURLDownload,
path: &NSString,
)
where Self: Sized + Message { ... }
unsafe fn downloadDidFinish(&self, download: &NSURLDownload)
where Self: Sized + Message { ... }
unsafe fn download_didFailWithError(
&self,
download: &NSURLDownload,
error: &NSError,
)
where Self: Sized + Message { ... }
}
NSURLDownload
only.Expand description
The NSURLDownloadDelegate delegate is used to report the progress of the download.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn downloadDidBegin(&self, download: &NSURLDownload)
unsafe fn downloadDidBegin(&self, download: &NSURLDownload)
This method is called immediately after the download has started.
Parameter download
: The download that just started downloading.
Sourceunsafe fn download_willSendRequest_redirectResponse(
&self,
download: &NSURLDownload,
request: &NSURLRequest,
redirect_response: Option<&NSURLResponse>,
) -> Option<Retained<NSURLRequest>>
Available on crate features NSURLRequest
and NSURLResponse
only.
unsafe fn download_willSendRequest_redirectResponse( &self, download: &NSURLDownload, request: &NSURLRequest, redirect_response: Option<&NSURLResponse>, ) -> Option<Retained<NSURLRequest>>
NSURLRequest
and NSURLResponse
only.This method is called if the download must load another request because the previous request was redirected.
Parameter download
: The download that will send the request.
Parameter request
: The request that will be used to continue loading.
Returns: The request to be used; either the request parameter or a replacement. If nil is returned, the download is cancelled.
This method gives the delegate an opportunity to inspect the request that will be used to continue loading the request, and modify it if necessary.
Sourceunsafe fn download_canAuthenticateAgainstProtectionSpace(
&self,
connection: &NSURLDownload,
protection_space: &NSURLProtectionSpace,
) -> bool
Available on crate feature NSURLProtectionSpace
only.
unsafe fn download_canAuthenticateAgainstProtectionSpace( &self, connection: &NSURLDownload, protection_space: &NSURLProtectionSpace, ) -> bool
NSURLProtectionSpace
only.This method gives the delegate an opportunity to inspect an NSURLProtectionSpace before an authentication attempt is made.
If implemented, will be called before connection:didReceiveAuthenticationChallenge to give the delegate a chance to inspect the protection space that will be authenticated against. Delegates should determine if they are prepared to respond to the authentication method of the protection space and if so, return YES, or NO to allow default processing to handle the authentication. If this delegate is not implemented, then default processing will occur (typically, consulting the user’s keychain and/or failing the connection attempt.
Parameter connection
: an NSURLConnection that has an NSURLProtectionSpace ready for inspection
Parameter protectionSpace
: an NSURLProtectionSpace that will be used to generate an authentication challenge
Returns: a boolean value that indicates the willingness of the delegate to handle the authentication
Sourceunsafe fn download_didReceiveAuthenticationChallenge(
&self,
download: &NSURLDownload,
challenge: &NSURLAuthenticationChallenge,
)
Available on crate feature NSURLAuthenticationChallenge
only.
unsafe fn download_didReceiveAuthenticationChallenge( &self, download: &NSURLDownload, challenge: &NSURLAuthenticationChallenge, )
NSURLAuthenticationChallenge
only.Start authentication for a given challenge
Parameter download
: The download that needs authentication.
Parameter challenge
: The NSURLAuthenticationChallenge for which to start authentication.
Call useCredential:forAuthenticationChallenge:, continueWithoutCredentialForAuthenticationChallenge: or cancel on the connection sender when done.
Sourceunsafe fn download_didCancelAuthenticationChallenge(
&self,
download: &NSURLDownload,
challenge: &NSURLAuthenticationChallenge,
)
Available on crate feature NSURLAuthenticationChallenge
only.
unsafe fn download_didCancelAuthenticationChallenge( &self, download: &NSURLDownload, challenge: &NSURLAuthenticationChallenge, )
NSURLAuthenticationChallenge
only.Cancel authentication for a given request
Parameter download
: The download that’s cancelling
Parameter challenge
: The NSURLAuthenticationChallenge to cancel authentication for
Sourceunsafe fn downloadShouldUseCredentialStorage(
&self,
download: &NSURLDownload,
) -> bool
unsafe fn downloadShouldUseCredentialStorage( &self, download: &NSURLDownload, ) -> bool
This method allows the delegate to inform the url loader that it should not consult the credential storage for the download.
This method will be called before any attempt to authenticate is attempted on a download. By returning NO the delegate is telling the download to not consult the credential storage and taking responsibility for providing any credentials for authentication challenges. Not implementing this method is the same as returning YES. The delegate is free to consult the credential storage itself when it receives a didReceiveAuthenticationChallenge message.
Parameter download
: the NSURLDownload object asking if it should consult the credential storage.
Returns: NO if the download should not consult the credential storage, Yes if it should.
Sourceunsafe fn download_didReceiveResponse(
&self,
download: &NSURLDownload,
response: &NSURLResponse,
)
Available on crate feature NSURLResponse
only.
unsafe fn download_didReceiveResponse( &self, download: &NSURLDownload, response: &NSURLResponse, )
NSURLResponse
only.This method is called when the download has received a response from the server.
Parameter download
: The download that now has a NSURLResponse available for inspection.
Parameter response
: The NSURLResponse object for the given download.
In some rare cases, multiple responses may be received for a single download. This occurs with multipart/x-mixed-replace, or “server push”. In this case, the client should assume that each new response resets progress so far for the resource back to 0, and should check the new response for the expected content length.
Sourceunsafe fn download_willResumeWithResponse_fromByte(
&self,
download: &NSURLDownload,
response: &NSURLResponse,
starting_byte: c_longlong,
)
Available on crate feature NSURLResponse
only.
unsafe fn download_willResumeWithResponse_fromByte( &self, download: &NSURLDownload, response: &NSURLResponse, starting_byte: c_longlong, )
NSURLResponse
only.This method is called when the download has received a response from the server after attempting to resume a download.
Parameter download
: The download that now has a NSURLResponse available for inspection.
Parameter response
: The NSURLResponse object for the given download.
Parameter startingByte
: The number of bytes from where the download will resume. 0 indicates that the download will
restart from the beginning.
download:willResumeWithResponse:fromByte: is called instead of download:didReceiveResponse: when a download is initialized with initWithResumeData:delegate:path:.
Sourceunsafe fn download_didReceiveDataOfLength(
&self,
download: &NSURLDownload,
length: NSUInteger,
)
unsafe fn download_didReceiveDataOfLength( &self, download: &NSURLDownload, length: NSUInteger, )
This method is called when the download has loaded data.
Parameter download
: The download that has received data.
Parameter length
: The length of the received data.
This method will be called one or more times.
Sourceunsafe fn download_shouldDecodeSourceDataOfMIMEType(
&self,
download: &NSURLDownload,
encoding_type: &NSString,
) -> bool
Available on crate feature NSString
only.
unsafe fn download_shouldDecodeSourceDataOfMIMEType( &self, download: &NSURLDownload, encoding_type: &NSString, ) -> bool
NSString
only.This method is called if the download detects that the downloading file is encoded.
Parameter download
: The download that has detected that the downloading file is encoded.
Parameter encodingType
: A MIME type expressing the encoding type.
Returns: Return YES to decode the file, NO to not decode the file.
An encoded file is encoded in MacBinary, BinHex or gzip format. This method may be called more than once if the file is encoded multiple times. This method is not called if the download is not encoded.
Sourceunsafe fn download_decideDestinationWithSuggestedFilename(
&self,
download: &NSURLDownload,
filename: &NSString,
)
Available on crate feature NSString
only.
unsafe fn download_decideDestinationWithSuggestedFilename( &self, download: &NSURLDownload, filename: &NSString, )
NSString
only.This method is called when enough information has been loaded to decide a destination for the downloaded file.
Parameter download
: The download that requests the download path.
Parameter filename
: The suggested filename for deciding the path of the downloaded file. The filename is either
derived from the last path component of the URL and the MIME type or if the download was encoded,
it is the filename specified in the encoding.
Once the delegate has decided a path, it should call setDestination:allowOverwrite:. The delegate may respond immediately or later. This method is not called if setDestination:allowOverwrite: has already been called.
Sourceunsafe fn download_didCreateDestination(
&self,
download: &NSURLDownload,
path: &NSString,
)
Available on crate feature NSString
only.
unsafe fn download_didCreateDestination( &self, download: &NSURLDownload, path: &NSString, )
NSString
only.This method is called after the download creates the downloaded file.
Parameter download
: The download that created the downloaded file.
Parameter path
: The path of the downloaded file.
Sourceunsafe fn downloadDidFinish(&self, download: &NSURLDownload)
unsafe fn downloadDidFinish(&self, download: &NSURLDownload)
This method is called when the download has finished downloading.
Parameter download
: The download that has finished downloading.
This method is called after all the data has been received and written to disk. This method or download:didFailWithError: will only be called once.
Sourceunsafe fn download_didFailWithError(
&self,
download: &NSURLDownload,
error: &NSError,
)
Available on crate feature NSError
only.
unsafe fn download_didFailWithError( &self, download: &NSURLDownload, error: &NSError, )
NSError
only.This method is called when the download has failed.
Parameter download
: The download that ended in error.
Parameter error
: The error caused the download to fail.
This method is called when the download encounters a network or file I/O related error. This method or downloadDidFinish: will only be called once.