objc2_foundation/generated/
NSURLSession.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 "C" {
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontransfersizeunknown?language=objc)
11    pub static NSURLSessionTransferSizeUnknown: i64;
12}
13
14extern_class!(
15    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsession?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct NSURLSession;
19);
20
21unsafe impl Send for NSURLSession {}
22
23unsafe impl Sync for NSURLSession {}
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for NSURLSession {}
27);
28
29impl NSURLSession {
30    extern_methods!(
31        #[unsafe(method(sharedSession))]
32        #[unsafe(method_family = none)]
33        pub unsafe fn sharedSession() -> Retained<NSURLSession>;
34
35        #[unsafe(method(sessionWithConfiguration:))]
36        #[unsafe(method_family = none)]
37        pub unsafe fn sessionWithConfiguration(
38            configuration: &NSURLSessionConfiguration,
39        ) -> Retained<NSURLSession>;
40
41        #[cfg(feature = "NSOperation")]
42        #[unsafe(method(sessionWithConfiguration:delegate:delegateQueue:))]
43        #[unsafe(method_family = none)]
44        pub unsafe fn sessionWithConfiguration_delegate_delegateQueue(
45            configuration: &NSURLSessionConfiguration,
46            delegate: Option<&ProtocolObject<dyn NSURLSessionDelegate>>,
47            queue: Option<&NSOperationQueue>,
48        ) -> Retained<NSURLSession>;
49
50        #[cfg(feature = "NSOperation")]
51        #[unsafe(method(delegateQueue))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn delegateQueue(&self) -> Retained<NSOperationQueue>;
54
55        #[unsafe(method(delegate))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn delegate(&self)
58            -> Option<Retained<ProtocolObject<dyn NSURLSessionDelegate>>>;
59
60        #[unsafe(method(configuration))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn configuration(&self) -> Retained<NSURLSessionConfiguration>;
63
64        #[cfg(feature = "NSString")]
65        #[unsafe(method(sessionDescription))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn sessionDescription(&self) -> Option<Retained<NSString>>;
68
69        #[cfg(feature = "NSString")]
70        /// Setter for [`sessionDescription`][Self::sessionDescription].
71        #[unsafe(method(setSessionDescription:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setSessionDescription(&self, session_description: Option<&NSString>);
74
75        #[unsafe(method(finishTasksAndInvalidate))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn finishTasksAndInvalidate(&self);
78
79        #[unsafe(method(invalidateAndCancel))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn invalidateAndCancel(&self);
82
83        #[cfg(feature = "block2")]
84        #[unsafe(method(resetWithCompletionHandler:))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn resetWithCompletionHandler(
87            &self,
88            completion_handler: &block2::DynBlock<dyn Fn()>,
89        );
90
91        #[cfg(feature = "block2")]
92        #[unsafe(method(flushWithCompletionHandler:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn flushWithCompletionHandler(
95            &self,
96            completion_handler: &block2::DynBlock<dyn Fn()>,
97        );
98
99        #[cfg(all(feature = "NSArray", feature = "block2"))]
100        #[unsafe(method(getTasksWithCompletionHandler:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn getTasksWithCompletionHandler(
103            &self,
104            completion_handler: &block2::DynBlock<
105                dyn Fn(
106                    NonNull<NSArray<NSURLSessionDataTask>>,
107                    NonNull<NSArray<NSURLSessionUploadTask>>,
108                    NonNull<NSArray<NSURLSessionDownloadTask>>,
109                ),
110            >,
111        );
112
113        #[cfg(all(feature = "NSArray", feature = "block2"))]
114        #[unsafe(method(getAllTasksWithCompletionHandler:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn getAllTasksWithCompletionHandler(
117            &self,
118            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSURLSessionTask>>)>,
119        );
120
121        #[cfg(feature = "NSURLRequest")]
122        #[unsafe(method(dataTaskWithRequest:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn dataTaskWithRequest(
125            &self,
126            request: &NSURLRequest,
127        ) -> Retained<NSURLSessionDataTask>;
128
129        #[cfg(feature = "NSURL")]
130        #[unsafe(method(dataTaskWithURL:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn dataTaskWithURL(&self, url: &NSURL) -> Retained<NSURLSessionDataTask>;
133
134        #[cfg(all(feature = "NSURL", feature = "NSURLRequest"))]
135        #[unsafe(method(uploadTaskWithRequest:fromFile:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn uploadTaskWithRequest_fromFile(
138            &self,
139            request: &NSURLRequest,
140            file_url: &NSURL,
141        ) -> Retained<NSURLSessionUploadTask>;
142
143        #[cfg(all(feature = "NSData", feature = "NSURLRequest"))]
144        #[unsafe(method(uploadTaskWithRequest:fromData:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn uploadTaskWithRequest_fromData(
147            &self,
148            request: &NSURLRequest,
149            body_data: &NSData,
150        ) -> Retained<NSURLSessionUploadTask>;
151
152        #[cfg(feature = "NSData")]
153        /// Creates an upload task from a resume data blob. Requires the server to support the latest resumable uploads
154        /// Internet-Draft from the HTTP Working Group, found at
155        /// https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/
156        /// If resuming from an upload file, the file must still exist and be unmodified. If the upload cannot be successfully
157        /// resumed, URLSession:task:didCompleteWithError: will be called.
158        ///
159        /// - Parameter resumeData: Resume data blob from an incomplete upload, such as data returned by the cancelByProducingResumeData: method.
160        /// - Returns: A new session upload task, or nil if the resumeData is invalid.
161        #[unsafe(method(uploadTaskWithResumeData:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn uploadTaskWithResumeData(
164            &self,
165            resume_data: &NSData,
166        ) -> Retained<NSURLSessionUploadTask>;
167
168        #[cfg(feature = "NSURLRequest")]
169        #[unsafe(method(uploadTaskWithStreamedRequest:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn uploadTaskWithStreamedRequest(
172            &self,
173            request: &NSURLRequest,
174        ) -> Retained<NSURLSessionUploadTask>;
175
176        #[cfg(feature = "NSURLRequest")]
177        #[unsafe(method(downloadTaskWithRequest:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn downloadTaskWithRequest(
180            &self,
181            request: &NSURLRequest,
182        ) -> Retained<NSURLSessionDownloadTask>;
183
184        #[cfg(feature = "NSURL")]
185        #[unsafe(method(downloadTaskWithURL:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn downloadTaskWithURL(&self, url: &NSURL)
188            -> Retained<NSURLSessionDownloadTask>;
189
190        #[cfg(feature = "NSData")]
191        #[unsafe(method(downloadTaskWithResumeData:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn downloadTaskWithResumeData(
194            &self,
195            resume_data: &NSData,
196        ) -> Retained<NSURLSessionDownloadTask>;
197
198        #[cfg(feature = "NSString")]
199        #[unsafe(method(streamTaskWithHostName:port:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn streamTaskWithHostName_port(
202            &self,
203            hostname: &NSString,
204            port: NSInteger,
205        ) -> Retained<NSURLSessionStreamTask>;
206
207        #[cfg(feature = "NSNetServices")]
208        #[deprecated = "Use nw_connection_t in Network framework instead"]
209        #[unsafe(method(streamTaskWithNetService:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn streamTaskWithNetService(
212            &self,
213            service: &NSNetService,
214        ) -> Retained<NSURLSessionStreamTask>;
215
216        #[cfg(feature = "NSURL")]
217        #[unsafe(method(webSocketTaskWithURL:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn webSocketTaskWithURL(
220            &self,
221            url: &NSURL,
222        ) -> Retained<NSURLSessionWebSocketTask>;
223
224        #[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
225        #[unsafe(method(webSocketTaskWithURL:protocols:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn webSocketTaskWithURL_protocols(
228            &self,
229            url: &NSURL,
230            protocols: &NSArray<NSString>,
231        ) -> Retained<NSURLSessionWebSocketTask>;
232
233        #[cfg(feature = "NSURLRequest")]
234        #[unsafe(method(webSocketTaskWithRequest:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn webSocketTaskWithRequest(
237            &self,
238            request: &NSURLRequest,
239        ) -> Retained<NSURLSessionWebSocketTask>;
240
241        #[deprecated = "Please use +[NSURLSession sessionWithConfiguration:] or other class methods to create instances"]
242        #[unsafe(method(init))]
243        #[unsafe(method_family = init)]
244        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
245
246        #[deprecated = "Please use +[NSURLSession sessionWithConfiguration:] or other class methods to create instances"]
247        #[unsafe(method(new))]
248        #[unsafe(method_family = new)]
249        pub unsafe fn new() -> Retained<Self>;
250    );
251}
252
253/// NSURLSessionAsynchronousConvenience.
254impl NSURLSession {
255    extern_methods!(
256        #[cfg(all(
257            feature = "NSData",
258            feature = "NSError",
259            feature = "NSURLRequest",
260            feature = "NSURLResponse",
261            feature = "block2"
262        ))]
263        #[unsafe(method(dataTaskWithRequest:completionHandler:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn dataTaskWithRequest_completionHandler(
266            &self,
267            request: &NSURLRequest,
268            completion_handler: &block2::DynBlock<
269                dyn Fn(*mut NSData, *mut NSURLResponse, *mut NSError),
270            >,
271        ) -> Retained<NSURLSessionDataTask>;
272
273        #[cfg(all(
274            feature = "NSData",
275            feature = "NSError",
276            feature = "NSURL",
277            feature = "NSURLResponse",
278            feature = "block2"
279        ))]
280        #[unsafe(method(dataTaskWithURL:completionHandler:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn dataTaskWithURL_completionHandler(
283            &self,
284            url: &NSURL,
285            completion_handler: &block2::DynBlock<
286                dyn Fn(*mut NSData, *mut NSURLResponse, *mut NSError),
287            >,
288        ) -> Retained<NSURLSessionDataTask>;
289
290        #[cfg(all(
291            feature = "NSData",
292            feature = "NSError",
293            feature = "NSURL",
294            feature = "NSURLRequest",
295            feature = "NSURLResponse",
296            feature = "block2"
297        ))]
298        #[unsafe(method(uploadTaskWithRequest:fromFile:completionHandler:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn uploadTaskWithRequest_fromFile_completionHandler(
301            &self,
302            request: &NSURLRequest,
303            file_url: &NSURL,
304            completion_handler: &block2::DynBlock<
305                dyn Fn(*mut NSData, *mut NSURLResponse, *mut NSError),
306            >,
307        ) -> Retained<NSURLSessionUploadTask>;
308
309        #[cfg(all(
310            feature = "NSData",
311            feature = "NSError",
312            feature = "NSURLRequest",
313            feature = "NSURLResponse",
314            feature = "block2"
315        ))]
316        #[unsafe(method(uploadTaskWithRequest:fromData:completionHandler:))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn uploadTaskWithRequest_fromData_completionHandler(
319            &self,
320            request: &NSURLRequest,
321            body_data: Option<&NSData>,
322            completion_handler: &block2::DynBlock<
323                dyn Fn(*mut NSData, *mut NSURLResponse, *mut NSError),
324            >,
325        ) -> Retained<NSURLSessionUploadTask>;
326
327        #[cfg(all(
328            feature = "NSData",
329            feature = "NSError",
330            feature = "NSURLResponse",
331            feature = "block2"
332        ))]
333        /// Creates a URLSessionUploadTask from a resume data blob. If resuming from an upload
334        /// file, the file must still exist and be unmodified.
335        ///
336        /// - Parameter resumeData: Resume data blob from an incomplete upload, such as data returned by the cancelByProducingResumeData: method.
337        /// - Parameter completionHandler: The completion handler to call when the load request is complete.
338        /// - Returns: A new session upload task, or nil if the resumeData is invalid.
339        #[unsafe(method(uploadTaskWithResumeData:completionHandler:))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn uploadTaskWithResumeData_completionHandler(
342            &self,
343            resume_data: &NSData,
344            completion_handler: &block2::DynBlock<
345                dyn Fn(*mut NSData, *mut NSURLResponse, *mut NSError),
346            >,
347        ) -> Retained<NSURLSessionUploadTask>;
348
349        #[cfg(all(
350            feature = "NSError",
351            feature = "NSURL",
352            feature = "NSURLRequest",
353            feature = "NSURLResponse",
354            feature = "block2"
355        ))]
356        #[unsafe(method(downloadTaskWithRequest:completionHandler:))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn downloadTaskWithRequest_completionHandler(
359            &self,
360            request: &NSURLRequest,
361            completion_handler: &block2::DynBlock<
362                dyn Fn(*mut NSURL, *mut NSURLResponse, *mut NSError),
363            >,
364        ) -> Retained<NSURLSessionDownloadTask>;
365
366        #[cfg(all(
367            feature = "NSError",
368            feature = "NSURL",
369            feature = "NSURLResponse",
370            feature = "block2"
371        ))]
372        #[unsafe(method(downloadTaskWithURL:completionHandler:))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn downloadTaskWithURL_completionHandler(
375            &self,
376            url: &NSURL,
377            completion_handler: &block2::DynBlock<
378                dyn Fn(*mut NSURL, *mut NSURLResponse, *mut NSError),
379            >,
380        ) -> Retained<NSURLSessionDownloadTask>;
381
382        #[cfg(all(
383            feature = "NSData",
384            feature = "NSError",
385            feature = "NSURL",
386            feature = "NSURLResponse",
387            feature = "block2"
388        ))]
389        #[unsafe(method(downloadTaskWithResumeData:completionHandler:))]
390        #[unsafe(method_family = none)]
391        pub unsafe fn downloadTaskWithResumeData_completionHandler(
392            &self,
393            resume_data: &NSData,
394            completion_handler: &block2::DynBlock<
395                dyn Fn(*mut NSURL, *mut NSURLResponse, *mut NSError),
396            >,
397        ) -> Retained<NSURLSessionDownloadTask>;
398    );
399}
400
401/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskstate?language=objc)
402// NS_ENUM
403#[repr(transparent)]
404#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
405pub struct NSURLSessionTaskState(pub NSInteger);
406impl NSURLSessionTaskState {
407    #[doc(alias = "NSURLSessionTaskStateRunning")]
408    pub const Running: Self = Self(0);
409    #[doc(alias = "NSURLSessionTaskStateSuspended")]
410    pub const Suspended: Self = Self(1);
411    #[doc(alias = "NSURLSessionTaskStateCanceling")]
412    pub const Canceling: Self = Self(2);
413    #[doc(alias = "NSURLSessionTaskStateCompleted")]
414    pub const Completed: Self = Self(3);
415}
416
417unsafe impl Encode for NSURLSessionTaskState {
418    const ENCODING: Encoding = NSInteger::ENCODING;
419}
420
421unsafe impl RefEncode for NSURLSessionTaskState {
422    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
423}
424
425extern_class!(
426    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontask?language=objc)
427    #[unsafe(super(NSObject))]
428    #[derive(Debug, PartialEq, Eq, Hash)]
429    pub struct NSURLSessionTask;
430);
431
432unsafe impl Send for NSURLSessionTask {}
433
434unsafe impl Sync for NSURLSessionTask {}
435
436#[cfg(feature = "NSObject")]
437extern_conformance!(
438    unsafe impl NSCopying for NSURLSessionTask {}
439);
440
441#[cfg(feature = "NSObject")]
442unsafe impl CopyingHelper for NSURLSessionTask {
443    type Result = Self;
444}
445
446extern_conformance!(
447    unsafe impl NSObjectProtocol for NSURLSessionTask {}
448);
449
450#[cfg(feature = "NSProgress")]
451extern_conformance!(
452    unsafe impl NSProgressReporting for NSURLSessionTask {}
453);
454
455impl NSURLSessionTask {
456    extern_methods!(
457        #[unsafe(method(taskIdentifier))]
458        #[unsafe(method_family = none)]
459        pub unsafe fn taskIdentifier(&self) -> NSUInteger;
460
461        #[cfg(feature = "NSURLRequest")]
462        #[unsafe(method(originalRequest))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn originalRequest(&self) -> Option<Retained<NSURLRequest>>;
465
466        #[cfg(feature = "NSURLRequest")]
467        #[unsafe(method(currentRequest))]
468        #[unsafe(method_family = none)]
469        pub unsafe fn currentRequest(&self) -> Option<Retained<NSURLRequest>>;
470
471        #[cfg(feature = "NSURLResponse")]
472        #[unsafe(method(response))]
473        #[unsafe(method_family = none)]
474        pub unsafe fn response(&self) -> Option<Retained<NSURLResponse>>;
475
476        #[unsafe(method(delegate))]
477        #[unsafe(method_family = none)]
478        pub unsafe fn delegate(
479            &self,
480        ) -> Option<Retained<ProtocolObject<dyn NSURLSessionTaskDelegate>>>;
481
482        /// Setter for [`delegate`][Self::delegate].
483        #[unsafe(method(setDelegate:))]
484        #[unsafe(method_family = none)]
485        pub unsafe fn setDelegate(
486            &self,
487            delegate: Option<&ProtocolObject<dyn NSURLSessionTaskDelegate>>,
488        );
489
490        #[cfg(feature = "NSProgress")]
491        #[unsafe(method(progress))]
492        #[unsafe(method_family = none)]
493        pub unsafe fn progress(&self) -> Retained<NSProgress>;
494
495        #[cfg(feature = "NSDate")]
496        #[unsafe(method(earliestBeginDate))]
497        #[unsafe(method_family = none)]
498        pub unsafe fn earliestBeginDate(&self) -> Option<Retained<NSDate>>;
499
500        #[cfg(feature = "NSDate")]
501        /// Setter for [`earliestBeginDate`][Self::earliestBeginDate].
502        #[unsafe(method(setEarliestBeginDate:))]
503        #[unsafe(method_family = none)]
504        pub unsafe fn setEarliestBeginDate(&self, earliest_begin_date: Option<&NSDate>);
505
506        #[unsafe(method(countOfBytesClientExpectsToSend))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn countOfBytesClientExpectsToSend(&self) -> i64;
509
510        /// Setter for [`countOfBytesClientExpectsToSend`][Self::countOfBytesClientExpectsToSend].
511        #[unsafe(method(setCountOfBytesClientExpectsToSend:))]
512        #[unsafe(method_family = none)]
513        pub unsafe fn setCountOfBytesClientExpectsToSend(
514            &self,
515            count_of_bytes_client_expects_to_send: i64,
516        );
517
518        #[unsafe(method(countOfBytesClientExpectsToReceive))]
519        #[unsafe(method_family = none)]
520        pub unsafe fn countOfBytesClientExpectsToReceive(&self) -> i64;
521
522        /// Setter for [`countOfBytesClientExpectsToReceive`][Self::countOfBytesClientExpectsToReceive].
523        #[unsafe(method(setCountOfBytesClientExpectsToReceive:))]
524        #[unsafe(method_family = none)]
525        pub unsafe fn setCountOfBytesClientExpectsToReceive(
526            &self,
527            count_of_bytes_client_expects_to_receive: i64,
528        );
529
530        #[unsafe(method(countOfBytesSent))]
531        #[unsafe(method_family = none)]
532        pub unsafe fn countOfBytesSent(&self) -> i64;
533
534        #[unsafe(method(countOfBytesReceived))]
535        #[unsafe(method_family = none)]
536        pub unsafe fn countOfBytesReceived(&self) -> i64;
537
538        #[unsafe(method(countOfBytesExpectedToSend))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn countOfBytesExpectedToSend(&self) -> i64;
541
542        #[unsafe(method(countOfBytesExpectedToReceive))]
543        #[unsafe(method_family = none)]
544        pub unsafe fn countOfBytesExpectedToReceive(&self) -> i64;
545
546        #[cfg(feature = "NSString")]
547        #[unsafe(method(taskDescription))]
548        #[unsafe(method_family = none)]
549        pub unsafe fn taskDescription(&self) -> Option<Retained<NSString>>;
550
551        #[cfg(feature = "NSString")]
552        /// Setter for [`taskDescription`][Self::taskDescription].
553        #[unsafe(method(setTaskDescription:))]
554        #[unsafe(method_family = none)]
555        pub unsafe fn setTaskDescription(&self, task_description: Option<&NSString>);
556
557        #[unsafe(method(cancel))]
558        #[unsafe(method_family = none)]
559        pub unsafe fn cancel(&self);
560
561        #[unsafe(method(state))]
562        #[unsafe(method_family = none)]
563        pub unsafe fn state(&self) -> NSURLSessionTaskState;
564
565        #[cfg(feature = "NSError")]
566        #[unsafe(method(error))]
567        #[unsafe(method_family = none)]
568        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
569
570        #[unsafe(method(suspend))]
571        #[unsafe(method_family = none)]
572        pub unsafe fn suspend(&self);
573
574        #[unsafe(method(resume))]
575        #[unsafe(method_family = none)]
576        pub unsafe fn resume(&self);
577
578        #[unsafe(method(priority))]
579        #[unsafe(method_family = none)]
580        pub unsafe fn priority(&self) -> c_float;
581
582        /// Setter for [`priority`][Self::priority].
583        #[unsafe(method(setPriority:))]
584        #[unsafe(method_family = none)]
585        pub unsafe fn setPriority(&self, priority: c_float);
586
587        #[unsafe(method(prefersIncrementalDelivery))]
588        #[unsafe(method_family = none)]
589        pub unsafe fn prefersIncrementalDelivery(&self) -> bool;
590
591        /// Setter for [`prefersIncrementalDelivery`][Self::prefersIncrementalDelivery].
592        #[unsafe(method(setPrefersIncrementalDelivery:))]
593        #[unsafe(method_family = none)]
594        pub unsafe fn setPrefersIncrementalDelivery(&self, prefers_incremental_delivery: bool);
595
596        #[deprecated = "Not supported"]
597        #[unsafe(method(init))]
598        #[unsafe(method_family = init)]
599        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
600
601        #[deprecated = "Not supported"]
602        #[unsafe(method(new))]
603        #[unsafe(method_family = new)]
604        pub unsafe fn new() -> Retained<Self>;
605    );
606}
607
608extern "C" {
609    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskprioritydefault?language=objc)
610    pub static NSURLSessionTaskPriorityDefault: c_float;
611}
612
613extern "C" {
614    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskprioritylow?language=objc)
615    pub static NSURLSessionTaskPriorityLow: c_float;
616}
617
618extern "C" {
619    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskpriorityhigh?language=objc)
620    pub static NSURLSessionTaskPriorityHigh: c_float;
621}
622
623extern_class!(
624    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondatatask?language=objc)
625    #[unsafe(super(NSURLSessionTask, NSObject))]
626    #[derive(Debug, PartialEq, Eq, Hash)]
627    pub struct NSURLSessionDataTask;
628);
629
630unsafe impl Send for NSURLSessionDataTask {}
631
632unsafe impl Sync for NSURLSessionDataTask {}
633
634#[cfg(feature = "NSObject")]
635extern_conformance!(
636    unsafe impl NSCopying for NSURLSessionDataTask {}
637);
638
639#[cfg(feature = "NSObject")]
640unsafe impl CopyingHelper for NSURLSessionDataTask {
641    type Result = Self;
642}
643
644extern_conformance!(
645    unsafe impl NSObjectProtocol for NSURLSessionDataTask {}
646);
647
648#[cfg(feature = "NSProgress")]
649extern_conformance!(
650    unsafe impl NSProgressReporting for NSURLSessionDataTask {}
651);
652
653impl NSURLSessionDataTask {
654    extern_methods!(
655        #[deprecated = "Please use -[NSURLSession dataTaskWithRequest:] or other NSURLSession methods to create instances"]
656        #[unsafe(method(init))]
657        #[unsafe(method_family = init)]
658        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
659
660        #[deprecated = "Please use -[NSURLSession dataTaskWithRequest:] or other NSURLSession methods to create instances"]
661        #[unsafe(method(new))]
662        #[unsafe(method_family = new)]
663        pub unsafe fn new() -> Retained<Self>;
664    );
665}
666
667extern_class!(
668    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionuploadtask?language=objc)
669    #[unsafe(super(NSURLSessionDataTask, NSURLSessionTask, NSObject))]
670    #[derive(Debug, PartialEq, Eq, Hash)]
671    pub struct NSURLSessionUploadTask;
672);
673
674unsafe impl Send for NSURLSessionUploadTask {}
675
676unsafe impl Sync for NSURLSessionUploadTask {}
677
678#[cfg(feature = "NSObject")]
679extern_conformance!(
680    unsafe impl NSCopying for NSURLSessionUploadTask {}
681);
682
683#[cfg(feature = "NSObject")]
684unsafe impl CopyingHelper for NSURLSessionUploadTask {
685    type Result = Self;
686}
687
688extern_conformance!(
689    unsafe impl NSObjectProtocol for NSURLSessionUploadTask {}
690);
691
692#[cfg(feature = "NSProgress")]
693extern_conformance!(
694    unsafe impl NSProgressReporting for NSURLSessionUploadTask {}
695);
696
697impl NSURLSessionUploadTask {
698    extern_methods!(
699        #[deprecated = "Please use -[NSURLSession uploadTaskWithStreamedRequest:] or other NSURLSession methods to create instances"]
700        #[unsafe(method(init))]
701        #[unsafe(method_family = init)]
702        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
703
704        #[deprecated = "Please use -[NSURLSession uploadTaskWithStreamedRequest:] or other NSURLSession methods to create instances"]
705        #[unsafe(method(new))]
706        #[unsafe(method_family = new)]
707        pub unsafe fn new() -> Retained<Self>;
708
709        #[cfg(all(feature = "NSData", feature = "block2"))]
710        /// Cancels an upload and calls the completion handler with resume data for later use.
711        /// resumeData will be nil if the server does not support the latest resumable uploads
712        /// Internet-Draft from the HTTP Working Group, found at
713        /// https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/
714        ///
715        /// - Parameter completionHandler: The completion handler to call when the upload has been successfully canceled.
716        #[unsafe(method(cancelByProducingResumeData:))]
717        #[unsafe(method_family = none)]
718        pub unsafe fn cancelByProducingResumeData(
719            &self,
720            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData)>,
721        );
722    );
723}
724
725extern_class!(
726    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondownloadtask?language=objc)
727    #[unsafe(super(NSURLSessionTask, NSObject))]
728    #[derive(Debug, PartialEq, Eq, Hash)]
729    pub struct NSURLSessionDownloadTask;
730);
731
732unsafe impl Send for NSURLSessionDownloadTask {}
733
734unsafe impl Sync for NSURLSessionDownloadTask {}
735
736#[cfg(feature = "NSObject")]
737extern_conformance!(
738    unsafe impl NSCopying for NSURLSessionDownloadTask {}
739);
740
741#[cfg(feature = "NSObject")]
742unsafe impl CopyingHelper for NSURLSessionDownloadTask {
743    type Result = Self;
744}
745
746extern_conformance!(
747    unsafe impl NSObjectProtocol for NSURLSessionDownloadTask {}
748);
749
750#[cfg(feature = "NSProgress")]
751extern_conformance!(
752    unsafe impl NSProgressReporting for NSURLSessionDownloadTask {}
753);
754
755impl NSURLSessionDownloadTask {
756    extern_methods!(
757        #[cfg(all(feature = "NSData", feature = "block2"))]
758        #[unsafe(method(cancelByProducingResumeData:))]
759        #[unsafe(method_family = none)]
760        pub unsafe fn cancelByProducingResumeData(
761            &self,
762            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData)>,
763        );
764
765        #[deprecated = "Please use -[NSURLSession downloadTaskWithRequest:] or other NSURLSession methods to create instances"]
766        #[unsafe(method(init))]
767        #[unsafe(method_family = init)]
768        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
769
770        #[deprecated = "Please use -[NSURLSession downloadTaskWithRequest:] or other NSURLSession methods to create instances"]
771        #[unsafe(method(new))]
772        #[unsafe(method_family = new)]
773        pub unsafe fn new() -> Retained<Self>;
774    );
775}
776
777extern_class!(
778    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionstreamtask?language=objc)
779    #[unsafe(super(NSURLSessionTask, NSObject))]
780    #[derive(Debug, PartialEq, Eq, Hash)]
781    pub struct NSURLSessionStreamTask;
782);
783
784unsafe impl Send for NSURLSessionStreamTask {}
785
786unsafe impl Sync for NSURLSessionStreamTask {}
787
788#[cfg(feature = "NSObject")]
789extern_conformance!(
790    unsafe impl NSCopying for NSURLSessionStreamTask {}
791);
792
793#[cfg(feature = "NSObject")]
794unsafe impl CopyingHelper for NSURLSessionStreamTask {
795    type Result = Self;
796}
797
798extern_conformance!(
799    unsafe impl NSObjectProtocol for NSURLSessionStreamTask {}
800);
801
802#[cfg(feature = "NSProgress")]
803extern_conformance!(
804    unsafe impl NSProgressReporting for NSURLSessionStreamTask {}
805);
806
807impl NSURLSessionStreamTask {
808    extern_methods!(
809        #[cfg(all(
810            feature = "NSData",
811            feature = "NSDate",
812            feature = "NSError",
813            feature = "block2"
814        ))]
815        #[unsafe(method(readDataOfMinLength:maxLength:timeout:completionHandler:))]
816        #[unsafe(method_family = none)]
817        pub unsafe fn readDataOfMinLength_maxLength_timeout_completionHandler(
818            &self,
819            min_bytes: NSUInteger,
820            max_bytes: NSUInteger,
821            timeout: NSTimeInterval,
822            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, Bool, *mut NSError)>,
823        );
824
825        #[cfg(all(
826            feature = "NSData",
827            feature = "NSDate",
828            feature = "NSError",
829            feature = "block2"
830        ))]
831        #[unsafe(method(writeData:timeout:completionHandler:))]
832        #[unsafe(method_family = none)]
833        pub unsafe fn writeData_timeout_completionHandler(
834            &self,
835            data: &NSData,
836            timeout: NSTimeInterval,
837            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
838        );
839
840        #[unsafe(method(captureStreams))]
841        #[unsafe(method_family = none)]
842        pub unsafe fn captureStreams(&self);
843
844        #[unsafe(method(closeWrite))]
845        #[unsafe(method_family = none)]
846        pub unsafe fn closeWrite(&self);
847
848        #[unsafe(method(closeRead))]
849        #[unsafe(method_family = none)]
850        pub unsafe fn closeRead(&self);
851
852        #[unsafe(method(startSecureConnection))]
853        #[unsafe(method_family = none)]
854        pub unsafe fn startSecureConnection(&self);
855
856        #[deprecated = "TLS cannot be disabled once it is enabled"]
857        #[unsafe(method(stopSecureConnection))]
858        #[unsafe(method_family = none)]
859        pub unsafe fn stopSecureConnection(&self);
860
861        #[deprecated = "Please use -[NSURLSession streamTaskWithHostName:port:] or other NSURLSession methods to create instances"]
862        #[unsafe(method(init))]
863        #[unsafe(method_family = init)]
864        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
865
866        #[deprecated = "Please use -[NSURLSession streamTaskWithHostName:port:] or other NSURLSession methods to create instances"]
867        #[unsafe(method(new))]
868        #[unsafe(method_family = new)]
869        pub unsafe fn new() -> Retained<Self>;
870    );
871}
872
873/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionwebsocketmessagetype?language=objc)
874// NS_ENUM
875#[repr(transparent)]
876#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
877pub struct NSURLSessionWebSocketMessageType(pub NSInteger);
878impl NSURLSessionWebSocketMessageType {
879    #[doc(alias = "NSURLSessionWebSocketMessageTypeData")]
880    pub const Data: Self = Self(0);
881    #[doc(alias = "NSURLSessionWebSocketMessageTypeString")]
882    pub const String: Self = Self(1);
883}
884
885unsafe impl Encode for NSURLSessionWebSocketMessageType {
886    const ENCODING: Encoding = NSInteger::ENCODING;
887}
888
889unsafe impl RefEncode for NSURLSessionWebSocketMessageType {
890    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
891}
892
893extern_class!(
894    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionwebsocketmessage?language=objc)
895    #[unsafe(super(NSObject))]
896    #[derive(Debug, PartialEq, Eq, Hash)]
897    pub struct NSURLSessionWebSocketMessage;
898);
899
900unsafe impl Send for NSURLSessionWebSocketMessage {}
901
902unsafe impl Sync for NSURLSessionWebSocketMessage {}
903
904extern_conformance!(
905    unsafe impl NSObjectProtocol for NSURLSessionWebSocketMessage {}
906);
907
908impl NSURLSessionWebSocketMessage {
909    extern_methods!(
910        #[cfg(feature = "NSData")]
911        #[unsafe(method(initWithData:))]
912        #[unsafe(method_family = init)]
913        pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Retained<Self>;
914
915        #[cfg(feature = "NSString")]
916        #[unsafe(method(initWithString:))]
917        #[unsafe(method_family = init)]
918        pub unsafe fn initWithString(this: Allocated<Self>, string: &NSString) -> Retained<Self>;
919
920        #[unsafe(method(type))]
921        #[unsafe(method_family = none)]
922        pub unsafe fn r#type(&self) -> NSURLSessionWebSocketMessageType;
923
924        #[cfg(feature = "NSData")]
925        #[unsafe(method(data))]
926        #[unsafe(method_family = none)]
927        pub unsafe fn data(&self) -> Option<Retained<NSData>>;
928
929        #[cfg(feature = "NSString")]
930        #[unsafe(method(string))]
931        #[unsafe(method_family = none)]
932        pub unsafe fn string(&self) -> Option<Retained<NSString>>;
933
934        #[unsafe(method(init))]
935        #[unsafe(method_family = init)]
936        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
937
938        #[unsafe(method(new))]
939        #[unsafe(method_family = new)]
940        pub unsafe fn new() -> Retained<Self>;
941    );
942}
943
944/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionwebsocketclosecode?language=objc)
945// NS_ENUM
946#[repr(transparent)]
947#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
948pub struct NSURLSessionWebSocketCloseCode(pub NSInteger);
949impl NSURLSessionWebSocketCloseCode {
950    #[doc(alias = "NSURLSessionWebSocketCloseCodeInvalid")]
951    pub const Invalid: Self = Self(0);
952    #[doc(alias = "NSURLSessionWebSocketCloseCodeNormalClosure")]
953    pub const NormalClosure: Self = Self(1000);
954    #[doc(alias = "NSURLSessionWebSocketCloseCodeGoingAway")]
955    pub const GoingAway: Self = Self(1001);
956    #[doc(alias = "NSURLSessionWebSocketCloseCodeProtocolError")]
957    pub const ProtocolError: Self = Self(1002);
958    #[doc(alias = "NSURLSessionWebSocketCloseCodeUnsupportedData")]
959    pub const UnsupportedData: Self = Self(1003);
960    #[doc(alias = "NSURLSessionWebSocketCloseCodeNoStatusReceived")]
961    pub const NoStatusReceived: Self = Self(1005);
962    #[doc(alias = "NSURLSessionWebSocketCloseCodeAbnormalClosure")]
963    pub const AbnormalClosure: Self = Self(1006);
964    #[doc(alias = "NSURLSessionWebSocketCloseCodeInvalidFramePayloadData")]
965    pub const InvalidFramePayloadData: Self = Self(1007);
966    #[doc(alias = "NSURLSessionWebSocketCloseCodePolicyViolation")]
967    pub const PolicyViolation: Self = Self(1008);
968    #[doc(alias = "NSURLSessionWebSocketCloseCodeMessageTooBig")]
969    pub const MessageTooBig: Self = Self(1009);
970    #[doc(alias = "NSURLSessionWebSocketCloseCodeMandatoryExtensionMissing")]
971    pub const MandatoryExtensionMissing: Self = Self(1010);
972    #[doc(alias = "NSURLSessionWebSocketCloseCodeInternalServerError")]
973    pub const InternalServerError: Self = Self(1011);
974    #[doc(alias = "NSURLSessionWebSocketCloseCodeTLSHandshakeFailure")]
975    pub const TLSHandshakeFailure: Self = Self(1015);
976}
977
978unsafe impl Encode for NSURLSessionWebSocketCloseCode {
979    const ENCODING: Encoding = NSInteger::ENCODING;
980}
981
982unsafe impl RefEncode for NSURLSessionWebSocketCloseCode {
983    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
984}
985
986extern_class!(
987    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionwebsockettask?language=objc)
988    #[unsafe(super(NSURLSessionTask, NSObject))]
989    #[derive(Debug, PartialEq, Eq, Hash)]
990    pub struct NSURLSessionWebSocketTask;
991);
992
993unsafe impl Send for NSURLSessionWebSocketTask {}
994
995unsafe impl Sync for NSURLSessionWebSocketTask {}
996
997#[cfg(feature = "NSObject")]
998extern_conformance!(
999    unsafe impl NSCopying for NSURLSessionWebSocketTask {}
1000);
1001
1002#[cfg(feature = "NSObject")]
1003unsafe impl CopyingHelper for NSURLSessionWebSocketTask {
1004    type Result = Self;
1005}
1006
1007extern_conformance!(
1008    unsafe impl NSObjectProtocol for NSURLSessionWebSocketTask {}
1009);
1010
1011#[cfg(feature = "NSProgress")]
1012extern_conformance!(
1013    unsafe impl NSProgressReporting for NSURLSessionWebSocketTask {}
1014);
1015
1016impl NSURLSessionWebSocketTask {
1017    extern_methods!(
1018        #[cfg(all(feature = "NSError", feature = "block2"))]
1019        #[unsafe(method(sendMessage:completionHandler:))]
1020        #[unsafe(method_family = none)]
1021        pub unsafe fn sendMessage_completionHandler(
1022            &self,
1023            message: &NSURLSessionWebSocketMessage,
1024            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1025        );
1026
1027        #[cfg(all(feature = "NSError", feature = "block2"))]
1028        #[unsafe(method(receiveMessageWithCompletionHandler:))]
1029        #[unsafe(method_family = none)]
1030        pub unsafe fn receiveMessageWithCompletionHandler(
1031            &self,
1032            completion_handler: &block2::DynBlock<
1033                dyn Fn(*mut NSURLSessionWebSocketMessage, *mut NSError),
1034            >,
1035        );
1036
1037        #[cfg(all(feature = "NSError", feature = "block2"))]
1038        #[unsafe(method(sendPingWithPongReceiveHandler:))]
1039        #[unsafe(method_family = none)]
1040        pub unsafe fn sendPingWithPongReceiveHandler(
1041            &self,
1042            pong_receive_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1043        );
1044
1045        #[cfg(feature = "NSData")]
1046        #[unsafe(method(cancelWithCloseCode:reason:))]
1047        #[unsafe(method_family = none)]
1048        pub unsafe fn cancelWithCloseCode_reason(
1049            &self,
1050            close_code: NSURLSessionWebSocketCloseCode,
1051            reason: Option<&NSData>,
1052        );
1053
1054        #[unsafe(method(maximumMessageSize))]
1055        #[unsafe(method_family = none)]
1056        pub unsafe fn maximumMessageSize(&self) -> NSInteger;
1057
1058        /// Setter for [`maximumMessageSize`][Self::maximumMessageSize].
1059        #[unsafe(method(setMaximumMessageSize:))]
1060        #[unsafe(method_family = none)]
1061        pub unsafe fn setMaximumMessageSize(&self, maximum_message_size: NSInteger);
1062
1063        #[unsafe(method(closeCode))]
1064        #[unsafe(method_family = none)]
1065        pub unsafe fn closeCode(&self) -> NSURLSessionWebSocketCloseCode;
1066
1067        #[cfg(feature = "NSData")]
1068        #[unsafe(method(closeReason))]
1069        #[unsafe(method_family = none)]
1070        pub unsafe fn closeReason(&self) -> Option<Retained<NSData>>;
1071
1072        #[unsafe(method(init))]
1073        #[unsafe(method_family = init)]
1074        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1075
1076        #[unsafe(method(new))]
1077        #[unsafe(method_family = new)]
1078        pub unsafe fn new() -> Retained<Self>;
1079    );
1080}
1081
1082/// The NSURLSessionMultipathServiceType enum defines constants that
1083/// can be used to specify the multipath service type to associate an NSURLSession.  The
1084/// multipath service type determines whether multipath TCP should be attempted and the conditions
1085/// for creating and switching between subflows.  Using these service types requires the appropriate entitlement.  Any connection attempt will fail if the process does not have the required entitlement.
1086/// A primary interface is a generally less expensive interface in terms of both cost and power (such as WiFi or ethernet).  A secondary interface is more expensive (such as 3G or LTE).
1087///
1088///
1089/// This is the default value.  No entitlement is required to set this value.
1090///
1091///
1092/// when the primary subflow is not performing adequately.   Requires the com.apple.developer.networking.multipath entitlement.
1093///
1094///
1095/// primary subflow is not performing adequately (packet loss, high round trip times, bandwidth issues).  The secondary
1096/// subflow will be created more aggressively than with NSURLSessionMultipathServiceTypeHandover.  Requires the com.apple.developer.networking.multipath entitlement.
1097///
1098///
1099/// used for better bandwidth.  This mode is only available for experimentation on devices configured for development use.
1100/// It can be enabled in the Developer section of the Settings app.
1101///
1102/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionmultipathservicetype?language=objc)
1103// NS_ENUM
1104#[repr(transparent)]
1105#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1106pub struct NSURLSessionMultipathServiceType(pub NSInteger);
1107impl NSURLSessionMultipathServiceType {
1108    #[doc(alias = "NSURLSessionMultipathServiceTypeNone")]
1109    pub const None: Self = Self(0);
1110    #[doc(alias = "NSURLSessionMultipathServiceTypeHandover")]
1111    pub const Handover: Self = Self(1);
1112    #[doc(alias = "NSURLSessionMultipathServiceTypeInteractive")]
1113    pub const Interactive: Self = Self(2);
1114    #[doc(alias = "NSURLSessionMultipathServiceTypeAggregate")]
1115    pub const Aggregate: Self = Self(3);
1116}
1117
1118unsafe impl Encode for NSURLSessionMultipathServiceType {
1119    const ENCODING: Encoding = NSInteger::ENCODING;
1120}
1121
1122unsafe impl RefEncode for NSURLSessionMultipathServiceType {
1123    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1124}
1125
1126extern_class!(
1127    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration?language=objc)
1128    #[unsafe(super(NSObject))]
1129    #[derive(Debug, PartialEq, Eq, Hash)]
1130    pub struct NSURLSessionConfiguration;
1131);
1132
1133unsafe impl Send for NSURLSessionConfiguration {}
1134
1135unsafe impl Sync for NSURLSessionConfiguration {}
1136
1137#[cfg(feature = "NSObject")]
1138extern_conformance!(
1139    unsafe impl NSCopying for NSURLSessionConfiguration {}
1140);
1141
1142#[cfg(feature = "NSObject")]
1143unsafe impl CopyingHelper for NSURLSessionConfiguration {
1144    type Result = Self;
1145}
1146
1147extern_conformance!(
1148    unsafe impl NSObjectProtocol for NSURLSessionConfiguration {}
1149);
1150
1151impl NSURLSessionConfiguration {
1152    extern_methods!(
1153        #[unsafe(method(defaultSessionConfiguration))]
1154        #[unsafe(method_family = none)]
1155        pub unsafe fn defaultSessionConfiguration() -> Retained<NSURLSessionConfiguration>;
1156
1157        #[unsafe(method(ephemeralSessionConfiguration))]
1158        #[unsafe(method_family = none)]
1159        pub unsafe fn ephemeralSessionConfiguration() -> Retained<NSURLSessionConfiguration>;
1160
1161        #[cfg(feature = "NSString")]
1162        #[unsafe(method(backgroundSessionConfigurationWithIdentifier:))]
1163        #[unsafe(method_family = none)]
1164        pub unsafe fn backgroundSessionConfigurationWithIdentifier(
1165            identifier: &NSString,
1166        ) -> Retained<NSURLSessionConfiguration>;
1167
1168        #[cfg(feature = "NSString")]
1169        #[unsafe(method(identifier))]
1170        #[unsafe(method_family = none)]
1171        pub unsafe fn identifier(&self) -> Option<Retained<NSString>>;
1172
1173        #[cfg(feature = "NSURLRequest")]
1174        #[unsafe(method(requestCachePolicy))]
1175        #[unsafe(method_family = none)]
1176        pub unsafe fn requestCachePolicy(&self) -> NSURLRequestCachePolicy;
1177
1178        #[cfg(feature = "NSURLRequest")]
1179        /// Setter for [`requestCachePolicy`][Self::requestCachePolicy].
1180        #[unsafe(method(setRequestCachePolicy:))]
1181        #[unsafe(method_family = none)]
1182        pub unsafe fn setRequestCachePolicy(&self, request_cache_policy: NSURLRequestCachePolicy);
1183
1184        #[cfg(feature = "NSDate")]
1185        #[unsafe(method(timeoutIntervalForRequest))]
1186        #[unsafe(method_family = none)]
1187        pub unsafe fn timeoutIntervalForRequest(&self) -> NSTimeInterval;
1188
1189        #[cfg(feature = "NSDate")]
1190        /// Setter for [`timeoutIntervalForRequest`][Self::timeoutIntervalForRequest].
1191        #[unsafe(method(setTimeoutIntervalForRequest:))]
1192        #[unsafe(method_family = none)]
1193        pub unsafe fn setTimeoutIntervalForRequest(
1194            &self,
1195            timeout_interval_for_request: NSTimeInterval,
1196        );
1197
1198        #[cfg(feature = "NSDate")]
1199        #[unsafe(method(timeoutIntervalForResource))]
1200        #[unsafe(method_family = none)]
1201        pub unsafe fn timeoutIntervalForResource(&self) -> NSTimeInterval;
1202
1203        #[cfg(feature = "NSDate")]
1204        /// Setter for [`timeoutIntervalForResource`][Self::timeoutIntervalForResource].
1205        #[unsafe(method(setTimeoutIntervalForResource:))]
1206        #[unsafe(method_family = none)]
1207        pub unsafe fn setTimeoutIntervalForResource(
1208            &self,
1209            timeout_interval_for_resource: NSTimeInterval,
1210        );
1211
1212        #[cfg(feature = "NSURLRequest")]
1213        #[unsafe(method(networkServiceType))]
1214        #[unsafe(method_family = none)]
1215        pub unsafe fn networkServiceType(&self) -> NSURLRequestNetworkServiceType;
1216
1217        #[cfg(feature = "NSURLRequest")]
1218        /// Setter for [`networkServiceType`][Self::networkServiceType].
1219        #[unsafe(method(setNetworkServiceType:))]
1220        #[unsafe(method_family = none)]
1221        pub unsafe fn setNetworkServiceType(
1222            &self,
1223            network_service_type: NSURLRequestNetworkServiceType,
1224        );
1225
1226        #[unsafe(method(allowsCellularAccess))]
1227        #[unsafe(method_family = none)]
1228        pub unsafe fn allowsCellularAccess(&self) -> bool;
1229
1230        /// Setter for [`allowsCellularAccess`][Self::allowsCellularAccess].
1231        #[unsafe(method(setAllowsCellularAccess:))]
1232        #[unsafe(method_family = none)]
1233        pub unsafe fn setAllowsCellularAccess(&self, allows_cellular_access: bool);
1234
1235        #[unsafe(method(allowsExpensiveNetworkAccess))]
1236        #[unsafe(method_family = none)]
1237        pub unsafe fn allowsExpensiveNetworkAccess(&self) -> bool;
1238
1239        /// Setter for [`allowsExpensiveNetworkAccess`][Self::allowsExpensiveNetworkAccess].
1240        #[unsafe(method(setAllowsExpensiveNetworkAccess:))]
1241        #[unsafe(method_family = none)]
1242        pub unsafe fn setAllowsExpensiveNetworkAccess(&self, allows_expensive_network_access: bool);
1243
1244        #[unsafe(method(allowsConstrainedNetworkAccess))]
1245        #[unsafe(method_family = none)]
1246        pub unsafe fn allowsConstrainedNetworkAccess(&self) -> bool;
1247
1248        /// Setter for [`allowsConstrainedNetworkAccess`][Self::allowsConstrainedNetworkAccess].
1249        #[unsafe(method(setAllowsConstrainedNetworkAccess:))]
1250        #[unsafe(method_family = none)]
1251        pub unsafe fn setAllowsConstrainedNetworkAccess(
1252            &self,
1253            allows_constrained_network_access: bool,
1254        );
1255
1256        #[unsafe(method(requiresDNSSECValidation))]
1257        #[unsafe(method_family = none)]
1258        pub unsafe fn requiresDNSSECValidation(&self) -> bool;
1259
1260        /// Setter for [`requiresDNSSECValidation`][Self::requiresDNSSECValidation].
1261        #[unsafe(method(setRequiresDNSSECValidation:))]
1262        #[unsafe(method_family = none)]
1263        pub unsafe fn setRequiresDNSSECValidation(&self, requires_dnssec_validation: bool);
1264
1265        #[unsafe(method(waitsForConnectivity))]
1266        #[unsafe(method_family = none)]
1267        pub unsafe fn waitsForConnectivity(&self) -> bool;
1268
1269        /// Setter for [`waitsForConnectivity`][Self::waitsForConnectivity].
1270        #[unsafe(method(setWaitsForConnectivity:))]
1271        #[unsafe(method_family = none)]
1272        pub unsafe fn setWaitsForConnectivity(&self, waits_for_connectivity: bool);
1273
1274        #[unsafe(method(isDiscretionary))]
1275        #[unsafe(method_family = none)]
1276        pub unsafe fn isDiscretionary(&self) -> bool;
1277
1278        /// Setter for [`isDiscretionary`][Self::isDiscretionary].
1279        #[unsafe(method(setDiscretionary:))]
1280        #[unsafe(method_family = none)]
1281        pub unsafe fn setDiscretionary(&self, discretionary: bool);
1282
1283        #[cfg(feature = "NSString")]
1284        #[unsafe(method(sharedContainerIdentifier))]
1285        #[unsafe(method_family = none)]
1286        pub unsafe fn sharedContainerIdentifier(&self) -> Option<Retained<NSString>>;
1287
1288        #[cfg(feature = "NSString")]
1289        /// Setter for [`sharedContainerIdentifier`][Self::sharedContainerIdentifier].
1290        #[unsafe(method(setSharedContainerIdentifier:))]
1291        #[unsafe(method_family = none)]
1292        pub unsafe fn setSharedContainerIdentifier(
1293            &self,
1294            shared_container_identifier: Option<&NSString>,
1295        );
1296
1297        #[unsafe(method(sessionSendsLaunchEvents))]
1298        #[unsafe(method_family = none)]
1299        pub unsafe fn sessionSendsLaunchEvents(&self) -> bool;
1300
1301        /// Setter for [`sessionSendsLaunchEvents`][Self::sessionSendsLaunchEvents].
1302        #[unsafe(method(setSessionSendsLaunchEvents:))]
1303        #[unsafe(method_family = none)]
1304        pub unsafe fn setSessionSendsLaunchEvents(&self, session_sends_launch_events: bool);
1305
1306        #[cfg(feature = "NSDictionary")]
1307        #[unsafe(method(connectionProxyDictionary))]
1308        #[unsafe(method_family = none)]
1309        pub unsafe fn connectionProxyDictionary(&self) -> Option<Retained<NSDictionary>>;
1310
1311        #[cfg(feature = "NSDictionary")]
1312        /// Setter for [`connectionProxyDictionary`][Self::connectionProxyDictionary].
1313        #[unsafe(method(setConnectionProxyDictionary:))]
1314        #[unsafe(method_family = none)]
1315        pub unsafe fn setConnectionProxyDictionary(
1316            &self,
1317            connection_proxy_dictionary: Option<&NSDictionary>,
1318        );
1319
1320        #[deprecated = "Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead"]
1321        #[unsafe(method(HTTPShouldUsePipelining))]
1322        #[unsafe(method_family = none)]
1323        pub unsafe fn HTTPShouldUsePipelining(&self) -> bool;
1324
1325        /// Setter for [`HTTPShouldUsePipelining`][Self::HTTPShouldUsePipelining].
1326        #[deprecated = "Only supported in the classic loader, please adopt HTTP/2 and HTTP/3 instead"]
1327        #[unsafe(method(setHTTPShouldUsePipelining:))]
1328        #[unsafe(method_family = none)]
1329        pub unsafe fn setHTTPShouldUsePipelining(&self, http_should_use_pipelining: bool);
1330
1331        #[unsafe(method(HTTPShouldSetCookies))]
1332        #[unsafe(method_family = none)]
1333        pub unsafe fn HTTPShouldSetCookies(&self) -> bool;
1334
1335        /// Setter for [`HTTPShouldSetCookies`][Self::HTTPShouldSetCookies].
1336        #[unsafe(method(setHTTPShouldSetCookies:))]
1337        #[unsafe(method_family = none)]
1338        pub unsafe fn setHTTPShouldSetCookies(&self, http_should_set_cookies: bool);
1339
1340        #[cfg(feature = "NSHTTPCookieStorage")]
1341        #[unsafe(method(HTTPCookieAcceptPolicy))]
1342        #[unsafe(method_family = none)]
1343        pub unsafe fn HTTPCookieAcceptPolicy(&self) -> NSHTTPCookieAcceptPolicy;
1344
1345        #[cfg(feature = "NSHTTPCookieStorage")]
1346        /// Setter for [`HTTPCookieAcceptPolicy`][Self::HTTPCookieAcceptPolicy].
1347        #[unsafe(method(setHTTPCookieAcceptPolicy:))]
1348        #[unsafe(method_family = none)]
1349        pub unsafe fn setHTTPCookieAcceptPolicy(
1350            &self,
1351            http_cookie_accept_policy: NSHTTPCookieAcceptPolicy,
1352        );
1353
1354        #[cfg(feature = "NSDictionary")]
1355        #[unsafe(method(HTTPAdditionalHeaders))]
1356        #[unsafe(method_family = none)]
1357        pub unsafe fn HTTPAdditionalHeaders(&self) -> Option<Retained<NSDictionary>>;
1358
1359        #[cfg(feature = "NSDictionary")]
1360        /// Setter for [`HTTPAdditionalHeaders`][Self::HTTPAdditionalHeaders].
1361        #[unsafe(method(setHTTPAdditionalHeaders:))]
1362        #[unsafe(method_family = none)]
1363        pub unsafe fn setHTTPAdditionalHeaders(
1364            &self,
1365            http_additional_headers: Option<&NSDictionary>,
1366        );
1367
1368        #[unsafe(method(HTTPMaximumConnectionsPerHost))]
1369        #[unsafe(method_family = none)]
1370        pub unsafe fn HTTPMaximumConnectionsPerHost(&self) -> NSInteger;
1371
1372        /// Setter for [`HTTPMaximumConnectionsPerHost`][Self::HTTPMaximumConnectionsPerHost].
1373        #[unsafe(method(setHTTPMaximumConnectionsPerHost:))]
1374        #[unsafe(method_family = none)]
1375        pub unsafe fn setHTTPMaximumConnectionsPerHost(
1376            &self,
1377            http_maximum_connections_per_host: NSInteger,
1378        );
1379
1380        #[cfg(feature = "NSHTTPCookieStorage")]
1381        #[unsafe(method(HTTPCookieStorage))]
1382        #[unsafe(method_family = none)]
1383        pub unsafe fn HTTPCookieStorage(&self) -> Option<Retained<NSHTTPCookieStorage>>;
1384
1385        #[cfg(feature = "NSHTTPCookieStorage")]
1386        /// Setter for [`HTTPCookieStorage`][Self::HTTPCookieStorage].
1387        #[unsafe(method(setHTTPCookieStorage:))]
1388        #[unsafe(method_family = none)]
1389        pub unsafe fn setHTTPCookieStorage(
1390            &self,
1391            http_cookie_storage: Option<&NSHTTPCookieStorage>,
1392        );
1393
1394        #[cfg(feature = "NSURLCredentialStorage")]
1395        #[unsafe(method(URLCredentialStorage))]
1396        #[unsafe(method_family = none)]
1397        pub unsafe fn URLCredentialStorage(&self) -> Option<Retained<NSURLCredentialStorage>>;
1398
1399        #[cfg(feature = "NSURLCredentialStorage")]
1400        /// Setter for [`URLCredentialStorage`][Self::URLCredentialStorage].
1401        #[unsafe(method(setURLCredentialStorage:))]
1402        #[unsafe(method_family = none)]
1403        pub unsafe fn setURLCredentialStorage(
1404            &self,
1405            url_credential_storage: Option<&NSURLCredentialStorage>,
1406        );
1407
1408        #[cfg(feature = "NSURLCache")]
1409        #[unsafe(method(URLCache))]
1410        #[unsafe(method_family = none)]
1411        pub unsafe fn URLCache(&self) -> Option<Retained<NSURLCache>>;
1412
1413        #[cfg(feature = "NSURLCache")]
1414        /// Setter for [`URLCache`][Self::URLCache].
1415        #[unsafe(method(setURLCache:))]
1416        #[unsafe(method_family = none)]
1417        pub unsafe fn setURLCache(&self, url_cache: Option<&NSURLCache>);
1418
1419        #[deprecated = "Not supported"]
1420        #[unsafe(method(shouldUseExtendedBackgroundIdleMode))]
1421        #[unsafe(method_family = none)]
1422        pub unsafe fn shouldUseExtendedBackgroundIdleMode(&self) -> bool;
1423
1424        /// Setter for [`shouldUseExtendedBackgroundIdleMode`][Self::shouldUseExtendedBackgroundIdleMode].
1425        #[deprecated = "Not supported"]
1426        #[unsafe(method(setShouldUseExtendedBackgroundIdleMode:))]
1427        #[unsafe(method_family = none)]
1428        pub unsafe fn setShouldUseExtendedBackgroundIdleMode(
1429            &self,
1430            should_use_extended_background_idle_mode: bool,
1431        );
1432
1433        #[cfg(feature = "NSArray")]
1434        #[unsafe(method(protocolClasses))]
1435        #[unsafe(method_family = none)]
1436        pub unsafe fn protocolClasses(&self) -> Option<Retained<NSArray<AnyClass>>>;
1437
1438        #[cfg(feature = "NSArray")]
1439        /// Setter for [`protocolClasses`][Self::protocolClasses].
1440        #[unsafe(method(setProtocolClasses:))]
1441        #[unsafe(method_family = none)]
1442        pub unsafe fn setProtocolClasses(&self, protocol_classes: Option<&NSArray<AnyClass>>);
1443
1444        #[unsafe(method(multipathServiceType))]
1445        #[unsafe(method_family = none)]
1446        pub unsafe fn multipathServiceType(&self) -> NSURLSessionMultipathServiceType;
1447
1448        /// Setter for [`multipathServiceType`][Self::multipathServiceType].
1449        #[unsafe(method(setMultipathServiceType:))]
1450        #[unsafe(method_family = none)]
1451        pub unsafe fn setMultipathServiceType(
1452            &self,
1453            multipath_service_type: NSURLSessionMultipathServiceType,
1454        );
1455
1456        #[unsafe(method(usesClassicLoadingMode))]
1457        #[unsafe(method_family = none)]
1458        pub unsafe fn usesClassicLoadingMode(&self) -> bool;
1459
1460        /// Setter for [`usesClassicLoadingMode`][Self::usesClassicLoadingMode].
1461        #[unsafe(method(setUsesClassicLoadingMode:))]
1462        #[unsafe(method_family = none)]
1463        pub unsafe fn setUsesClassicLoadingMode(&self, uses_classic_loading_mode: bool);
1464
1465        #[deprecated = "Please use NSURLSessionConfiguration.defaultSessionConfiguration or other class methods to create instances"]
1466        #[unsafe(method(init))]
1467        #[unsafe(method_family = init)]
1468        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1469
1470        #[deprecated = "Please use NSURLSessionConfiguration.defaultSessionConfiguration or other class methods to create instances"]
1471        #[unsafe(method(new))]
1472        #[unsafe(method_family = new)]
1473        pub unsafe fn new() -> Retained<Self>;
1474    );
1475}
1476
1477/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondelayedrequestdisposition?language=objc)
1478// NS_ENUM
1479#[repr(transparent)]
1480#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1481pub struct NSURLSessionDelayedRequestDisposition(pub NSInteger);
1482impl NSURLSessionDelayedRequestDisposition {
1483    #[doc(alias = "NSURLSessionDelayedRequestContinueLoading")]
1484    pub const ContinueLoading: Self = Self(0);
1485    #[doc(alias = "NSURLSessionDelayedRequestUseNewRequest")]
1486    pub const UseNewRequest: Self = Self(1);
1487    #[doc(alias = "NSURLSessionDelayedRequestCancel")]
1488    pub const Cancel: Self = Self(2);
1489}
1490
1491unsafe impl Encode for NSURLSessionDelayedRequestDisposition {
1492    const ENCODING: Encoding = NSInteger::ENCODING;
1493}
1494
1495unsafe impl RefEncode for NSURLSessionDelayedRequestDisposition {
1496    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1497}
1498
1499/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionauthchallengedisposition?language=objc)
1500// NS_ENUM
1501#[repr(transparent)]
1502#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1503pub struct NSURLSessionAuthChallengeDisposition(pub NSInteger);
1504impl NSURLSessionAuthChallengeDisposition {
1505    #[doc(alias = "NSURLSessionAuthChallengeUseCredential")]
1506    pub const UseCredential: Self = Self(0);
1507    #[doc(alias = "NSURLSessionAuthChallengePerformDefaultHandling")]
1508    pub const PerformDefaultHandling: Self = Self(1);
1509    #[doc(alias = "NSURLSessionAuthChallengeCancelAuthenticationChallenge")]
1510    pub const CancelAuthenticationChallenge: Self = Self(2);
1511    #[doc(alias = "NSURLSessionAuthChallengeRejectProtectionSpace")]
1512    pub const RejectProtectionSpace: Self = Self(3);
1513}
1514
1515unsafe impl Encode for NSURLSessionAuthChallengeDisposition {
1516    const ENCODING: Encoding = NSInteger::ENCODING;
1517}
1518
1519unsafe impl RefEncode for NSURLSessionAuthChallengeDisposition {
1520    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1521}
1522
1523/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionresponsedisposition?language=objc)
1524// NS_ENUM
1525#[repr(transparent)]
1526#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1527pub struct NSURLSessionResponseDisposition(pub NSInteger);
1528impl NSURLSessionResponseDisposition {
1529    #[doc(alias = "NSURLSessionResponseCancel")]
1530    pub const Cancel: Self = Self(0);
1531    #[doc(alias = "NSURLSessionResponseAllow")]
1532    pub const Allow: Self = Self(1);
1533    #[doc(alias = "NSURLSessionResponseBecomeDownload")]
1534    pub const BecomeDownload: Self = Self(2);
1535    #[doc(alias = "NSURLSessionResponseBecomeStream")]
1536    pub const BecomeStream: Self = Self(3);
1537}
1538
1539unsafe impl Encode for NSURLSessionResponseDisposition {
1540    const ENCODING: Encoding = NSInteger::ENCODING;
1541}
1542
1543unsafe impl RefEncode for NSURLSessionResponseDisposition {
1544    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1545}
1546
1547extern_protocol!(
1548    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondelegate?language=objc)
1549    pub unsafe trait NSURLSessionDelegate: NSObjectProtocol {
1550        #[cfg(feature = "NSError")]
1551        #[optional]
1552        #[unsafe(method(URLSession:didBecomeInvalidWithError:))]
1553        #[unsafe(method_family = none)]
1554        unsafe fn URLSession_didBecomeInvalidWithError(
1555            &self,
1556            session: &NSURLSession,
1557            error: Option<&NSError>,
1558        );
1559
1560        #[cfg(all(
1561            feature = "NSURLAuthenticationChallenge",
1562            feature = "NSURLCredential",
1563            feature = "block2"
1564        ))]
1565        #[optional]
1566        #[unsafe(method(URLSession:didReceiveChallenge:completionHandler:))]
1567        #[unsafe(method_family = none)]
1568        unsafe fn URLSession_didReceiveChallenge_completionHandler(
1569            &self,
1570            session: &NSURLSession,
1571            challenge: &NSURLAuthenticationChallenge,
1572            completion_handler: &block2::DynBlock<
1573                dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
1574            >,
1575        );
1576
1577        #[optional]
1578        #[unsafe(method(URLSessionDidFinishEventsForBackgroundURLSession:))]
1579        #[unsafe(method_family = none)]
1580        unsafe fn URLSessionDidFinishEventsForBackgroundURLSession(&self, session: &NSURLSession);
1581    }
1582);
1583
1584extern_protocol!(
1585    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskdelegate?language=objc)
1586    pub unsafe trait NSURLSessionTaskDelegate: NSURLSessionDelegate {
1587        #[optional]
1588        #[unsafe(method(URLSession:didCreateTask:))]
1589        #[unsafe(method_family = none)]
1590        unsafe fn URLSession_didCreateTask(&self, session: &NSURLSession, task: &NSURLSessionTask);
1591
1592        #[cfg(all(feature = "NSURLRequest", feature = "block2"))]
1593        #[optional]
1594        #[unsafe(method(URLSession:task:willBeginDelayedRequest:completionHandler:))]
1595        #[unsafe(method_family = none)]
1596        unsafe fn URLSession_task_willBeginDelayedRequest_completionHandler(
1597            &self,
1598            session: &NSURLSession,
1599            task: &NSURLSessionTask,
1600            request: &NSURLRequest,
1601            completion_handler: &block2::DynBlock<
1602                dyn Fn(NSURLSessionDelayedRequestDisposition, *mut NSURLRequest),
1603            >,
1604        );
1605
1606        #[optional]
1607        #[unsafe(method(URLSession:taskIsWaitingForConnectivity:))]
1608        #[unsafe(method_family = none)]
1609        unsafe fn URLSession_taskIsWaitingForConnectivity(
1610            &self,
1611            session: &NSURLSession,
1612            task: &NSURLSessionTask,
1613        );
1614
1615        #[cfg(all(
1616            feature = "NSURLRequest",
1617            feature = "NSURLResponse",
1618            feature = "block2"
1619        ))]
1620        #[optional]
1621        #[unsafe(method(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:))]
1622        #[unsafe(method_family = none)]
1623        unsafe fn URLSession_task_willPerformHTTPRedirection_newRequest_completionHandler(
1624            &self,
1625            session: &NSURLSession,
1626            task: &NSURLSessionTask,
1627            response: &NSHTTPURLResponse,
1628            request: &NSURLRequest,
1629            completion_handler: &block2::DynBlock<dyn Fn(*mut NSURLRequest)>,
1630        );
1631
1632        #[cfg(all(
1633            feature = "NSURLAuthenticationChallenge",
1634            feature = "NSURLCredential",
1635            feature = "block2"
1636        ))]
1637        #[optional]
1638        #[unsafe(method(URLSession:task:didReceiveChallenge:completionHandler:))]
1639        #[unsafe(method_family = none)]
1640        unsafe fn URLSession_task_didReceiveChallenge_completionHandler(
1641            &self,
1642            session: &NSURLSession,
1643            task: &NSURLSessionTask,
1644            challenge: &NSURLAuthenticationChallenge,
1645            completion_handler: &block2::DynBlock<
1646                dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
1647            >,
1648        );
1649
1650        #[cfg(all(feature = "NSStream", feature = "block2"))]
1651        #[optional]
1652        #[unsafe(method(URLSession:task:needNewBodyStream:))]
1653        #[unsafe(method_family = none)]
1654        unsafe fn URLSession_task_needNewBodyStream(
1655            &self,
1656            session: &NSURLSession,
1657            task: &NSURLSessionTask,
1658            completion_handler: &block2::DynBlock<dyn Fn(*mut NSInputStream)>,
1659        );
1660
1661        #[cfg(all(feature = "NSStream", feature = "block2"))]
1662        /// Tells the delegate if a task requires a new body stream starting from the given offset. This may be
1663        /// necessary when resuming a failed upload task.
1664        ///
1665        /// - Parameter session: The session containing the task that needs a new body stream from the given offset.
1666        /// - Parameter task: The task that needs a new body stream.
1667        /// - Parameter offset: The starting offset required for the body stream.
1668        /// - Parameter completionHandler: A completion handler that your delegate method should call with the new body stream.
1669        #[optional]
1670        #[unsafe(method(URLSession:task:needNewBodyStreamFromOffset:completionHandler:))]
1671        #[unsafe(method_family = none)]
1672        unsafe fn URLSession_task_needNewBodyStreamFromOffset_completionHandler(
1673            &self,
1674            session: &NSURLSession,
1675            task: &NSURLSessionTask,
1676            offset: i64,
1677            completion_handler: &block2::DynBlock<dyn Fn(*mut NSInputStream)>,
1678        );
1679
1680        #[optional]
1681        #[unsafe(method(URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:))]
1682        #[unsafe(method_family = none)]
1683        unsafe fn URLSession_task_didSendBodyData_totalBytesSent_totalBytesExpectedToSend(
1684            &self,
1685            session: &NSURLSession,
1686            task: &NSURLSessionTask,
1687            bytes_sent: i64,
1688            total_bytes_sent: i64,
1689            total_bytes_expected_to_send: i64,
1690        );
1691
1692        #[cfg(feature = "NSURLResponse")]
1693        #[optional]
1694        #[unsafe(method(URLSession:task:didReceiveInformationalResponse:))]
1695        #[unsafe(method_family = none)]
1696        unsafe fn URLSession_task_didReceiveInformationalResponse(
1697            &self,
1698            session: &NSURLSession,
1699            task: &NSURLSessionTask,
1700            response: &NSHTTPURLResponse,
1701        );
1702
1703        #[optional]
1704        #[unsafe(method(URLSession:task:didFinishCollectingMetrics:))]
1705        #[unsafe(method_family = none)]
1706        unsafe fn URLSession_task_didFinishCollectingMetrics(
1707            &self,
1708            session: &NSURLSession,
1709            task: &NSURLSessionTask,
1710            metrics: &NSURLSessionTaskMetrics,
1711        );
1712
1713        #[cfg(feature = "NSError")]
1714        #[optional]
1715        #[unsafe(method(URLSession:task:didCompleteWithError:))]
1716        #[unsafe(method_family = none)]
1717        unsafe fn URLSession_task_didCompleteWithError(
1718            &self,
1719            session: &NSURLSession,
1720            task: &NSURLSessionTask,
1721            error: Option<&NSError>,
1722        );
1723    }
1724);
1725
1726extern_protocol!(
1727    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondatadelegate?language=objc)
1728    pub unsafe trait NSURLSessionDataDelegate: NSURLSessionTaskDelegate {
1729        #[cfg(all(feature = "NSURLResponse", feature = "block2"))]
1730        #[optional]
1731        #[unsafe(method(URLSession:dataTask:didReceiveResponse:completionHandler:))]
1732        #[unsafe(method_family = none)]
1733        unsafe fn URLSession_dataTask_didReceiveResponse_completionHandler(
1734            &self,
1735            session: &NSURLSession,
1736            data_task: &NSURLSessionDataTask,
1737            response: &NSURLResponse,
1738            completion_handler: &block2::DynBlock<dyn Fn(NSURLSessionResponseDisposition)>,
1739        );
1740
1741        #[optional]
1742        #[unsafe(method(URLSession:dataTask:didBecomeDownloadTask:))]
1743        #[unsafe(method_family = none)]
1744        unsafe fn URLSession_dataTask_didBecomeDownloadTask(
1745            &self,
1746            session: &NSURLSession,
1747            data_task: &NSURLSessionDataTask,
1748            download_task: &NSURLSessionDownloadTask,
1749        );
1750
1751        #[optional]
1752        #[unsafe(method(URLSession:dataTask:didBecomeStreamTask:))]
1753        #[unsafe(method_family = none)]
1754        unsafe fn URLSession_dataTask_didBecomeStreamTask(
1755            &self,
1756            session: &NSURLSession,
1757            data_task: &NSURLSessionDataTask,
1758            stream_task: &NSURLSessionStreamTask,
1759        );
1760
1761        #[cfg(feature = "NSData")]
1762        #[optional]
1763        #[unsafe(method(URLSession:dataTask:didReceiveData:))]
1764        #[unsafe(method_family = none)]
1765        unsafe fn URLSession_dataTask_didReceiveData(
1766            &self,
1767            session: &NSURLSession,
1768            data_task: &NSURLSessionDataTask,
1769            data: &NSData,
1770        );
1771
1772        #[cfg(all(feature = "NSURLCache", feature = "block2"))]
1773        #[optional]
1774        #[unsafe(method(URLSession:dataTask:willCacheResponse:completionHandler:))]
1775        #[unsafe(method_family = none)]
1776        unsafe fn URLSession_dataTask_willCacheResponse_completionHandler(
1777            &self,
1778            session: &NSURLSession,
1779            data_task: &NSURLSessionDataTask,
1780            proposed_response: &NSCachedURLResponse,
1781            completion_handler: &block2::DynBlock<dyn Fn(*mut NSCachedURLResponse)>,
1782        );
1783    }
1784);
1785
1786extern_protocol!(
1787    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondownloaddelegate?language=objc)
1788    pub unsafe trait NSURLSessionDownloadDelegate: NSURLSessionTaskDelegate {
1789        #[cfg(feature = "NSURL")]
1790        #[unsafe(method(URLSession:downloadTask:didFinishDownloadingToURL:))]
1791        #[unsafe(method_family = none)]
1792        unsafe fn URLSession_downloadTask_didFinishDownloadingToURL(
1793            &self,
1794            session: &NSURLSession,
1795            download_task: &NSURLSessionDownloadTask,
1796            location: &NSURL,
1797        );
1798
1799        #[optional]
1800        #[unsafe(method(URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:))]
1801        #[unsafe(method_family = none)]
1802        unsafe fn URLSession_downloadTask_didWriteData_totalBytesWritten_totalBytesExpectedToWrite(
1803            &self,
1804            session: &NSURLSession,
1805            download_task: &NSURLSessionDownloadTask,
1806            bytes_written: i64,
1807            total_bytes_written: i64,
1808            total_bytes_expected_to_write: i64,
1809        );
1810
1811        #[optional]
1812        #[unsafe(method(URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:))]
1813        #[unsafe(method_family = none)]
1814        unsafe fn URLSession_downloadTask_didResumeAtOffset_expectedTotalBytes(
1815            &self,
1816            session: &NSURLSession,
1817            download_task: &NSURLSessionDownloadTask,
1818            file_offset: i64,
1819            expected_total_bytes: i64,
1820        );
1821    }
1822);
1823
1824extern_protocol!(
1825    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionstreamdelegate?language=objc)
1826    pub unsafe trait NSURLSessionStreamDelegate: NSURLSessionTaskDelegate {
1827        #[optional]
1828        #[unsafe(method(URLSession:readClosedForStreamTask:))]
1829        #[unsafe(method_family = none)]
1830        unsafe fn URLSession_readClosedForStreamTask(
1831            &self,
1832            session: &NSURLSession,
1833            stream_task: &NSURLSessionStreamTask,
1834        );
1835
1836        #[optional]
1837        #[unsafe(method(URLSession:writeClosedForStreamTask:))]
1838        #[unsafe(method_family = none)]
1839        unsafe fn URLSession_writeClosedForStreamTask(
1840            &self,
1841            session: &NSURLSession,
1842            stream_task: &NSURLSessionStreamTask,
1843        );
1844
1845        #[optional]
1846        #[unsafe(method(URLSession:betterRouteDiscoveredForStreamTask:))]
1847        #[unsafe(method_family = none)]
1848        unsafe fn URLSession_betterRouteDiscoveredForStreamTask(
1849            &self,
1850            session: &NSURLSession,
1851            stream_task: &NSURLSessionStreamTask,
1852        );
1853
1854        #[cfg(feature = "NSStream")]
1855        #[optional]
1856        #[unsafe(method(URLSession:streamTask:didBecomeInputStream:outputStream:))]
1857        #[unsafe(method_family = none)]
1858        unsafe fn URLSession_streamTask_didBecomeInputStream_outputStream(
1859            &self,
1860            session: &NSURLSession,
1861            stream_task: &NSURLSessionStreamTask,
1862            input_stream: &NSInputStream,
1863            output_stream: &NSOutputStream,
1864        );
1865    }
1866);
1867
1868extern_protocol!(
1869    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionwebsocketdelegate?language=objc)
1870    pub unsafe trait NSURLSessionWebSocketDelegate: NSURLSessionTaskDelegate {
1871        #[cfg(feature = "NSString")]
1872        #[optional]
1873        #[unsafe(method(URLSession:webSocketTask:didOpenWithProtocol:))]
1874        #[unsafe(method_family = none)]
1875        unsafe fn URLSession_webSocketTask_didOpenWithProtocol(
1876            &self,
1877            session: &NSURLSession,
1878            web_socket_task: &NSURLSessionWebSocketTask,
1879            protocol: Option<&NSString>,
1880        );
1881
1882        #[cfg(feature = "NSData")]
1883        #[optional]
1884        #[unsafe(method(URLSession:webSocketTask:didCloseWithCode:reason:))]
1885        #[unsafe(method_family = none)]
1886        unsafe fn URLSession_webSocketTask_didCloseWithCode_reason(
1887            &self,
1888            session: &NSURLSession,
1889            web_socket_task: &NSURLSessionWebSocketTask,
1890            close_code: NSURLSessionWebSocketCloseCode,
1891            reason: Option<&NSData>,
1892        );
1893    }
1894);
1895
1896extern "C" {
1897    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiondownloadtaskresumedata?language=objc)
1898    #[cfg(feature = "NSString")]
1899    pub static NSURLSessionDownloadTaskResumeData: &'static NSString;
1900}
1901
1902extern "C" {
1903    /// Key in the userInfo dictionary of an NSError received during a failed upload.
1904    ///
1905    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessionuploadtaskresumedata?language=objc)
1906    #[cfg(feature = "NSString")]
1907    pub static NSURLSessionUploadTaskResumeData: &'static NSString;
1908}
1909
1910/// NSURLSessionDeprecated.
1911impl NSURLSessionConfiguration {
1912    extern_methods!(
1913        #[cfg(feature = "NSString")]
1914        #[deprecated]
1915        #[unsafe(method(backgroundSessionConfiguration:))]
1916        #[unsafe(method_family = none)]
1917        pub unsafe fn backgroundSessionConfiguration(
1918            identifier: &NSString,
1919        ) -> Retained<NSURLSessionConfiguration>;
1920    );
1921}
1922
1923/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskmetricsresourcefetchtype?language=objc)
1924// NS_ENUM
1925#[repr(transparent)]
1926#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1927pub struct NSURLSessionTaskMetricsResourceFetchType(pub NSInteger);
1928impl NSURLSessionTaskMetricsResourceFetchType {
1929    #[doc(alias = "NSURLSessionTaskMetricsResourceFetchTypeUnknown")]
1930    pub const Unknown: Self = Self(0);
1931    #[doc(alias = "NSURLSessionTaskMetricsResourceFetchTypeNetworkLoad")]
1932    pub const NetworkLoad: Self = Self(1);
1933    #[doc(alias = "NSURLSessionTaskMetricsResourceFetchTypeServerPush")]
1934    #[deprecated = "Server push is no longer supported as of iOS 17 and aligned releases"]
1935    pub const ServerPush: Self = Self(2);
1936    #[doc(alias = "NSURLSessionTaskMetricsResourceFetchTypeLocalCache")]
1937    pub const LocalCache: Self = Self(3);
1938}
1939
1940unsafe impl Encode for NSURLSessionTaskMetricsResourceFetchType {
1941    const ENCODING: Encoding = NSInteger::ENCODING;
1942}
1943
1944unsafe impl RefEncode for NSURLSessionTaskMetricsResourceFetchType {
1945    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1946}
1947
1948/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskmetricsdomainresolutionprotocol?language=objc)
1949// NS_ENUM
1950#[repr(transparent)]
1951#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1952pub struct NSURLSessionTaskMetricsDomainResolutionProtocol(pub NSInteger);
1953impl NSURLSessionTaskMetricsDomainResolutionProtocol {
1954    #[doc(alias = "NSURLSessionTaskMetricsDomainResolutionProtocolUnknown")]
1955    pub const Unknown: Self = Self(0);
1956    #[doc(alias = "NSURLSessionTaskMetricsDomainResolutionProtocolUDP")]
1957    pub const UDP: Self = Self(1);
1958    #[doc(alias = "NSURLSessionTaskMetricsDomainResolutionProtocolTCP")]
1959    pub const TCP: Self = Self(2);
1960    #[doc(alias = "NSURLSessionTaskMetricsDomainResolutionProtocolTLS")]
1961    pub const TLS: Self = Self(3);
1962    #[doc(alias = "NSURLSessionTaskMetricsDomainResolutionProtocolHTTPS")]
1963    pub const HTTPS: Self = Self(4);
1964}
1965
1966unsafe impl Encode for NSURLSessionTaskMetricsDomainResolutionProtocol {
1967    const ENCODING: Encoding = NSInteger::ENCODING;
1968}
1969
1970unsafe impl RefEncode for NSURLSessionTaskMetricsDomainResolutionProtocol {
1971    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1972}
1973
1974extern_class!(
1975    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontasktransactionmetrics?language=objc)
1976    #[unsafe(super(NSObject))]
1977    #[derive(Debug, PartialEq, Eq, Hash)]
1978    pub struct NSURLSessionTaskTransactionMetrics;
1979);
1980
1981unsafe impl Send for NSURLSessionTaskTransactionMetrics {}
1982
1983unsafe impl Sync for NSURLSessionTaskTransactionMetrics {}
1984
1985extern_conformance!(
1986    unsafe impl NSObjectProtocol for NSURLSessionTaskTransactionMetrics {}
1987);
1988
1989impl NSURLSessionTaskTransactionMetrics {
1990    extern_methods!(
1991        #[cfg(feature = "NSURLRequest")]
1992        #[unsafe(method(request))]
1993        #[unsafe(method_family = none)]
1994        pub unsafe fn request(&self) -> Retained<NSURLRequest>;
1995
1996        #[cfg(feature = "NSURLResponse")]
1997        #[unsafe(method(response))]
1998        #[unsafe(method_family = none)]
1999        pub unsafe fn response(&self) -> Option<Retained<NSURLResponse>>;
2000
2001        #[cfg(feature = "NSDate")]
2002        #[unsafe(method(fetchStartDate))]
2003        #[unsafe(method_family = none)]
2004        pub unsafe fn fetchStartDate(&self) -> Option<Retained<NSDate>>;
2005
2006        #[cfg(feature = "NSDate")]
2007        #[unsafe(method(domainLookupStartDate))]
2008        #[unsafe(method_family = none)]
2009        pub unsafe fn domainLookupStartDate(&self) -> Option<Retained<NSDate>>;
2010
2011        #[cfg(feature = "NSDate")]
2012        #[unsafe(method(domainLookupEndDate))]
2013        #[unsafe(method_family = none)]
2014        pub unsafe fn domainLookupEndDate(&self) -> Option<Retained<NSDate>>;
2015
2016        #[cfg(feature = "NSDate")]
2017        #[unsafe(method(connectStartDate))]
2018        #[unsafe(method_family = none)]
2019        pub unsafe fn connectStartDate(&self) -> Option<Retained<NSDate>>;
2020
2021        #[cfg(feature = "NSDate")]
2022        #[unsafe(method(secureConnectionStartDate))]
2023        #[unsafe(method_family = none)]
2024        pub unsafe fn secureConnectionStartDate(&self) -> Option<Retained<NSDate>>;
2025
2026        #[cfg(feature = "NSDate")]
2027        #[unsafe(method(secureConnectionEndDate))]
2028        #[unsafe(method_family = none)]
2029        pub unsafe fn secureConnectionEndDate(&self) -> Option<Retained<NSDate>>;
2030
2031        #[cfg(feature = "NSDate")]
2032        #[unsafe(method(connectEndDate))]
2033        #[unsafe(method_family = none)]
2034        pub unsafe fn connectEndDate(&self) -> Option<Retained<NSDate>>;
2035
2036        #[cfg(feature = "NSDate")]
2037        #[unsafe(method(requestStartDate))]
2038        #[unsafe(method_family = none)]
2039        pub unsafe fn requestStartDate(&self) -> Option<Retained<NSDate>>;
2040
2041        #[cfg(feature = "NSDate")]
2042        #[unsafe(method(requestEndDate))]
2043        #[unsafe(method_family = none)]
2044        pub unsafe fn requestEndDate(&self) -> Option<Retained<NSDate>>;
2045
2046        #[cfg(feature = "NSDate")]
2047        #[unsafe(method(responseStartDate))]
2048        #[unsafe(method_family = none)]
2049        pub unsafe fn responseStartDate(&self) -> Option<Retained<NSDate>>;
2050
2051        #[cfg(feature = "NSDate")]
2052        #[unsafe(method(responseEndDate))]
2053        #[unsafe(method_family = none)]
2054        pub unsafe fn responseEndDate(&self) -> Option<Retained<NSDate>>;
2055
2056        #[cfg(feature = "NSString")]
2057        #[unsafe(method(networkProtocolName))]
2058        #[unsafe(method_family = none)]
2059        pub unsafe fn networkProtocolName(&self) -> Option<Retained<NSString>>;
2060
2061        #[unsafe(method(isProxyConnection))]
2062        #[unsafe(method_family = none)]
2063        pub unsafe fn isProxyConnection(&self) -> bool;
2064
2065        #[unsafe(method(isReusedConnection))]
2066        #[unsafe(method_family = none)]
2067        pub unsafe fn isReusedConnection(&self) -> bool;
2068
2069        #[unsafe(method(resourceFetchType))]
2070        #[unsafe(method_family = none)]
2071        pub unsafe fn resourceFetchType(&self) -> NSURLSessionTaskMetricsResourceFetchType;
2072
2073        #[unsafe(method(countOfRequestHeaderBytesSent))]
2074        #[unsafe(method_family = none)]
2075        pub unsafe fn countOfRequestHeaderBytesSent(&self) -> i64;
2076
2077        #[unsafe(method(countOfRequestBodyBytesSent))]
2078        #[unsafe(method_family = none)]
2079        pub unsafe fn countOfRequestBodyBytesSent(&self) -> i64;
2080
2081        #[unsafe(method(countOfRequestBodyBytesBeforeEncoding))]
2082        #[unsafe(method_family = none)]
2083        pub unsafe fn countOfRequestBodyBytesBeforeEncoding(&self) -> i64;
2084
2085        #[unsafe(method(countOfResponseHeaderBytesReceived))]
2086        #[unsafe(method_family = none)]
2087        pub unsafe fn countOfResponseHeaderBytesReceived(&self) -> i64;
2088
2089        #[unsafe(method(countOfResponseBodyBytesReceived))]
2090        #[unsafe(method_family = none)]
2091        pub unsafe fn countOfResponseBodyBytesReceived(&self) -> i64;
2092
2093        #[unsafe(method(countOfResponseBodyBytesAfterDecoding))]
2094        #[unsafe(method_family = none)]
2095        pub unsafe fn countOfResponseBodyBytesAfterDecoding(&self) -> i64;
2096
2097        #[cfg(feature = "NSString")]
2098        #[unsafe(method(localAddress))]
2099        #[unsafe(method_family = none)]
2100        pub unsafe fn localAddress(&self) -> Option<Retained<NSString>>;
2101
2102        #[cfg(feature = "NSValue")]
2103        #[unsafe(method(localPort))]
2104        #[unsafe(method_family = none)]
2105        pub unsafe fn localPort(&self) -> Option<Retained<NSNumber>>;
2106
2107        #[cfg(feature = "NSString")]
2108        #[unsafe(method(remoteAddress))]
2109        #[unsafe(method_family = none)]
2110        pub unsafe fn remoteAddress(&self) -> Option<Retained<NSString>>;
2111
2112        #[cfg(feature = "NSValue")]
2113        #[unsafe(method(remotePort))]
2114        #[unsafe(method_family = none)]
2115        pub unsafe fn remotePort(&self) -> Option<Retained<NSNumber>>;
2116
2117        #[cfg(feature = "NSValue")]
2118        #[unsafe(method(negotiatedTLSProtocolVersion))]
2119        #[unsafe(method_family = none)]
2120        pub unsafe fn negotiatedTLSProtocolVersion(&self) -> Option<Retained<NSNumber>>;
2121
2122        #[cfg(feature = "NSValue")]
2123        #[unsafe(method(negotiatedTLSCipherSuite))]
2124        #[unsafe(method_family = none)]
2125        pub unsafe fn negotiatedTLSCipherSuite(&self) -> Option<Retained<NSNumber>>;
2126
2127        #[unsafe(method(isCellular))]
2128        #[unsafe(method_family = none)]
2129        pub unsafe fn isCellular(&self) -> bool;
2130
2131        #[unsafe(method(isExpensive))]
2132        #[unsafe(method_family = none)]
2133        pub unsafe fn isExpensive(&self) -> bool;
2134
2135        #[unsafe(method(isConstrained))]
2136        #[unsafe(method_family = none)]
2137        pub unsafe fn isConstrained(&self) -> bool;
2138
2139        #[unsafe(method(isMultipath))]
2140        #[unsafe(method_family = none)]
2141        pub unsafe fn isMultipath(&self) -> bool;
2142
2143        #[unsafe(method(domainResolutionProtocol))]
2144        #[unsafe(method_family = none)]
2145        pub unsafe fn domainResolutionProtocol(
2146            &self,
2147        ) -> NSURLSessionTaskMetricsDomainResolutionProtocol;
2148
2149        #[deprecated = "Not supported"]
2150        #[unsafe(method(init))]
2151        #[unsafe(method_family = init)]
2152        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2153
2154        #[deprecated = "Not supported"]
2155        #[unsafe(method(new))]
2156        #[unsafe(method_family = new)]
2157        pub unsafe fn new() -> Retained<Self>;
2158    );
2159}
2160
2161extern_class!(
2162    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsurlsessiontaskmetrics?language=objc)
2163    #[unsafe(super(NSObject))]
2164    #[derive(Debug, PartialEq, Eq, Hash)]
2165    pub struct NSURLSessionTaskMetrics;
2166);
2167
2168unsafe impl Send for NSURLSessionTaskMetrics {}
2169
2170unsafe impl Sync for NSURLSessionTaskMetrics {}
2171
2172extern_conformance!(
2173    unsafe impl NSObjectProtocol for NSURLSessionTaskMetrics {}
2174);
2175
2176impl NSURLSessionTaskMetrics {
2177    extern_methods!(
2178        #[cfg(feature = "NSArray")]
2179        #[unsafe(method(transactionMetrics))]
2180        #[unsafe(method_family = none)]
2181        pub unsafe fn transactionMetrics(
2182            &self,
2183        ) -> Retained<NSArray<NSURLSessionTaskTransactionMetrics>>;
2184
2185        #[cfg(feature = "NSDateInterval")]
2186        #[unsafe(method(taskInterval))]
2187        #[unsafe(method_family = none)]
2188        pub unsafe fn taskInterval(&self) -> Retained<NSDateInterval>;
2189
2190        #[unsafe(method(redirectCount))]
2191        #[unsafe(method_family = none)]
2192        pub unsafe fn redirectCount(&self) -> NSUInteger;
2193
2194        #[deprecated = "Not supported"]
2195        #[unsafe(method(init))]
2196        #[unsafe(method_family = init)]
2197        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
2198
2199        #[deprecated = "Not supported"]
2200        #[unsafe(method(new))]
2201        #[unsafe(method_family = new)]
2202        pub unsafe fn new() -> Retained<Self>;
2203    );
2204}