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 Send for BADownload {}
73
74unsafe impl Sync for BADownload {}
75
76extern_conformance!(
77    unsafe impl NSCoding for BADownload {}
78);
79
80extern_conformance!(
81    unsafe impl NSCopying for BADownload {}
82);
83
84unsafe impl CopyingHelper for BADownload {
85    type Result = Self;
86}
87
88extern_conformance!(
89    unsafe impl NSObjectProtocol for BADownload {}
90);
91
92extern_conformance!(
93    unsafe impl NSSecureCoding for BADownload {}
94);
95
96impl BADownload {
97    extern_methods!(
98        /// The current state of the respresented download.
99        ///
100        /// This property is not atomic.
101        ///
102        /// # Safety
103        ///
104        /// This might not be thread-safe.
105        #[unsafe(method(state))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn state(&self) -> BADownloadState;
108
109        /// A client defined identifier that uniquely identifies this asset.
110        ///
111        /// This property is not atomic.
112        ///
113        /// # Safety
114        ///
115        /// This might not be thread-safe.
116        #[unsafe(method(identifier))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn identifier(&self) -> Retained<NSString>;
119
120        /// A UUID that uniquely identifies the download object.
121        ///
122        /// This property is not atomic.
123        ///
124        /// # Safety
125        ///
126        /// This might not be thread-safe.
127        #[unsafe(method(uniqueIdentifier))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSString>;
130
131        /// A client set priority to try to order downloads in order of importance
132        #[unsafe(method(priority))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn priority(&self) -> BADownloaderPriority;
135
136        /// Whether this download is essential.
137        /// Essential downloads will occur while the app is being installed. Users cannot launch the app while these downloads are occurring.
138        /// Essential downloads cannot be scheduled with `BADownloadManager`, they may only be scheduled from the extension with
139        /// a `BAContentRequest` type of `Update` or `Install`.
140        /// Essential downloads must have an accurate `fileSize` or they will fail.
141        #[unsafe(method(isEssential))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn isEssential(&self) -> bool;
144
145        /// Copies an existing download ensuring that it has `isEssential == false`.
146        ///
147        /// This serves as a convenience method for constructing a non-essential representation of an existing
148        /// download. It is important to note that essential downloads can only be enqueued by
149        /// the app extension during a content request. If an essential download fails, `copyAsNonEssential`
150        /// can be used to create a copy with `isEssential == false` that can be re-queued with `BADownloadManager`.
151        #[unsafe(method(copyAsNonEssential))]
152        #[unsafe(method_family = copy)]
153        pub unsafe fn copyAsNonEssential(&self) -> Retained<Self>;
154
155        #[unsafe(method(init))]
156        #[unsafe(method_family = init)]
157        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
158
159        #[unsafe(method(new))]
160        #[unsafe(method_family = new)]
161        pub unsafe fn new() -> Retained<Self>;
162    );
163}