objc2_foundation/generated/NSURLConnection.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10 /// An NSURLConnection object provides support to perform
11 /// asynchronous loads of a URL request, providing data to a
12 /// client supplied delegate.
13 ///
14 ///
15 /// The interface for NSURLConnection is very sparse, providing
16 /// only the controls to start and cancel asynchronous loads of a
17 /// URL request.
18 /// <p>
19 ///
20 /// An NSURLConnection may be used for loading of resource data
21 /// directly to memory, in which case an
22 /// NSURLConnectionDataDelegate should be supplied, or for
23 /// downloading of resource data directly to a file, in which case
24 /// an NSURLConnectionDownloadDelegate is used. The delegate is
25 /// retained by the NSURLConnection until a terminal condition is
26 /// encountered. These two delegates are logically subclasses of
27 /// the base protocol, NSURLConnectionDelegate.
28 /// <p>
29 ///
30 /// A terminal condition produced by the loader will result in a
31 /// connection:didFailWithError: in the case of an error, or
32 /// connectionDidFinishLoading: or connectionDidFinishDownloading:
33 /// delegate message.
34 /// <p>
35 ///
36 /// The -cancel message hints to the loader that a resource load
37 /// should be abandoned but does not guarantee that more delegate
38 /// messages will not be delivered. If -cancel does cause the
39 /// load to be abandoned, the delegate will be released without
40 /// further messages. In general, a caller should be prepared for
41 /// -cancel to have no effect, and internally ignore any delegate
42 /// callbacks until the delegate is released.
43 ///
44 /// Scheduling of an NSURLConnection specifies the context in
45 /// which delegate callbacks will be made, but the actual IO may
46 /// occur on a separate thread and should be considered an
47 /// implementation detail.
48 /// <p>
49 ///
50 /// When created, an NSURLConnection performs a deep-copy of the
51 /// NSURLRequest. This copy is available through the
52 /// -originalRequest method. As the connection performs the load,
53 /// this request may change as a result of protocol
54 /// canonicalization or due to following redirects.
55 /// -currentRequest can be used to retrieve this value.
56 /// <p>
57 ///
58 /// An NSURLConnections created with the
59 /// +connectionWithRequest:delegate: or -initWithRequest:delegate:
60 /// methods are scheduled on the current runloop immediately, and
61 /// it is not necessary to send the -start message to begin the
62 /// resource load.
63 /// <p>
64 ///
65 /// NSURLConnections created with
66 /// -initWithRequest:delegate:startImmediately: are not
67 /// automatically scheduled. Use -scheduleWithRunLoop:forMode: or
68 /// -setDelegateQueue: to specify the context for delegate
69 /// callbacks, and -start to begin the load. If you do not
70 /// explicitly schedule the connection before -start, it will be
71 /// scheduled on the current runloop and mode automatically.
72 /// <p>
73 ///
74 /// The NSURLConnectionSynchronousLoading category adds
75 /// +sendSynchronousRequest:returningResponse:error, which blocks
76 /// the current thread until the resource data is available or an
77 /// error occurs. It should be noted that using this method on an
78 /// applications main run loop may result in an unacceptably long
79 /// delay in a user interface and its use is strongly
80 /// discourage.
81 /// <p>
82 ///
83 /// The NSURLConnectionQueuedLoading category implements
84 /// +sendAsynchronousRequest:queue:completionHandler, providing
85 /// similar simplicity but provides a mechanism where the current
86 /// runloop is not blocked.
87 /// <p>
88 ///
89 /// Both of the immediate loading categories do not provide for
90 /// customization of resource load, and do not allow the caller to
91 /// respond to, e.g., authentication challenges.
92 /// <p>
93 ///
94 /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlconnection?language=objc)
95 #[unsafe(super(NSObject))]
96 #[derive(Debug, PartialEq, Eq, Hash)]
97 pub struct NSURLConnection;
98);
99
100extern_conformance!(
101 unsafe impl NSObjectProtocol for NSURLConnection {}
102);
103
104impl NSURLConnection {
105 extern_methods!(
106 #[cfg(feature = "NSURLRequest")]
107 /// # Safety
108 ///
109 /// `delegate` should be of the correct type.
110 #[deprecated = "Use NSURLSession (see NSURLSession.h)"]
111 #[unsafe(method(initWithRequest:delegate:startImmediately:))]
112 #[unsafe(method_family = init)]
113 pub unsafe fn initWithRequest_delegate_startImmediately(
114 this: Allocated<Self>,
115 request: &NSURLRequest,
116 delegate: Option<&AnyObject>,
117 start_immediately: bool,
118 ) -> Option<Retained<Self>>;
119
120 #[cfg(feature = "NSURLRequest")]
121 /// # Safety
122 ///
123 /// `delegate` should be of the correct type.
124 #[deprecated = "Use NSURLSession (see NSURLSession.h)"]
125 #[unsafe(method(initWithRequest:delegate:))]
126 #[unsafe(method_family = init)]
127 pub unsafe fn initWithRequest_delegate(
128 this: Allocated<Self>,
129 request: &NSURLRequest,
130 delegate: Option<&AnyObject>,
131 ) -> Option<Retained<Self>>;
132
133 #[cfg(feature = "NSURLRequest")]
134 /// # Safety
135 ///
136 /// `delegate` should be of the correct type.
137 #[deprecated = "Use NSURLSession (see NSURLSession.h)"]
138 #[unsafe(method(connectionWithRequest:delegate:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn connectionWithRequest_delegate(
141 request: &NSURLRequest,
142 delegate: Option<&AnyObject>,
143 ) -> Option<Retained<NSURLConnection>>;
144
145 #[cfg(feature = "NSURLRequest")]
146 #[unsafe(method(originalRequest))]
147 #[unsafe(method_family = none)]
148 pub fn originalRequest(&self) -> Retained<NSURLRequest>;
149
150 #[cfg(feature = "NSURLRequest")]
151 #[unsafe(method(currentRequest))]
152 #[unsafe(method_family = none)]
153 pub fn currentRequest(&self) -> Retained<NSURLRequest>;
154
155 #[unsafe(method(start))]
156 #[unsafe(method_family = none)]
157 pub fn start(&self);
158
159 #[unsafe(method(cancel))]
160 #[unsafe(method_family = none)]
161 pub fn cancel(&self);
162
163 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
164 /// # Safety
165 ///
166 /// `a_run_loop` possibly has additional threading requirements.
167 #[unsafe(method(scheduleInRunLoop:forMode:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn scheduleInRunLoop_forMode(
170 &self,
171 a_run_loop: &NSRunLoop,
172 mode: &NSRunLoopMode,
173 );
174
175 #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
176 /// # Safety
177 ///
178 /// `a_run_loop` possibly has additional threading requirements.
179 #[unsafe(method(unscheduleFromRunLoop:forMode:))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn unscheduleFromRunLoop_forMode(
182 &self,
183 a_run_loop: &NSRunLoop,
184 mode: &NSRunLoopMode,
185 );
186
187 #[cfg(feature = "NSOperation")]
188 /// # Safety
189 ///
190 /// `queue` possibly has additional threading requirements.
191 #[unsafe(method(setDelegateQueue:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn setDelegateQueue(&self, queue: Option<&NSOperationQueue>);
194
195 #[cfg(feature = "NSURLRequest")]
196 /// Performs a "preflight" operation that performs
197 /// some speculative checks to see if a connection can
198 /// be initialized, and the associated I/O that is
199 /// started in the initializer methods can begin.
200 ///
201 ///
202 /// The result of this method is valid only as long as
203 /// no protocols are registered or unregistered, and
204 /// as long as the request is not mutated (if the
205 /// request is mutable). Hence, clients should be
206 /// prepared to handle failures even if they have
207 /// performed request preflighting by calling this
208 /// method.
209 ///
210 ///
211 /// Parameter `request`: The request to preflight.
212 ///
213 ///
214 /// Returns: YES if it is likely that the given request can be used to
215 /// initialize a connection and the associated I/O can be
216 /// started, NO otherwise.
217 #[unsafe(method(canHandleRequest:))]
218 #[unsafe(method_family = none)]
219 pub fn canHandleRequest(request: &NSURLRequest) -> bool;
220 );
221}
222
223/// Methods declared on superclass `NSObject`.
224impl NSURLConnection {
225 extern_methods!(
226 #[unsafe(method(init))]
227 #[unsafe(method_family = init)]
228 pub fn init(this: Allocated<Self>) -> Retained<Self>;
229
230 #[unsafe(method(new))]
231 #[unsafe(method_family = new)]
232 pub fn new() -> Retained<Self>;
233 );
234}
235
236impl DefaultRetained for NSURLConnection {
237 #[inline]
238 fn default_retained() -> Retained<Self> {
239 Self::new()
240 }
241}
242
243extern_protocol!(
244 /// Delegate methods that are common to all forms of
245 /// NSURLConnection. These are all optional. This
246 /// protocol should be considered a base class for the
247 /// NSURLConnectionDataDelegate and
248 /// NSURLConnectionDownloadDelegate protocols.
249 ///
250 ///
251 /// connection:didFailWithError: will be called at
252 /// most once, if an error occurs during a resource
253 /// load. No other callbacks will be made after.
254 /// <p>
255 ///
256 /// connectionShouldUseCredentialStorage: will be
257 /// called at most once, before a resource load begins
258 /// (which means it may be called during construction
259 /// of the connection.) The delegate should return
260 /// TRUE if the connection should consult the shared
261 /// NSURLCredentialStorage in response to
262 /// authentication challenges. Regardless of the
263 /// result, the authentication challenge methods may
264 /// still be called.
265 ///
266 /// connection:willSendRequestForAuthenticationChallenge:
267 /// is the preferred (Mac OS X 10.7 and iOS 5.0 or
268 /// later) mechanism for responding to authentication
269 /// challenges. See
270 /// <Foundation
271 /// /NSURLAuthenticationChallenge.h> for
272 /// more information on dealing with the various types
273 /// of authentication challenges.
274 ///
275 /// connection:canAuthenticateAgainstProtectionSpace:
276 /// connection:didReceiveAuthenticationChallenge:
277 /// connection:didCancelAuthenticationChallenge: are
278 /// deprecated and new code should adopt
279 /// connection:willSendRequestForAuthenticationChallenge.
280 /// The older delegates will still be called for
281 /// compatibility, but incur more latency in dealing
282 /// with the authentication challenge.
283 ///
284 /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlconnectiondelegate?language=objc)
285 pub unsafe trait NSURLConnectionDelegate: NSObjectProtocol {
286 #[cfg(feature = "NSError")]
287 #[optional]
288 #[unsafe(method(connection:didFailWithError:))]
289 #[unsafe(method_family = none)]
290 fn connection_didFailWithError(&self, connection: &NSURLConnection, error: &NSError);
291
292 #[optional]
293 #[unsafe(method(connectionShouldUseCredentialStorage:))]
294 #[unsafe(method_family = none)]
295 fn connectionShouldUseCredentialStorage(&self, connection: &NSURLConnection) -> bool;
296
297 #[cfg(feature = "NSURLAuthenticationChallenge")]
298 #[optional]
299 #[unsafe(method(connection:willSendRequestForAuthenticationChallenge:))]
300 #[unsafe(method_family = none)]
301 fn connection_willSendRequestForAuthenticationChallenge(
302 &self,
303 connection: &NSURLConnection,
304 challenge: &NSURLAuthenticationChallenge,
305 );
306
307 #[cfg(feature = "NSURLProtectionSpace")]
308 #[deprecated = "Use -connection:willSendRequestForAuthenticationChallenge: instead."]
309 #[optional]
310 #[unsafe(method(connection:canAuthenticateAgainstProtectionSpace:))]
311 #[unsafe(method_family = none)]
312 fn connection_canAuthenticateAgainstProtectionSpace(
313 &self,
314 connection: &NSURLConnection,
315 protection_space: &NSURLProtectionSpace,
316 ) -> bool;
317
318 #[cfg(feature = "NSURLAuthenticationChallenge")]
319 #[deprecated = "Use -connection:willSendRequestForAuthenticationChallenge: instead."]
320 #[optional]
321 #[unsafe(method(connection:didReceiveAuthenticationChallenge:))]
322 #[unsafe(method_family = none)]
323 fn connection_didReceiveAuthenticationChallenge(
324 &self,
325 connection: &NSURLConnection,
326 challenge: &NSURLAuthenticationChallenge,
327 );
328
329 #[cfg(feature = "NSURLAuthenticationChallenge")]
330 #[deprecated = "Use -connection:willSendRequestForAuthenticationChallenge: instead."]
331 #[optional]
332 #[unsafe(method(connection:didCancelAuthenticationChallenge:))]
333 #[unsafe(method_family = none)]
334 fn connection_didCancelAuthenticationChallenge(
335 &self,
336 connection: &NSURLConnection,
337 challenge: &NSURLAuthenticationChallenge,
338 );
339 }
340);
341
342extern_protocol!(
343 /// Delegate methods used for loading data to memory.
344 /// These delegate methods are all optional.
345 ///
346 ///
347 /// connection:willSendRequest:redirectResponse: is
348 /// called whenever an connection determines that it
349 /// must change URLs in order to continue loading a
350 /// request. This gives the delegate an opportunity
351 /// inspect and if necessary modify a request. A
352 /// delegate can cause the request to abort by either
353 /// calling the connections -cancel method, or by
354 /// returning nil from this callback.
355 /// <p>
356 ///
357 /// There is one subtle difference which results from
358 /// this choice. If -cancel is called in the delegate
359 /// method, all processing for the connection stops,
360 /// and no further delegate callbacks will be sent. If
361 /// the delegate returns nil, the connection will
362 /// continue to process, and this has special
363 /// relevance in the case where the redirectResponse
364 /// argument is non-nil. In this case, any data that
365 /// is loaded for the connection will be sent to the
366 /// delegate, and the delegate will receive a finished
367 /// or failure delegate callback as appropriate.
368 /// <p>
369 ///
370 /// connection:didReceiveResponse: is called when
371 /// enough data has been read to construct an
372 /// NSURLResponse object. In the event of a protocol
373 /// which may return multiple responses (such as HTTP
374 /// multipart/x-mixed-replace) the delegate should be
375 /// prepared to inspect the new response and make
376 /// itself ready for data callbacks as appropriate.
377 /// <p>
378 ///
379 /// connection:didReceiveData: is called with a single
380 /// immutable NSData object to the delegate,
381 /// representing the next portion of the data loaded
382 /// from the connection. This is the only guaranteed
383 /// for the delegate to receive the data from the
384 /// resource load.
385 /// <p>
386 ///
387 /// connection:needNewBodyStream: is called when the
388 /// loader must retransmit a requests payload, due to
389 /// connection errors or authentication challenges.
390 /// Delegates should construct a new unopened and
391 /// autoreleased NSInputStream. If not implemented,
392 /// the loader will be required to spool the bytes to
393 /// be uploaded to disk, a potentially expensive
394 /// operation. Returning nil will cancel the
395 /// connection.
396 ///
397 /// connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:
398 /// is called during an upload operation to provide
399 /// progress feedback. Note that the values may
400 /// change in unexpected ways if the request needs to
401 /// be retransmitted.
402 /// <p>
403 ///
404 /// connection:willCacheResponse: gives the delegate
405 /// an opportunity to inspect and modify the
406 /// NSCachedURLResponse which will be cached by the
407 /// loader if caching is enabled for the original
408 /// NSURLRequest. Returning nil from this delegate
409 /// will prevent the resource from being cached. Note
410 /// that the -data method of the cached response may
411 /// return an autoreleased in-memory copy of the true
412 /// data, and should not be used as an alternative to
413 /// receiving and accumulating the data through
414 /// connection:didReceiveData:
415 /// <p>
416 ///
417 /// connectionDidFinishLoading: is called when all
418 /// connection processing has completed successfully,
419 /// before the delegate is released by the
420 /// connection.
421 /// <p>
422 ///
423 /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlconnectiondatadelegate?language=objc)
424 pub unsafe trait NSURLConnectionDataDelegate: NSURLConnectionDelegate {
425 #[cfg(all(feature = "NSURLRequest", feature = "NSURLResponse"))]
426 #[optional]
427 #[unsafe(method(connection:willSendRequest:redirectResponse:))]
428 #[unsafe(method_family = none)]
429 fn connection_willSendRequest_redirectResponse(
430 &self,
431 connection: &NSURLConnection,
432 request: &NSURLRequest,
433 response: Option<&NSURLResponse>,
434 ) -> Option<Retained<NSURLRequest>>;
435
436 #[cfg(feature = "NSURLResponse")]
437 #[optional]
438 #[unsafe(method(connection:didReceiveResponse:))]
439 #[unsafe(method_family = none)]
440 fn connection_didReceiveResponse(
441 &self,
442 connection: &NSURLConnection,
443 response: &NSURLResponse,
444 );
445
446 #[cfg(feature = "NSData")]
447 #[optional]
448 #[unsafe(method(connection:didReceiveData:))]
449 #[unsafe(method_family = none)]
450 fn connection_didReceiveData(&self, connection: &NSURLConnection, data: &NSData);
451
452 #[cfg(all(feature = "NSStream", feature = "NSURLRequest"))]
453 #[optional]
454 #[unsafe(method(connection:needNewBodyStream:))]
455 #[unsafe(method_family = none)]
456 fn connection_needNewBodyStream(
457 &self,
458 connection: &NSURLConnection,
459 request: &NSURLRequest,
460 ) -> Option<Retained<NSInputStream>>;
461
462 #[optional]
463 #[unsafe(method(connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:))]
464 #[unsafe(method_family = none)]
465 fn connection_didSendBodyData_totalBytesWritten_totalBytesExpectedToWrite(
466 &self,
467 connection: &NSURLConnection,
468 bytes_written: NSInteger,
469 total_bytes_written: NSInteger,
470 total_bytes_expected_to_write: NSInteger,
471 );
472
473 #[cfg(feature = "NSURLCache")]
474 #[optional]
475 #[unsafe(method(connection:willCacheResponse:))]
476 #[unsafe(method_family = none)]
477 fn connection_willCacheResponse(
478 &self,
479 connection: &NSURLConnection,
480 cached_response: &NSCachedURLResponse,
481 ) -> Option<Retained<NSCachedURLResponse>>;
482
483 #[optional]
484 #[unsafe(method(connectionDidFinishLoading:))]
485 #[unsafe(method_family = none)]
486 fn connectionDidFinishLoading(&self, connection: &NSURLConnection);
487 }
488);
489
490extern_protocol!(
491 /// Delegate methods used to perform resource
492 /// downloads directly to a disk file. All the
493 /// methods are optional with the exception of
494 /// connectionDidFinishDownloading:destinationURL:
495 /// which must be implemented in order to inform the
496 /// delegate of the location of the finished download.
497 /// This delegate and download implementation is
498 /// currently only available on iOS 5.0 or later.
499 ///
500 ///
501 /// connection:didWriteData:totalBytesWritten:expectedTotalBytes:
502 /// provides progress information about the state of
503 /// the download, the number of bytes written since
504 /// the last delegate callback, the total number of
505 /// bytes written to disk and the total number of
506 /// bytes that are expected (or 0 if this is unknown.)
507 ///
508 /// connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytes:
509 /// is called when the connection is able to resume an
510 /// in progress download. This may happen due to a
511 /// connection or network failure.
512 ///
513 /// connectionDidFinishDownloading:destinationURL: is
514 /// a terminal event which indicates the completion of
515 /// a download and provides the location of the file.
516 /// The file will be located in the applications cache
517 /// directory and is guaranteed to exist for the
518 /// duration of the delegate callback. The
519 /// implication is that the delegate should copy or
520 /// move the download to a more persistent location if
521 /// desired.
522 ///
523 /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlconnectiondownloaddelegate?language=objc)
524 pub unsafe trait NSURLConnectionDownloadDelegate: NSURLConnectionDelegate {
525 #[optional]
526 #[unsafe(method(connection:didWriteData:totalBytesWritten:expectedTotalBytes:))]
527 #[unsafe(method_family = none)]
528 fn connection_didWriteData_totalBytesWritten_expectedTotalBytes(
529 &self,
530 connection: &NSURLConnection,
531 bytes_written: c_longlong,
532 total_bytes_written: c_longlong,
533 expected_total_bytes: c_longlong,
534 );
535
536 #[optional]
537 #[unsafe(method(connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytes:))]
538 #[unsafe(method_family = none)]
539 fn connectionDidResumeDownloading_totalBytesWritten_expectedTotalBytes(
540 &self,
541 connection: &NSURLConnection,
542 total_bytes_written: c_longlong,
543 expected_total_bytes: c_longlong,
544 );
545
546 #[cfg(feature = "NSURL")]
547 #[unsafe(method(connectionDidFinishDownloading:destinationURL:))]
548 #[unsafe(method_family = none)]
549 fn connectionDidFinishDownloading_destinationURL(
550 &self,
551 connection: &NSURLConnection,
552 destination_url: &NSURL,
553 );
554 }
555);
556
557/// NSURLConnectionSynchronousLoading.
558///
559/// The NSURLConnectionSynchronousLoading category on
560/// NSURLConnection provides the interface to perform
561/// synchronous loading of URL requests.
562impl NSURLConnection {
563 extern_methods!(
564 #[cfg(all(
565 feature = "NSData",
566 feature = "NSError",
567 feature = "NSURLRequest",
568 feature = "NSURLResponse"
569 ))]
570 /// Performs a synchronous load of the given request,
571 /// returning an NSURLResponse in the given out
572 /// parameter.
573 ///
574 ///
575 /// A synchronous load for the given request is built on
576 /// top of the asynchronous loading code made available
577 /// by the class. The calling thread is blocked while
578 /// the asynchronous loading system performs the URL load
579 /// on a thread spawned specifically for this load
580 /// request. No special threading or run loop
581 /// configuration is necessary in the calling thread in
582 /// order to perform a synchronous load. For instance,
583 /// the calling thread need not be running its run loop.
584 ///
585 ///
586 /// Parameter `request`: The request to load. Note that the request is
587 /// deep-copied as part of the initialization
588 /// process. Changes made to the request argument after
589 /// this method returns do not affect the request that is
590 /// used for the loading process.
591 ///
592 ///
593 /// Parameter `response`: An out parameter which is filled in with the
594 /// response generated by performing the load.
595 ///
596 ///
597 /// Parameter `error`: Out parameter (may be NULL) used if an error occurs
598 /// while processing the request. Will not be modified if the
599 /// load succeeds.
600 ///
601 ///
602 /// Returns: The content of the URL resulting from performing the load,
603 /// or nil if the load failed.
604 #[deprecated = "Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h"]
605 #[unsafe(method(sendSynchronousRequest:returningResponse:error:_))]
606 #[unsafe(method_family = none)]
607 pub fn sendSynchronousRequest_returningResponse_error(
608 request: &NSURLRequest,
609 response: Option<&mut Option<Retained<NSURLResponse>>>,
610 ) -> Result<Retained<NSData>, Retained<NSError>>;
611 );
612}
613
614/// NSURLConnectionQueuedLoading.
615///
616/// The NSURLConnectionQueuedLoading category on NSURLConnection
617/// provides the interface to perform asynchronous loading of URL
618/// requests where the results of the request are delivered to a
619/// block via an NSOperationQueue.
620///
621/// Note that there is no guarantee of load ordering implied by this
622/// method.
623impl NSURLConnection {
624 extern_methods!(
625 #[cfg(all(
626 feature = "NSData",
627 feature = "NSError",
628 feature = "NSOperation",
629 feature = "NSURLRequest",
630 feature = "NSURLResponse",
631 feature = "block2"
632 ))]
633 /// Performs an asynchronous load of the given
634 /// request. When the request has completed or failed,
635 /// the block will be executed from the context of the
636 /// specified NSOperationQueue.
637 ///
638 ///
639 /// This is a convenience routine that allows for
640 /// asynchronous loading of a url-based resource. If
641 /// the resource load is successful, the data parameter
642 /// to the callback will contain the resource data and
643 /// the error parameter will be nil. If the resource
644 /// load fails, the data parameter will be nil and the
645 /// error will contain information about the failure.
646 ///
647 ///
648 /// Parameter `request`: The request to load. Note that the request is
649 /// deep-copied as part of the initialization
650 /// process. Changes made to the request argument after
651 /// this method returns do not affect the request that
652 /// is used for the loading process.
653 ///
654 ///
655 /// Parameter `queue`: An NSOperationQueue upon which the handler block will
656 /// be dispatched.
657 ///
658 ///
659 /// Parameter `handler`: A block which receives the results of the resource load.
660 ///
661 /// # Safety
662 ///
663 /// `queue` possibly has additional threading requirements.
664 #[deprecated = "Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h"]
665 #[unsafe(method(sendAsynchronousRequest:queue:completionHandler:))]
666 #[unsafe(method_family = none)]
667 pub unsafe fn sendAsynchronousRequest_queue_completionHandler(
668 request: &NSURLRequest,
669 queue: &NSOperationQueue,
670 handler: &block2::DynBlock<dyn Fn(*mut NSURLResponse, *mut NSData, *mut NSError)>,
671 );
672 );
673}