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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloaderextension?language=objc)
pub unsafe trait BADownloaderExtension: NSObjectProtocol {
#[cfg(all(
feature = "BAAppExtensionInfo",
feature = "BADownload",
feature = "BATypes"
))]
/// Invoked by the system when the extension should check for updated content.
///
/// This method will be invoked by the system upon requested events defined in `BAContentRequest`.
/// This method should return a set of all `BAURLDownload`'s that your extension would like to schedule.
/// During the invocation of this method, `BADownloadManager` will prohibit the ability to schedule additional downloads
/// until this method exits scope. Therefore, all downloads needing to be scheduled should be returned here.
/// If a download fails, it can be rescheduled using `BADownloadManager` in any other method in this protocol.
///
/// Parameter `contentRequest`: The content request event that occurred that caused this method to be invoked.
///
/// Parameter `manifestURL`: A file URL to the local manifest that was pre-downloaded and specified in your App's Info.plist under the `BAManifestURL`.
/// The file is read-only and will be deleted after this method returns. If you wish to keep it, you must copy it out.
///
/// Parameter `extensionInfo`: Information about your extension that may be useful for making a decision about
/// what content needs to be scheduled.
///
/// Returns: A set of unique `BAURLDownload` objects that the extension should schedule for download.
///
/// Warning: You cannot use `BADownloadManager` to manually schedule downloads using this method. All downloads to enqueue must be returned.
#[optional]
#[unsafe(method(downloadsForRequest:manifestURL:extensionInfo:))]
#[unsafe(method_family = none)]
unsafe fn downloadsForRequest_manifestURL_extensionInfo(
&self,
content_request: BAContentRequest,
manifest_url: &NSURL,
extension_info: &BAAppExtensionInfo,
) -> Retained<NSSet<BADownload>>;
#[cfg(all(feature = "BADownload", feature = "block2"))]
/// Download is about to begin but requires an authentication challenge to continue.
///
/// # Safety
///
/// `completion_handler` block must be sendable.
#[optional]
#[unsafe(method(backgroundDownload:didReceiveChallenge:completionHandler:))]
#[unsafe(method_family = none)]
unsafe fn backgroundDownload_didReceiveChallenge_completionHandler(
&self,
download: &BADownload,
challenge: &NSURLAuthenticationChallenge,
completion_handler: &block2::DynBlock<
dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
>,
);
#[cfg(feature = "BADownload")]
/// This method is called when a download has failed but there is no `BADownloadManager` delegate to handle the completion event.
///
/// When a download has failed, this method will be invoked.
/// If a download fails you may reschedule it with `BADownloadManager`.
///
/// Parameter `download`: The download object that has failed.
///
/// Parameter `error`: The error that caused the failure.
#[optional]
#[unsafe(method(backgroundDownload:failedWithError:))]
#[unsafe(method_family = none)]
unsafe fn backgroundDownload_failedWithError(&self, download: &BADownload, error: &NSError);
#[cfg(feature = "BADownload")]
/// This method is called when a download has finished but there is no `BADownloadManager` delegate to handle the completion event.
///
/// Parameter `download`: Download that has completed successfully.
///
/// Parameter `fileURL`: A location to the file that has been downloaded.
///
/// When a download succeeds, this method will be invoked; however it is only invoked if there is no other client using `BADownloadManager`
/// with a hooked in `delegate`. The file located at `fileURL` must be moved before this method exits scope, or it will be deleted.
/// It is strongly advised to move the file to its permanent destination rather than copy it.
///
/// Warning: The file is marked by the system for deletion when the device becomes low on storage. Avoid copying or modifying
/// the file, as this may remove the system's ability to delete the file.
#[optional]
#[unsafe(method(backgroundDownload:finishedWithFileURL:))]
#[unsafe(method_family = none)]
unsafe fn backgroundDownload_finishedWithFileURL(
&self,
download: &BADownload,
file_url: &NSURL,
);
/// This method may be called shortly before the extension is terminated.
///
/// This method is invoked if all extension callbacks have returned or if the extension has run over its allotted runtime.
/// This callback provides a last chance to tidy up state before process termination.
///
/// Warning: This method is advisory only, there will be instances where the extension is terminated before this method is invoked.
/// Do not rely on this method being invoked before the extension is terminated.
#[deprecated = "extensionWillTerminate will not be invoked in all applicable circumstances and should not be relied upon."]
#[optional]
#[unsafe(method(extensionWillTerminate))]
#[unsafe(method_family = none)]
unsafe fn extensionWillTerminate(&self);
}
);