1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSURLRequestCachePolicy(pub NSUInteger);
impl NSURLRequestCachePolicy {
    pub const NSURLRequestUseProtocolCachePolicy: Self = Self(0);
    pub const NSURLRequestReloadIgnoringLocalCacheData: Self = Self(1);
    pub const NSURLRequestReloadIgnoringLocalAndRemoteCacheData: Self = Self(4);
    pub const NSURLRequestReloadIgnoringCacheData: Self =
        Self(NSURLRequestCachePolicy::NSURLRequestReloadIgnoringLocalCacheData.0);
    pub const NSURLRequestReturnCacheDataElseLoad: Self = Self(2);
    pub const NSURLRequestReturnCacheDataDontLoad: Self = Self(3);
    pub const NSURLRequestReloadRevalidatingCacheData: Self = Self(5);
}

unsafe impl Encode for NSURLRequestCachePolicy {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSURLRequestCachePolicy {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSURLRequestNetworkServiceType(pub NSUInteger);
impl NSURLRequestNetworkServiceType {
    pub const NSURLNetworkServiceTypeDefault: Self = Self(0);
    #[deprecated = "Use PushKit for VoIP control purposes"]
    pub const NSURLNetworkServiceTypeVoIP: Self = Self(1);
    pub const NSURLNetworkServiceTypeVideo: Self = Self(2);
    pub const NSURLNetworkServiceTypeBackground: Self = Self(3);
    pub const NSURLNetworkServiceTypeVoice: Self = Self(4);
    pub const NSURLNetworkServiceTypeResponsiveData: Self = Self(6);
    pub const NSURLNetworkServiceTypeAVStreaming: Self = Self(8);
    pub const NSURLNetworkServiceTypeResponsiveAV: Self = Self(9);
    pub const NSURLNetworkServiceTypeCallSignaling: Self = Self(11);
}

unsafe impl Encode for NSURLRequestNetworkServiceType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSURLRequestNetworkServiceType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSURLRequestAttribution(pub NSUInteger);
impl NSURLRequestAttribution {
    #[doc(alias = "NSURLRequestAttributionDeveloper")]
    pub const Developer: Self = Self(0);
    #[doc(alias = "NSURLRequestAttributionUser")]
    pub const User: Self = Self(1);
}

unsafe impl Encode for NSURLRequestAttribution {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSURLRequestAttribution {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSURLRequest;

    unsafe impl ClassType for NSURLRequest {
        type Super = NSObject;
        type Mutability = ImmutableWithMutableSubclass<NSMutableURLRequest>;
    }
);

#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSURLRequest {}

#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSURLRequest {}

#[cfg(feature = "NSObject")]
unsafe impl NSMutableCopying for NSURLRequest {}

unsafe impl NSObjectProtocol for NSURLRequest {}

#[cfg(feature = "NSObject")]
unsafe impl NSSecureCoding for NSURLRequest {}

extern_methods!(
    unsafe impl NSURLRequest {
        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Other requestWithURL:)]
        pub unsafe fn requestWithURL(url: &NSURL) -> Retained<Self>;

        #[method(supportsSecureCoding)]
        pub unsafe fn supportsSecureCoding() -> bool;

        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
        #[method_id(@__retain_semantics Other requestWithURL:cachePolicy:timeoutInterval:)]
        pub unsafe fn requestWithURL_cachePolicy_timeoutInterval(
            url: &NSURL,
            cache_policy: NSURLRequestCachePolicy,
            timeout_interval: NSTimeInterval,
        ) -> Retained<Self>;

        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Init initWithURL:)]
        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;

        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
        #[method_id(@__retain_semantics Init initWithURL:cachePolicy:timeoutInterval:)]
        pub unsafe fn initWithURL_cachePolicy_timeoutInterval(
            this: Allocated<Self>,
            url: &NSURL,
            cache_policy: NSURLRequestCachePolicy,
            timeout_interval: NSTimeInterval,
        ) -> Retained<Self>;

        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Other URL)]
        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;

        #[method(cachePolicy)]
        pub unsafe fn cachePolicy(&self) -> NSURLRequestCachePolicy;

        #[cfg(feature = "NSDate")]
        #[method(timeoutInterval)]
        pub unsafe fn timeoutInterval(&self) -> NSTimeInterval;

        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Other mainDocumentURL)]
        pub unsafe fn mainDocumentURL(&self) -> Option<Retained<NSURL>>;

        #[method(networkServiceType)]
        pub unsafe fn networkServiceType(&self) -> NSURLRequestNetworkServiceType;

        #[method(allowsCellularAccess)]
        pub unsafe fn allowsCellularAccess(&self) -> bool;

        #[method(allowsExpensiveNetworkAccess)]
        pub unsafe fn allowsExpensiveNetworkAccess(&self) -> bool;

        #[method(allowsConstrainedNetworkAccess)]
        pub unsafe fn allowsConstrainedNetworkAccess(&self) -> bool;

        #[method(assumesHTTP3Capable)]
        pub unsafe fn assumesHTTP3Capable(&self) -> bool;

        #[method(attribution)]
        pub unsafe fn attribution(&self) -> NSURLRequestAttribution;

        #[method(requiresDNSSECValidation)]
        pub unsafe fn requiresDNSSECValidation(&self) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSURLRequest {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSMutableURLRequest;

    unsafe impl ClassType for NSMutableURLRequest {
        #[inherits(NSObject)]
        type Super = NSURLRequest;
        type Mutability = MutableWithImmutableSuperclass<NSURLRequest>;
    }
);

