objc2_background_tasks/generated/
BGTaskRequest.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_class!(
11    /// An abstract class for representing task requests.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundtasks/bgtaskrequest?language=objc)
14    #[unsafe(super(NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    pub struct BGTaskRequest;
17);
18
19extern_conformance!(
20    unsafe impl NSCopying for BGTaskRequest {}
21);
22
23unsafe impl CopyingHelper for BGTaskRequest {
24    type Result = Self;
25}
26
27extern_conformance!(
28    unsafe impl NSObjectProtocol for BGTaskRequest {}
29);
30
31impl BGTaskRequest {
32    extern_methods!(
33        /// The identifier of the task associated with the request.
34        #[unsafe(method(identifier))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn identifier(&self) -> Retained<NSString>;
37
38        /// The earliest date and time at which to run the task.
39        ///
40        /// Specify `nil` for no start delay.
41        ///
42        /// Setting the property indicates that the background task shouldn’t start any
43        /// earlier than this date. However, the system doesn’t guarantee launching the
44        /// task at the specified date, but only that it won’t begin sooner.
45        #[unsafe(method(earliestBeginDate))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn earliestBeginDate(&self) -> Option<Retained<NSDate>>;
48
49        /// Setter for [`earliestBeginDate`][Self::earliestBeginDate].
50        #[unsafe(method(setEarliestBeginDate:))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn setEarliestBeginDate(&self, earliest_begin_date: Option<&NSDate>);
53
54        #[unsafe(method(init))]
55        #[unsafe(method_family = init)]
56        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
57
58        #[unsafe(method(new))]
59        #[unsafe(method_family = new)]
60        pub unsafe fn new() -> Retained<Self>;
61    );
62}
63
64extern_class!(
65    /// A request to launch your app in the background to execute a short refresh task.
66    ///
67    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundtasks/bgapprefreshtaskrequest?language=objc)
68    #[unsafe(super(BGTaskRequest, NSObject))]
69    #[derive(Debug, PartialEq, Eq, Hash)]
70    pub struct BGAppRefreshTaskRequest;
71);
72
73extern_conformance!(
74    unsafe impl NSCopying for BGAppRefreshTaskRequest {}
75);
76
77unsafe impl CopyingHelper for BGAppRefreshTaskRequest {
78    type Result = Self;
79}
80
81extern_conformance!(
82    unsafe impl NSObjectProtocol for BGAppRefreshTaskRequest {}
83);
84
85impl BGAppRefreshTaskRequest {
86    extern_methods!(
87        /// Return a new refresh task request for the specified identifier.
88        ///
89        /// - Parameters:
90        /// - identifier: The string identifier of the refresh task associated with the request.
91        #[unsafe(method(initWithIdentifier:))]
92        #[unsafe(method_family = init)]
93        pub unsafe fn initWithIdentifier(
94            this: Allocated<Self>,
95            identifier: &NSString,
96        ) -> Retained<Self>;
97    );
98}
99
100/// Methods declared on superclass `BGTaskRequest`.
101impl BGAppRefreshTaskRequest {
102    extern_methods!(
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107        #[unsafe(method(new))]
108        #[unsafe(method_family = new)]
109        pub unsafe fn new() -> Retained<Self>;
110    );
111}
112
113extern_class!(
114    /// A request to launch your app in the background to execute a processing task
115    /// that can take minutes to complete.
116    ///
117    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundtasks/bgprocessingtaskrequest?language=objc)
118    #[unsafe(super(BGTaskRequest, NSObject))]
119    #[derive(Debug, PartialEq, Eq, Hash)]
120    pub struct BGProcessingTaskRequest;
121);
122
123extern_conformance!(
124    unsafe impl NSCopying for BGProcessingTaskRequest {}
125);
126
127unsafe impl CopyingHelper for BGProcessingTaskRequest {
128    type Result = Self;
129}
130
131extern_conformance!(
132    unsafe impl NSObjectProtocol for BGProcessingTaskRequest {}
133);
134
135impl BGProcessingTaskRequest {
136    extern_methods!(
137        /// Return a new processing task request for the specified identifier.
138        ///
139        /// - Parameters:
140        /// - identifier: The string identifier of the processing task associated with the request.
141        #[unsafe(method(initWithIdentifier:))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn initWithIdentifier(
144            this: Allocated<Self>,
145            identifier: &NSString,
146        ) -> Retained<Self>;
147
148        /// A Boolean specifying if the processing task requires network connectivity.
149        #[unsafe(method(requiresNetworkConnectivity))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn requiresNetworkConnectivity(&self) -> bool;
152
153        /// Setter for [`requiresNetworkConnectivity`][Self::requiresNetworkConnectivity].
154        #[unsafe(method(setRequiresNetworkConnectivity:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn setRequiresNetworkConnectivity(&self, requires_network_connectivity: bool);
157
158        /// A Boolean specifying if the processing task requires a device connected to power.
159        #[unsafe(method(requiresExternalPower))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn requiresExternalPower(&self) -> bool;
162
163        /// Setter for [`requiresExternalPower`][Self::requiresExternalPower].
164        #[unsafe(method(setRequiresExternalPower:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setRequiresExternalPower(&self, requires_external_power: bool);
167    );
168}
169
170/// Methods declared on superclass `BGTaskRequest`.
171impl BGProcessingTaskRequest {
172    extern_methods!(
173        #[unsafe(method(init))]
174        #[unsafe(method_family = init)]
175        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
176
177        #[unsafe(method(new))]
178        #[unsafe(method_family = new)]
179        pub unsafe fn new() -> Retained<Self>;
180    );
181}
182
183extern_class!(
184    /// A request to launch your app in the background to execute a health research task for studies a user has opted into and
185    /// that can take minutes to complete.
186    ///
187    /// See also [Apple's documentation](https://developer.apple.com/documentation/backgroundtasks/bghealthresearchtaskrequest?language=objc)
188    #[unsafe(super(BGProcessingTaskRequest, BGTaskRequest, NSObject))]
189    #[derive(Debug, PartialEq, Eq, Hash)]
190    pub struct BGHealthResearchTaskRequest;
191);
192
193extern_conformance!(
194    unsafe impl NSCopying for BGHealthResearchTaskRequest {}
195);
196
197unsafe impl CopyingHelper for BGHealthResearchTaskRequest {
198    type Result = Self;
199}
200
201extern_conformance!(
202    unsafe impl NSObjectProtocol for BGHealthResearchTaskRequest {}
203);
204
205impl BGHealthResearchTaskRequest {
206    extern_methods!(
207        /// A String indicating file protection availability required for processing.
208        #[unsafe(method(protectionTypeOfRequiredData))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn protectionTypeOfRequiredData(&self) -> Retained<NSFileProtectionType>;
211
212        /// Setter for [`protectionTypeOfRequiredData`][Self::protectionTypeOfRequiredData].
213        #[unsafe(method(setProtectionTypeOfRequiredData:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setProtectionTypeOfRequiredData(
216            &self,
217            protection_type_of_required_data: &NSFileProtectionType,
218        );
219    );
220}
221
222/// Methods declared on superclass `BGProcessingTaskRequest`.
223impl BGHealthResearchTaskRequest {
224    extern_methods!(
225        /// Return a new processing task request for the specified identifier.
226        ///
227        /// - Parameters:
228        /// - identifier: The string identifier of the processing task associated with the request.
229        #[unsafe(method(initWithIdentifier:))]
230        #[unsafe(method_family = init)]
231        pub unsafe fn initWithIdentifier(
232            this: Allocated<Self>,
233            identifier: &NSString,
234        ) -> Retained<Self>;
235    );
236}
237
238/// Methods declared on superclass `BGTaskRequest`.
239impl BGHealthResearchTaskRequest {
240    extern_methods!(
241        #[unsafe(method(init))]
242        #[unsafe(method_family = init)]
243        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
244
245        #[unsafe(method(new))]
246        #[unsafe(method_family = new)]
247        pub unsafe fn new() -> Retained<Self>;
248    );
249}