objc2_background_assets/generated/
BADownload.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloadstate?language=objc)
10// NS_ENUM
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct BADownloadState(pub NSInteger);
14impl BADownloadState {
15    #[doc(alias = "BADownloadStateFailed")]
16    pub const Failed: Self = Self(-1);
17    #[doc(alias = "BADownloadStateCreated")]
18    pub const Created: Self = Self(0);
19    #[doc(alias = "BADownloadStateWaiting")]
20    pub const Waiting: Self = Self(1);
21    #[doc(alias = "BADownloadStateDownloading")]
22    pub const Downloading: Self = Self(2);
23    #[doc(alias = "BADownloadStateFinished")]
24    pub const Finished: Self = Self(3);
25}
26
27unsafe impl Encode for BADownloadState {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for BADownloadState {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35/// A download's priority
36///
37/// The priority applied to a given download or group of downloads. This is a range from `BADownloaderPriorityMin` to `BADownloaderPriorityMax`.
38/// The priority only applies to how downloads are ordered for your application. Higher priority items will be enqued for download before lower priority items regardless of order in which they are scheduled.
39///
40/// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloaderpriority?language=objc)
41// NS_TYPED_EXTENSIBLE_ENUM
42pub type BADownloaderPriority = NSInteger;
43
44extern "C" {
45    /// A value that represents the lowest priority for a download.
46    ///
47    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloaderprioritymin?language=objc)
48    pub static BADownloaderPriorityMin: BADownloaderPriority;
49}
50
51extern "C" {
52    /// A value that represents average priority for a download.
53    ///
54    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloaderprioritydefault?language=objc)
55    pub static BADownloaderPriorityDefault: BADownloaderPriority;
56}
57
58extern "C" {
59    /// A value that represents the highest priority for a download.
60    ///
61    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownloaderprioritymax?language=objc)
62    pub static BADownloaderPriorityMax: BADownloaderPriority;
63}
64
65extern_class!(
66    /// [Apple's documentation](https://developer.apple.com/documentation/backgroundassets/badownload?language=objc)
67    #[unsafe(super(NSObject))]
68    #[derive(Debug, PartialEq, Eq, Hash)]
69    pub struct BADownload;
70);
71
72unsafe impl NSCoding for BADownload {}
73
74unsafe impl NSCopying for BADownload {}
75
76unsafe impl CopyingHelper for BADownload {
77    type Result = Self;
78}
79
80unsafe impl NSObjectProtocol for BADownload {}
81
82unsafe impl NSSecureCoding for BADownload {}
83
84impl BADownload {
85    extern_methods!(
86        /// The current state of the respresented download.
87        #[unsafe(method(state))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn state(&self) -> BADownloadState;
90
91        /// A client defined identifier that uniquely identifies this asset.
92        #[unsafe(method(identifier))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn identifier(&self) -> Retained<NSString>;
95
96        /// A UUID that uniquely identifies the download object.
97        #[unsafe(method(uniqueIdentifier))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSString>;
100
101        /// A client set priority to try to order downloads in order of importance
102        #[unsafe(method(priority))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn priority(&self) -> BADownloaderPriority;
105
106        /// Whether this download is essential.
107        /// Essential downloads will occur while the app is being installed. Users cannot launch the app while these downloads are occurring.
108        /// Essential downloads cannot be scheduled with `BADownloadManager`, they may only be scheduled from the extension with
109        /// a `BAContentRequest` type of `Update` or `Install`.
110        /// Essential downloads must have an accurate `fileSize` or they will fail.
111        #[unsafe(method(isEssential))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn isEssential(&self) -> bool;
114
115        /// Copies an existing download ensuring that it has `isEssential == false`.
116        ///
117        /// This serves as a convenience method for constructing a non-essential representation of an existing
118        /// download. It is important to note that essential downloads can only be enqueued by
119        /// the app extension during a content request. If an essential download fails, `copyAsNonEssential`
120        /// can be used to create a copy with `isEssential == false` that can be re-queued with `BADownloadManager`.
121        #[unsafe(method(copyAsNonEssential))]
122        #[unsafe(method_family = copy)]
123        pub unsafe fn copyAsNonEssential(&self) -> Retained<Self>;
124
125        #[unsafe(method(init))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
128
129        #[unsafe(method(new))]
130        #[unsafe(method_family = new)]
131        pub unsafe fn new() -> Retained<Self>;
132    );
133}