Trait NSURLConnectionDataDelegate

Source
pub unsafe trait NSURLConnectionDataDelegate: NSURLConnectionDelegate {
    // Provided methods
    unsafe fn connection_willSendRequest_redirectResponse(
        &self,
        connection: &NSURLConnection,
        request: &NSURLRequest,
        response: Option<&NSURLResponse>,
    ) -> Option<Retained<NSURLRequest>>
       where Self: Sized + Message { ... }
    unsafe fn connection_didReceiveResponse(
        &self,
        connection: &NSURLConnection,
        response: &NSURLResponse,
    )
       where Self: Sized + Message { ... }
    unsafe fn connection_didReceiveData(
        &self,
        connection: &NSURLConnection,
        data: &NSData,
    )
       where Self: Sized + Message { ... }
    unsafe fn connection_needNewBodyStream(
        &self,
        connection: &NSURLConnection,
        request: &NSURLRequest,
    ) -> Option<Retained<NSInputStream>>
       where Self: Sized + Message { ... }
    unsafe fn connection_didSendBodyData_totalBytesWritten_totalBytesExpectedToWrite(
        &self,
        connection: &NSURLConnection,
        bytes_written: NSInteger,
        total_bytes_written: NSInteger,
        total_bytes_expected_to_write: NSInteger,
    )
       where Self: Sized + Message { ... }
    unsafe fn connection_willCacheResponse(
        &self,
        connection: &NSURLConnection,
        cached_response: &NSCachedURLResponse,
    ) -> Option<Retained<NSCachedURLResponse>>
       where Self: Sized + Message { ... }
    unsafe fn connectionDidFinishLoading(&self, connection: &NSURLConnection)
       where Self: Sized + Message { ... }
}
Available on crate feature NSURLConnection only.
Expand description

Delegate methods used for loading data to memory. These delegate methods are all optional.

connection:willSendRequest:redirectResponse: is called whenever an connection determines that it must change URLs in order to continue loading a request. This gives the delegate an opportunity inspect and if necessary modify a request. A delegate can cause the request to abort by either calling the connections -cancel method, or by returning nil from this callback.

There is one subtle difference which results from this choice. If -cancel is called in the delegate method, all processing for the connection stops, and no further delegate callbacks will be sent. If the delegate returns nil, the connection will continue to process, and this has special relevance in the case where the redirectResponse argument is non-nil. In this case, any data that is loaded for the connection will be sent to the delegate, and the delegate will receive a finished or failure delegate callback as appropriate.

connection:didReceiveResponse: is called when enough data has been read to construct an NSURLResponse object. In the event of a protocol which may return multiple responses (such as HTTP multipart/x-mixed-replace) the delegate should be prepared to inspect the new response and make itself ready for data callbacks as appropriate.

connection:didReceiveData: is called with a single immutable NSData object to the delegate, representing the next portion of the data loaded from the connection. This is the only guaranteed for the delegate to receive the data from the resource load.

connection:needNewBodyStream: is called when the loader must retransmit a requests payload, due to connection errors or authentication challenges. Delegates should construct a new unopened and autoreleased NSInputStream. If not implemented, the loader will be required to spool the bytes to be uploaded to disk, a potentially expensive operation. Returning nil will cancel the connection.

connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: is called during an upload operation to provide progress feedback. Note that the values may change in unexpected ways if the request needs to be retransmitted.

connection:willCacheResponse: gives the delegate an opportunity to inspect and modify the NSCachedURLResponse which will be cached by the loader if caching is enabled for the original NSURLRequest. Returning nil from this delegate will prevent the resource from being cached. Note that the -data method of the cached response may return an autoreleased in-memory copy of the true data, and should not be used as an alternative to receiving and accumulating the data through connection:didReceiveData:

connectionDidFinishLoading: is called when all connection processing has completed successfully, before the delegate is released by the connection.

See also Apple’s documentation

Provided Methods§

Source

unsafe fn connection_willSendRequest_redirectResponse( &self, connection: &NSURLConnection, request: &NSURLRequest, response: Option<&NSURLResponse>, ) -> Option<Retained<NSURLRequest>>
where Self: Sized + Message,

Available on crate features NSURLRequest and NSURLResponse only.
Source

unsafe fn connection_didReceiveResponse( &self, connection: &NSURLConnection, response: &NSURLResponse, )
where Self: Sized + Message,

Available on crate feature NSURLResponse only.
Source

unsafe fn connection_didReceiveData( &self, connection: &NSURLConnection, data: &NSData, )
where Self: Sized + Message,

Available on crate feature NSData only.
Source

unsafe fn connection_needNewBodyStream( &self, connection: &NSURLConnection, request: &NSURLRequest, ) -> Option<Retained<NSInputStream>>
where Self: Sized + Message,

Available on crate features NSStream and NSURLRequest only.
Source

unsafe fn connection_didSendBodyData_totalBytesWritten_totalBytesExpectedToWrite( &self, connection: &NSURLConnection, bytes_written: NSInteger, total_bytes_written: NSInteger, total_bytes_expected_to_write: NSInteger, )
where Self: Sized + Message,

Source

unsafe fn connection_willCacheResponse( &self, connection: &NSURLConnection, cached_response: &NSCachedURLResponse, ) -> Option<Retained<NSCachedURLResponse>>
where Self: Sized + Message,

Available on crate feature NSURLCache only.
Source

unsafe fn connectionDidFinishLoading(&self, connection: &NSURLConnection)
where Self: Sized + Message,

Trait Implementations§

Source§

impl ProtocolType for dyn NSURLConnectionDataDelegate

Source§

const NAME: &'static str = "NSURLConnectionDataDelegate"

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 NSURLConnectionDataDelegate

Implementations on Foreign Types§

Source§

impl<T> NSURLConnectionDataDelegate for ProtocolObject<T>

Implementors§