objc2_background_assets/generated/
BADownloaderExtension.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloaderextension?language=objc)
12    pub unsafe trait BADownloaderExtension: NSObjectProtocol {
13        #[cfg(all(
14            feature = "BAAppExtensionInfo",
15            feature = "BADownload",
16            feature = "BATypes"
17        ))]
18        /// Invoked by the system when the extension should check for updated content.
19        ///
20        /// This method will be invoked by the system upon requested events defined in `BAContentRequest`.
21        /// This method should return a set of all `BAURLDownload`'s that your extension would like to schedule.
22        /// During the invocation of this method, `BADownloadManager` will prohibit the ability to schedule additional downloads
23        /// until this method exits scope. Therefore, all downloads needing to be scheduled should be returned here.
24        /// If a download fails, it can be rescheduled using `BADownloadManager` in any other method in this protocol.
25        ///
26        /// Parameter `contentRequest`: The content request event that occurred that caused this method to be invoked.
27        ///
28        /// Parameter `manifestURL`: A file URL to the local manifest that was pre-downloaded and specified in your App's Info.plist under the `BAManifestURL`.
29        /// The file is read-only and will be deleted after this method returns. If you wish to keep it, you must copy it out.
30        ///
31        /// Parameter `extensionInfo`: Information about your extension that may be useful for making a decision about
32        /// what content needs to be scheduled.
33        ///
34        /// Returns: A set of unique `BAURLDownload` objects that the extension should schedule for download.
35        ///
36        /// Warning: You cannot use `BADownloadManager` to manually schedule downloads using this method. All downloads to enqueue must be returned.
37        #[optional]
38        #[unsafe(method(downloadsForRequest:manifestURL:extensionInfo:))]
39        #[unsafe(method_family = none)]
40        unsafe fn downloadsForRequest_manifestURL_extensionInfo(
41            &self,
42            content_request: BAContentRequest,
43            manifest_url: &NSURL,
44            extension_info: &BAAppExtensionInfo,
45        ) -> Retained<NSSet<BADownload>>;
46
47        #[cfg(all(feature = "BADownload", feature = "block2"))]
48        /// Download is about to begin but requires an authentication challenge to continue.
49        ///
50        /// # Safety
51        ///
52        /// `completion_handler` block must be sendable.
53        #[optional]
54        #[unsafe(method(backgroundDownload:didReceiveChallenge:completionHandler:))]
55        #[unsafe(method_family = none)]
56        unsafe fn backgroundDownload_didReceiveChallenge_completionHandler(
57            &self,
58            download: &BADownload,
59            challenge: &NSURLAuthenticationChallenge,
60            completion_handler: &block2::DynBlock<
61                dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
62            >,
63        );
64
65        #[cfg(feature = "BADownload")]
66        /// This method is called when a download has failed but there is no `BADownloadManager` delegate to handle the completion event.
67        ///
68        /// When a download has failed, this method will be invoked.
69        /// If a download fails you may reschedule it with `BADownloadManager`.
70        ///
71        /// Parameter `download`: The download object that has failed.
72        ///
73        /// Parameter `error`: The error that caused the failure.
74        #[optional]
75        #[unsafe(method(backgroundDownload:failedWithError:))]
76        #[unsafe(method_family = none)]
77        unsafe fn backgroundDownload_failedWithError(&self, download: &BADownload, error: &NSError);
78
79        #[cfg(feature = "BADownload")]
80        /// This method is called when a download has finished but there is no `BADownloadManager` delegate to handle the completion event.
81        ///
82        /// Parameter `download`: Download that has completed successfully.
83        ///
84        /// Parameter `fileURL`: A location to the file that has been downloaded.
85        ///
86        /// When a download succeeds, this method will be invoked; however it is only invoked if there is no other client using `BADownloadManager`
87        /// with a hooked in `delegate`. The file located at `fileURL` must be moved before this method exits scope, or it will be deleted.
88        /// It is strongly advised to move the file to its permanent destination rather than copy it.
89        ///
90        /// Warning: The file is marked by the system for deletion when the device becomes low on storage. Avoid copying or modifying
91        /// the file, as this may remove the system's ability to delete the file.
92        #[optional]
93        #[unsafe(method(backgroundDownload:finishedWithFileURL:))]
94        #[unsafe(method_family = none)]
95        unsafe fn backgroundDownload_finishedWithFileURL(
96            &self,
97            download: &BADownload,
98            file_url: &NSURL,
99        );
100
101        /// This method may be called shortly before the extension is terminated.
102        ///
103        /// This method is invoked if all extension callbacks have returned or if the extension has run over its allotted runtime.
104        /// This callback provides a last chance to tidy up state before process termination.
105        ///
106        /// Warning: This method is advisory only, there will be instances where the extension is terminated before this method is invoked.
107        /// Do not rely on this method being invoked before the extension is terminated.
108        #[deprecated = "extensionWillTerminate will not be invoked in all applicable circumstances and should not be relied upon."]
109        #[optional]
110        #[unsafe(method(extensionWillTerminate))]
111        #[unsafe(method_family = none)]
112        unsafe fn extensionWillTerminate(&self);
113    }
114);