Trait NSURLDownloadDelegate

Source
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 { ... }
}
Available on crate feature NSURLDownload only.
Expand description

The NSURLDownloadDelegate delegate is used to report the progress of the download.

See also Apple’s documentation

Provided Methods§

Source

unsafe fn downloadDidBegin(&self, download: &NSURLDownload)
where Self: Sized + Message,

This method is called immediately after the download has started.

Parameter download: The download that just started downloading.

Source

unsafe fn download_willSendRequest_redirectResponse( &self, download: &NSURLDownload, request: &NSURLRequest, redirect_response: Option<&NSURLResponse>, ) -> Option<Retained<NSURLRequest>>
where Self: Sized + Message,

Available on crate features 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.

Source

unsafe fn download_canAuthenticateAgainstProtectionSpace( &self, connection: &NSURLDownload, protection_space: &NSURLProtectionSpace, ) -> bool
where Self: Sized + Message,

Available on crate feature 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

Source

unsafe fn download_didReceiveAuthenticationChallenge( &self, download: &NSURLDownload, challenge: &NSURLAuthenticationChallenge, )
where Self: Sized + Message,

Available on crate feature 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.

Source

unsafe fn download_didCancelAuthenticationChallenge( &self, download: &NSURLDownload, challenge: &NSURLAuthenticationChallenge, )
where Self: Sized + Message,

Available on crate feature NSURLAuthenticationChallenge only.

Cancel authentication for a given request

Parameter download: The download that’s cancelling

Parameter challenge: The NSURLAuthenticationChallenge to cancel authentication for

Source

unsafe fn downloadShouldUseCredentialStorage( &self, download: &NSURLDownload, ) -> bool
where Self: Sized + Message,

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.

Source

unsafe fn download_didReceiveResponse( &self, download: &NSURLDownload, response: &NSURLResponse, )
where Self: Sized + Message,

Available on crate feature 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.

Source

unsafe fn download_willResumeWithResponse_fromByte( &self, download: &NSURLDownload, response: &NSURLResponse, starting_byte: c_longlong, )
where Self: Sized + Message,

Available on crate feature 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:.

Source

unsafe fn download_didReceiveDataOfLength( &self, download: &NSURLDownload, length: NSUInteger, )
where Self: Sized + Message,

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.

Source

unsafe fn download_shouldDecodeSourceDataOfMIMEType( &self, download: &NSURLDownload, encoding_type: &NSString, ) -> bool
where Self: Sized + Message,

Available on crate feature 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.

Source

unsafe fn download_decideDestinationWithSuggestedFilename( &self, download: &NSURLDownload, filename: &NSString, )
where Self: Sized + Message,

Available on crate feature 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.

Source

unsafe fn download_didCreateDestination( &self, download: &NSURLDownload, path: &NSString, )
where Self: Sized + Message,

Available on crate feature 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.

Source

unsafe fn downloadDidFinish(&self, download: &NSURLDownload)
where Self: Sized + Message,

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.

Source

unsafe fn download_didFailWithError( &self, download: &NSURLDownload, error: &NSError, )
where Self: Sized + Message,

Available on crate feature 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.

Trait Implementations§

Source§

impl ProtocolType for dyn NSURLDownloadDelegate

Source§

const NAME: &'static str = "NSURLDownloadDelegate"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn NSURLDownloadDelegate

Implementations on Foreign Types§

Source§

impl<T> NSURLDownloadDelegate for ProtocolObject<T>

Implementors§