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

use crate::*;

extern_protocol!(
    pub unsafe trait BADownloadManagerDelegate: NSObjectProtocol {
        #[cfg(feature = "BADownload")]
        #[optional]
        #[method(downloadDidBegin:)]
        unsafe fn downloadDidBegin(&self, download: &BADownload);

        #[cfg(feature = "BADownload")]
        #[optional]
        #[method(downloadDidPause:)]
        unsafe fn downloadDidPause(&self, download: &BADownload);

        #[cfg(feature = "BADownload")]
        #[optional]
        #[method(download:didWriteBytes:totalBytesWritten:totalBytesExpectedToWrite:)]
        unsafe fn download_didWriteBytes_totalBytesWritten_totalBytesExpectedToWrite(
            &self,
            download: &BADownload,
            bytes_written: i64,
            total_bytes_written: i64,
            total_expected_bytes: i64,
        );

        #[cfg(all(feature = "BADownload", feature = "block2"))]
        #[optional]
        #[method(download:didReceiveChallenge:completionHandler:)]
        unsafe fn download_didReceiveChallenge_completionHandler(
            &self,
            download: &BADownload,
            challenge: &NSURLAuthenticationChallenge,
            completion_handler: &block2::Block<
                dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
            >,
        );

        #[cfg(feature = "BADownload")]
        #[optional]
        #[method(download:failedWithError:)]
        unsafe fn download_failedWithError(&self, download: &BADownload, error: &NSError);

        #[cfg(feature = "BADownload")]
        #[optional]
        #[method(download:finishedWithFileURL:)]
        unsafe fn download_finishedWithFileURL(&self, download: &BADownload, file_url: &NSURL);
    }

    unsafe impl ProtocolType for dyn BADownloadManagerDelegate {}
);

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

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

unsafe impl NSObjectProtocol for BADownloadManager {}

extern_methods!(
    unsafe impl BADownloadManager {
        #[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>;

        #[method_id(@__retain_semantics Other sharedManager)]
        pub unsafe fn sharedManager() -> Retained<BADownloadManager>;

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn BADownloadManagerDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn BADownloadManagerDelegate>>,
        );

        #[cfg(feature = "BADownload")]
        #[method_id(@__retain_semantics Other fetchCurrentDownloads:_)]
        pub unsafe fn fetchCurrentDownloads(
            &self,
        ) -> Result<Retained<NSArray<BADownload>>, Retained<NSError>>;

        #[cfg(all(feature = "BADownload", feature = "block2"))]
        #[method(fetchCurrentDownloadsWithCompletionHandler:)]
        pub unsafe fn fetchCurrentDownloadsWithCompletionHandler(
            &self,
            completion_handler: &block2::Block<dyn Fn(NonNull<NSArray<BADownload>>, *mut NSError)>,
        );

        #[cfg(feature = "BADownload")]
        #[method(scheduleDownload:error:_)]
        pub unsafe fn scheduleDownload_error(
            &self,
            download: &BADownload,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "block2")]
        #[method(performWithExclusiveControl:)]
        pub unsafe fn performWithExclusiveControl(
            &self,
            perform_handler: &block2::Block<dyn Fn(Bool, *mut NSError)>,
        );

        #[cfg(feature = "block2")]
        #[method(performWithExclusiveControlBeforeDate:performHandler:)]
        pub unsafe fn performWithExclusiveControlBeforeDate_performHandler(
            &self,
            date: &NSDate,
            perform_handler: &block2::Block<dyn Fn(Bool, *mut NSError)>,
        );

        #[cfg(feature = "BADownload")]
        #[method(startForegroundDownload:error:_)]
        pub unsafe fn startForegroundDownload_error(
            &self,
            download: &BADownload,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "BADownload")]
        #[method(cancelDownload:error:_)]
        pub unsafe fn cancelDownload_error(
            &self,
            download: &BADownload,
        ) -> Result<(), Retained<NSError>>;
    }
);