#[cfg(feature = "NSObject")]
unsafe impl NSCoding for NSMutableURLRequest {}

#[cfg(feature = "NSObject")]
unsafe impl NSCopying for NSMutableURLRequest {}

#[cfg(feature = "NSObject")]
unsafe impl NSMutableCopying for NSMutableURLRequest {}

unsafe impl NSObjectProtocol for NSMutableURLRequest {}

#[cfg(feature = "NSObject")]
unsafe impl NSSecureCoding for NSMutableURLRequest {}

extern_methods!(
    unsafe impl NSMutableURLRequest {
        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Other URL)]
        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[method(setURL:)]
        pub unsafe fn setURL(&mut self, url: Option<&NSURL>);

        #[method(cachePolicy)]
        pub unsafe fn cachePolicy(&self) -> NSURLRequestCachePolicy;

        #[method(setCachePolicy:)]
        pub unsafe fn setCachePolicy(&mut self, cache_policy: NSURLRequestCachePolicy);

        #[cfg(feature = "NSDate")]
        #[method(timeoutInterval)]
        pub unsafe fn timeoutInterval(&self) -> NSTimeInterval;

        #[cfg(feature = "NSDate")]
        #[method(setTimeoutInterval:)]
        pub unsafe fn setTimeoutInterval(&mut self, timeout_interval: NSTimeInterval);

        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Other mainDocumentURL)]
        pub unsafe fn mainDocumentURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        #[method(setMainDocumentURL:)]
        pub unsafe fn setMainDocumentURL(&mut self, main_document_url: Option<&NSURL>);

        #[method(networkServiceType)]
        pub unsafe fn networkServiceType(&self) -> NSURLRequestNetworkServiceType;

        #[method(setNetworkServiceType:)]
        pub unsafe fn setNetworkServiceType(
            &mut self,
            network_service_type: NSURLRequestNetworkServiceType,
        );

        #[method(allowsCellularAccess)]
        pub unsafe fn allowsCellularAccess(&self) -> bool;

        #[method(setAllowsCellularAccess:)]
        pub unsafe fn setAllowsCellularAccess(&mut self, allows_cellular_access: bool);

        #[method(allowsExpensiveNetworkAccess)]
        pub unsafe fn allowsExpensiveNetworkAccess(&self) -> bool;

        #[method(setAllowsExpensiveNetworkAccess:)]
        pub unsafe fn setAllowsExpensiveNetworkAccess(
            &mut self,
            allows_expensive_network_access: bool,
        );

        #[method(allowsConstrainedNetworkAccess)]
        pub unsafe fn allowsConstrainedNetworkAccess(&self) -> bool;

        #[method(setAllowsConstrainedNetworkAccess:)]
        pub unsafe fn setAllowsConstrainedNetworkAccess(
            &mut self,
            allows_constrained_network_access: bool,
        );

        #[method(assumesHTTP3Capable)]
        pub unsafe fn assumesHTTP3Capable(&self) -> bool;

        #[method(setAssumesHTTP3Capable:)]
        pub unsafe fn setAssumesHTTP3Capable(&mut self, assumes_http3_capable: bool);

        #[method(attribution)]
        pub unsafe fn attribution(&self) -> NSURLRequestAttribution;

        #[method(setAttribution:)]
        pub unsafe fn setAttribution(&mut self, attribution: NSURLRequestAttribution);

        #[method(requiresDNSSECValidation)]
        pub unsafe fn requiresDNSSECValidation(&self) -> bool;

        #[method(setRequiresDNSSECValidation:)]
        pub unsafe fn setRequiresDNSSECValidation(&mut self, requires_dnssec_validation: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSURLRequest`
    unsafe impl NSMutableURLRequest {
        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Other requestWithURL:)]
        pub unsafe fn requestWithURL(url: &NSURL) -> Retained<Self>;

        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
        #[method_id(@__retain_semantics Other requestWithURL:cachePolicy:timeoutInterval:)]
        pub unsafe fn requestWithURL_cachePolicy_timeoutInterval(
            url: &NSURL,
            cache_policy: NSURLRequestCachePolicy,
            timeout_interval: NSTimeInterval,
        ) -> Retained<Self>;

        #[cfg(feature = "NSURL")]
        #[method_id(@__retain_semantics Init initWithURL:)]
        pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;

        #[cfg(all(feature = "NSDate", feature = "NSURL"))]
        #[method_id(@__retain_semantics Init initWithURL:cachePolicy:timeoutInterval:)]
        pub unsafe fn initWithURL_cachePolicy_timeoutInterval(
            this: Allocated<Self>,
            url: &NSURL,
            cache_policy: NSURLRequestCachePolicy,
            timeout_interval: NSTimeInterval,
        ) -> Retained<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSMutableURLRequest {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

extern_methods!(
    /// NSHTTPURLRequest
    unsafe impl NSURLRequest {
        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other HTTPMethod)]
        pub unsafe fn HTTPMethod(&self) -> Option<Retained<NSString>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Other allHTTPHeaderFields)]
        pub unsafe fn allHTTPHeaderFields(
            &self,
        ) -> Option<Retained<NSDictionary<NSString, NSString>>>;

        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other valueForHTTPHeaderField:)]
        pub unsafe fn valueForHTTPHeaderField(
            &self,
            field: &NSString,
        ) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSData")]
        #[method_id(@__retain_semantics Other HTTPBody)]
        pub unsafe fn HTTPBody(&self) -> Option<Retained<NSData>>;

        #[cfg(feature = "NSStream")]
        #[method_id(@__retain_semantics Other HTTPBodyStream)]
        pub unsafe fn HTTPBodyStream(&self) -> Option<Retained<NSInputStream>>;

        #[method(HTTPShouldHandleCookies)]
        pub unsafe fn HTTPShouldHandleCookies(&self) -> bool;

        #[method(HTTPShouldUsePipelining)]
        pub unsafe fn HTTPShouldUsePipelining(&self) -> bool;
    }
);

extern_methods!(
    /// NSMutableHTTPURLRequest
    unsafe impl NSMutableURLRequest {
        #[cfg(feature = "NSString")]
        #[method_id(@__retain_semantics Other HTTPMethod)]
        pub unsafe fn HTTPMethod(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        #[method(setHTTPMethod:)]
        pub unsafe fn setHTTPMethod(&mut self, http_method: &NSString);

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method_id(@__retain_semantics Other allHTTPHeaderFields)]
        pub unsafe fn allHTTPHeaderFields(
            &self,
        ) -> Option<Retained<NSDictionary<NSString, NSString>>>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[method(setAllHTTPHeaderFields:)]
        pub unsafe fn setAllHTTPHeaderFields(
            &mut self,
            all_http_header_fields: Option<&NSDictionary<NSString, NSString>>,
        );

        #[cfg(feature = "NSString")]
        #[method(setValue:forHTTPHeaderField:)]
        pub unsafe fn setValue_forHTTPHeaderField(
            &mut self,
            value: Option<&NSString>,
            field: &NSString,
        );

        #[cfg(feature = "NSString")]
        #[method(addValue:forHTTPHeaderField:)]
        pub unsafe fn addValue_forHTTPHeaderField(&mut self, value: &NSString, field: &NSString);

        #[cfg(feature = "NSData")]
        #[method_id(@__retain_semantics Other HTTPBody)]
        pub unsafe fn HTTPBody(&self) -> Option<Retained<NSData>>;

        #[cfg(feature = "NSData")]
        #[method(setHTTPBody:)]
        pub unsafe fn setHTTPBody(&mut self, http_body: Option<&NSData>);

        #[cfg(feature = "NSStream")]
        #[method_id(@__retain_semantics Other HTTPBodyStream)]
        pub unsafe fn HTTPBodyStream(&self) -> Option<Retained<NSInputStream>>;

        #[cfg(feature = "NSStream")]
        #[method(setHTTPBodyStream:)]
        pub unsafe fn setHTTPBodyStream(&mut self, http_body_stream: Option<&NSInputStream>);

        #[method(HTTPShouldHandleCookies)]
        pub unsafe fn HTTPShouldHandleCookies(&self) -> bool;

        #[method(setHTTPShouldHandleCookies:)]
        pub unsafe fn setHTTPShouldHandleCookies(&mut self, http_should_handle_cookies: bool);

        #[method(HTTPShouldUsePipelining)]
        pub unsafe fn HTTPShouldUsePipelining(&self) -> bool;

        #[method(setHTTPShouldUsePipelining:)]
        pub unsafe fn setHTTPShouldUsePipelining(&mut self, http_should_use_pipelining: bool);
    }
);