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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

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

    unsafe impl ClassType for NSURLDownload {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSURLDownload {}

extern_methods!(
    unsafe impl NSURLDownload {
        #[cfg(feature = "NSString")]
        #[method(canResumeDownloadDecodedWithEncodingMIMEType:)]
        pub unsafe fn canResumeDownloadDecodedWithEncodingMIMEType(mime_type: &NSString) -> bool;

        #[cfg(feature = "NSURLRequest")]
        #[deprecated = "Use NSURLSession downloadTask (see NSURLSession.h)"]
        #[method_id(@__retain_semantics Init initWithRequest:delegate:)]
        pub unsafe fn initWithRequest_delegate(
            this: Allocated<Self>,
            request: &NSURLRequest,
            delegate: Option<&ProtocolObject<dyn NSURLDownloadDelegate>>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "NSData", feature = "NSString"))]
        #[deprecated = "Use NSURLSession downloadTask (see NSURLSession.h)"]
        #[method_id(@__retain_semantics Init initWithResumeData:delegate:path:)]
        pub unsafe fn initWithResumeData_delegate_path(
            this: Allocated<Self>,
            resume_data: &NSData,
            delegate: Option<&ProtocolObject<dyn NSURLDownloadDelegate>>,
            path: &NSString,
        ) -> Retained<Self>;

        #[method(cancel)]
        pub unsafe fn cancel(&self);

        #[cfg(feature = "NSString")]
        #[method(setDestination:allowOverwrite:)]
        pub unsafe fn setDestination_allowOverwrite(&self, path: &NSString, allow_overwrite: bool);

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

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

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

        #[method(setDeletesFileUponFailure:)]
        pub unsafe fn setDeletesFileUponFailure(&self, deletes_file_upon_failure: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSURLDownload {
        #[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_protocol!(
    pub unsafe trait NSURLDownloadDelegate: NSObjectProtocol {
        #[optional]
        #[method(downloadDidBegin:)]
        unsafe fn downloadDidBegin(&self, download: &NSURLDownload);

        #[cfg(all(feature = "NSURLRequest", feature = "NSURLResponse"))]
        #[optional]
        #[method_id(@__retain_semantics Other download:willSendRequest:redirectResponse:)]
        unsafe fn download_willSendRequest_redirectResponse(
            &self,
            download: &NSURLDownload,
            request: &NSURLRequest,
            redirect_response: Option<&NSURLResponse>,
        ) -> Option<Retained<NSURLRequest>>;

        #[cfg(feature = "NSURLProtectionSpace")]
        #[optional]
        #[method(download:canAuthenticateAgainstProtectionSpace:)]
        unsafe fn download_canAuthenticateAgainstProtectionSpace(
            &self,
            connection: &NSURLDownload,
            protection_space: &NSURLProtectionSpace,
        ) -> bool;

        #[cfg(feature = "NSURLAuthenticationChallenge")]
        #[optional]
        #[method(download:didReceiveAuthenticationChallenge:)]
        unsafe fn download_didReceiveAuthenticationChallenge(
            &self,
            download: &NSURLDownload,
            challenge: &NSURLAuthenticationChallenge,
        );

        #[cfg(feature = "NSURLAuthenticationChallenge")]
        #[optional]
        #[method(download:didCancelAuthenticationChallenge:)]
        unsafe fn download_didCancelAuthenticationChallenge(
            &self,
            download: &NSURLDownload,
            challenge: &NSURLAuthenticationChallenge,
        );

        #[optional]
        #[method(downloadShouldUseCredentialStorage:)]
        unsafe fn downloadShouldUseCredentialStorage(&self, download: &NSURLDownload) -> bool;

        #[cfg(feature = "NSURLResponse")]
        #[optional]
        #[method(download:didReceiveResponse:)]
        unsafe fn download_didReceiveResponse(
            &self,
            download: &NSURLDownload,
            response: &NSURLResponse,
        );

        #[cfg(feature = "NSURLResponse")]
        #[optional]
        #[method(download:willResumeWithResponse:fromByte:)]
        unsafe fn download_willResumeWithResponse_fromByte(
            &self,
            download: &NSURLDownload,
            response: &NSURLResponse,
            starting_byte: c_longlong,
        );

        #[optional]
        #[method(download:didReceiveDataOfLength:)]
        unsafe fn download_didReceiveDataOfLength(
            &self,
            download: &NSURLDownload,
            length: NSUInteger,
        );

        #[cfg(feature = "NSString")]
        #[optional]
        #[method(download:shouldDecodeSourceDataOfMIMEType:)]
        unsafe fn download_shouldDecodeSourceDataOfMIMEType(
            &self,
            download: &NSURLDownload,
            encoding_type: &NSString,
        ) -> bool;

        #[cfg(feature = "NSString")]
        #[optional]
        #[method(download:decideDestinationWithSuggestedFilename:)]
        unsafe fn download_decideDestinationWithSuggestedFilename(
            &self,
            download: &NSURLDownload,
            filename: &NSString,
        );

        #[cfg(feature = "NSString")]
        #[optional]
        #[method(download:didCreateDestination:)]
        unsafe fn download_didCreateDestination(&self, download: &NSURLDownload, path: &NSString);

        #[optional]
        #[method(downloadDidFinish:)]
        unsafe fn downloadDidFinish(&self, download: &NSURLDownload);

        #[cfg(feature = "NSError")]
        #[optional]
        #[method(download:didFailWithError:)]
        unsafe fn download_didFailWithError(&self, download: &NSURLDownload, error: &NSError);
    }

    unsafe impl ProtocolType for dyn NSURLDownloadDelegate {}
);