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