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