objc2_watch_kit/generated/
WKBackgroundTask.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    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkrefreshbackgroundtask?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct WKRefreshBackgroundTask;
15);
16
17unsafe impl Send for WKRefreshBackgroundTask {}
18
19unsafe impl Sync for WKRefreshBackgroundTask {}
20
21extern_conformance!(
22    unsafe impl NSObjectProtocol for WKRefreshBackgroundTask {}
23);
24
25impl WKRefreshBackgroundTask {
26    extern_methods!(
27        #[unsafe(method(userInfo))]
28        #[unsafe(method_family = none)]
29        pub unsafe fn userInfo(
30            &self,
31        ) -> Option<Retained<AnyObject /* NSSecureCoding+ NSObjectProtocol */>>;
32
33        #[cfg(feature = "block2")]
34        /// A handler called shortly before the task’s background time expires.
35        ///
36        /// The expiration handler takes no arguments and has no return value. Use the handler to cancel any ongoing work and to do any required cleanup in as short a time as possible.
37        /// The handler may be called before the background process uses the full amount of its allocated time.
38        ///
39        /// Example usage:
40        ///
41        /// ```text
42        ///  func handle(backgroundTasks: Set<WKRefreshBackgroundTask>) {
43        ///      for task in backgroundTasks {
44        ///          startBackgroundWork()
45        ///          task.expirationHandler = {
46        ///              cancelExistingWork()
47        ///              task.setTaskCompleted()
48        ///              ...
49        ///          }
50        ///      }
51        ///  }
52        /// ```
53        #[unsafe(method(expirationHandler))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn expirationHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;
56
57        #[cfg(feature = "block2")]
58        /// Setter for [`expirationHandler`][Self::expirationHandler].
59        #[unsafe(method(setExpirationHandler:))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn setExpirationHandler(
62            &self,
63            expiration_handler: Option<&block2::DynBlock<dyn Fn()>>,
64        );
65
66        #[deprecated = "Use -setTaskCompletedWithSnapshot: instead, pass NO to duplicate existing behavior"]
67        #[unsafe(method(setTaskCompleted))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn setTaskCompleted(&self);
70
71        #[unsafe(method(setTaskCompletedWithSnapshot:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setTaskCompletedWithSnapshot(&self, refresh_snapshot: bool);
74    );
75}
76
77/// Methods declared on superclass `NSObject`.
78impl WKRefreshBackgroundTask {
79    extern_methods!(
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        #[unsafe(method(new))]
85        #[unsafe(method_family = new)]
86        pub unsafe fn new() -> Retained<Self>;
87    );
88}
89
90extern_class!(
91    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationrefreshbackgroundtask?language=objc)
92    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
93    #[derive(Debug, PartialEq, Eq, Hash)]
94    pub struct WKApplicationRefreshBackgroundTask;
95);
96
97extern_conformance!(
98    unsafe impl NSObjectProtocol for WKApplicationRefreshBackgroundTask {}
99);
100
101impl WKApplicationRefreshBackgroundTask {
102    extern_methods!();
103}
104
105/// Methods declared on superclass `NSObject`.
106impl WKApplicationRefreshBackgroundTask {
107    extern_methods!(
108        #[unsafe(method(init))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
111
112        #[unsafe(method(new))]
113        #[unsafe(method_family = new)]
114        pub unsafe fn new() -> Retained<Self>;
115    );
116}
117
118/// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wksnapshotreason?language=objc)
119// NS_ENUM
120#[repr(transparent)]
121#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
122pub struct WKSnapshotReason(pub NSInteger);
123impl WKSnapshotReason {
124    #[doc(alias = "WKSnapshotReasonAppScheduled")]
125    pub const AppScheduled: Self = Self(0);
126    #[doc(alias = "WKSnapshotReasonReturnToDefaultState")]
127    pub const ReturnToDefaultState: Self = Self(1);
128    #[doc(alias = "WKSnapshotReasonComplicationUpdate")]
129    pub const ComplicationUpdate: Self = Self(2);
130    #[doc(alias = "WKSnapshotReasonPrelaunch")]
131    pub const Prelaunch: Self = Self(3);
132    #[doc(alias = "WKSnapshotReasonAppBackgrounded")]
133    pub const AppBackgrounded: Self = Self(4);
134}
135
136unsafe impl Encode for WKSnapshotReason {
137    const ENCODING: Encoding = NSInteger::ENCODING;
138}
139
140unsafe impl RefEncode for WKSnapshotReason {
141    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
142}
143
144extern_class!(
145    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wksnapshotrefreshbackgroundtask?language=objc)
146    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
147    #[derive(Debug, PartialEq, Eq, Hash)]
148    pub struct WKSnapshotRefreshBackgroundTask;
149);
150
151extern_conformance!(
152    unsafe impl NSObjectProtocol for WKSnapshotRefreshBackgroundTask {}
153);
154
155impl WKSnapshotRefreshBackgroundTask {
156    extern_methods!(
157        #[deprecated = "Use reasonForSnapshot instead, WKSnapshotReasonReturnToPrimaryUI is equivalent to returnToDefaultState=true"]
158        #[unsafe(method(returnToDefaultState))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn returnToDefaultState(&self) -> bool;
161
162        #[unsafe(method(reasonForSnapshot))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn reasonForSnapshot(&self) -> WKSnapshotReason;
165
166        /// # Safety
167        ///
168        /// `user_info` should be of the correct type.
169        #[unsafe(method(setTaskCompletedWithDefaultStateRestored:estimatedSnapshotExpiration:userInfo:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setTaskCompletedWithDefaultStateRestored_estimatedSnapshotExpiration_userInfo(
172            &self,
173            restored_default_state: bool,
174            estimated_snapshot_expiration: Option<&NSDate>,
175            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
176        );
177    );
178}
179
180/// Methods declared on superclass `NSObject`.
181impl WKSnapshotRefreshBackgroundTask {
182    extern_methods!(
183        #[unsafe(method(init))]
184        #[unsafe(method_family = init)]
185        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
186
187        #[unsafe(method(new))]
188        #[unsafe(method_family = new)]
189        pub unsafe fn new() -> Retained<Self>;
190    );
191}
192
193extern_class!(
194    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkurlsessionrefreshbackgroundtask?language=objc)
195    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
196    #[derive(Debug, PartialEq, Eq, Hash)]
197    pub struct WKURLSessionRefreshBackgroundTask;
198);
199
200extern_conformance!(
201    unsafe impl NSObjectProtocol for WKURLSessionRefreshBackgroundTask {}
202);
203
204impl WKURLSessionRefreshBackgroundTask {
205    extern_methods!(
206        #[unsafe(method(sessionIdentifier))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn sessionIdentifier(&self) -> Retained<NSString>;
209    );
210}
211
212/// Methods declared on superclass `NSObject`.
213impl WKURLSessionRefreshBackgroundTask {
214    extern_methods!(
215        #[unsafe(method(init))]
216        #[unsafe(method_family = init)]
217        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
218
219        #[unsafe(method(new))]
220        #[unsafe(method_family = new)]
221        pub unsafe fn new() -> Retained<Self>;
222    );
223}
224
225extern_class!(
226    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkwatchconnectivityrefreshbackgroundtask?language=objc)
227    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
228    #[derive(Debug, PartialEq, Eq, Hash)]
229    pub struct WKWatchConnectivityRefreshBackgroundTask;
230);
231
232extern_conformance!(
233    unsafe impl NSObjectProtocol for WKWatchConnectivityRefreshBackgroundTask {}
234);
235
236impl WKWatchConnectivityRefreshBackgroundTask {
237    extern_methods!();
238}
239
240/// Methods declared on superclass `NSObject`.
241impl WKWatchConnectivityRefreshBackgroundTask {
242    extern_methods!(
243        #[unsafe(method(init))]
244        #[unsafe(method_family = init)]
245        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
246
247        #[unsafe(method(new))]
248        #[unsafe(method_family = new)]
249        pub unsafe fn new() -> Retained<Self>;
250    );
251}
252
253extern_class!(
254    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkrelevantshortcutrefreshbackgroundtask?language=objc)
255    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
256    #[derive(Debug, PartialEq, Eq, Hash)]
257    pub struct WKRelevantShortcutRefreshBackgroundTask;
258);
259
260extern_conformance!(
261    unsafe impl NSObjectProtocol for WKRelevantShortcutRefreshBackgroundTask {}
262);
263
264impl WKRelevantShortcutRefreshBackgroundTask {
265    extern_methods!();
266}
267
268/// Methods declared on superclass `NSObject`.
269impl WKRelevantShortcutRefreshBackgroundTask {
270    extern_methods!(
271        #[unsafe(method(init))]
272        #[unsafe(method_family = init)]
273        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
274
275        #[unsafe(method(new))]
276        #[unsafe(method_family = new)]
277        pub unsafe fn new() -> Retained<Self>;
278    );
279}
280
281extern_class!(
282    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkintentdidrunrefreshbackgroundtask?language=objc)
283    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
284    #[derive(Debug, PartialEq, Eq, Hash)]
285    pub struct WKIntentDidRunRefreshBackgroundTask;
286);
287
288extern_conformance!(
289    unsafe impl NSObjectProtocol for WKIntentDidRunRefreshBackgroundTask {}
290);
291
292impl WKIntentDidRunRefreshBackgroundTask {
293    extern_methods!();
294}
295
296/// Methods declared on superclass `NSObject`.
297impl WKIntentDidRunRefreshBackgroundTask {
298    extern_methods!(
299        #[unsafe(method(init))]
300        #[unsafe(method_family = init)]
301        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
302
303        #[unsafe(method(new))]
304        #[unsafe(method_family = new)]
305        pub unsafe fn new() -> Retained<Self>;
306    );
307}
308
309extern_class!(
310    /// Updates from Bluetooth are available to the application.
311    /// Register a CBCentralManagerDelegate to receive the updates,
312    /// and then call this task's completion handler.
313    ///
314    /// See also [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkbluetoothalertrefreshbackgroundtask?language=objc)
315    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
316    #[derive(Debug, PartialEq, Eq, Hash)]
317    pub struct WKBluetoothAlertRefreshBackgroundTask;
318);
319
320extern_conformance!(
321    unsafe impl NSObjectProtocol for WKBluetoothAlertRefreshBackgroundTask {}
322);
323
324impl WKBluetoothAlertRefreshBackgroundTask {
325    extern_methods!();
326}
327
328/// Methods declared on superclass `NSObject`.
329impl WKBluetoothAlertRefreshBackgroundTask {
330    extern_methods!(
331        #[unsafe(method(init))]
332        #[unsafe(method_family = init)]
333        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
334
335        #[unsafe(method(new))]
336        #[unsafe(method_family = new)]
337        pub unsafe fn new() -> Retained<Self>;
338    );
339}
340
341/// WKBackgroundTasks.
342#[cfg(feature = "WKExtension")]
343impl WKExtension {
344    extern_methods!(
345        #[cfg(feature = "block2")]
346        /// # Safety
347        ///
348        /// `user_info` should be of the correct type.
349        #[unsafe(method(scheduleBackgroundRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
350        #[unsafe(method_family = none)]
351        pub unsafe fn scheduleBackgroundRefreshWithPreferredDate_userInfo_scheduledCompletion(
352            &self,
353            preferred_fire_date: &NSDate,
354            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
355            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
356        );
357
358        #[cfg(feature = "block2")]
359        /// # Safety
360        ///
361        /// `user_info` should be of the correct type.
362        #[unsafe(method(scheduleSnapshotRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
363        #[unsafe(method_family = none)]
364        pub unsafe fn scheduleSnapshotRefreshWithPreferredDate_userInfo_scheduledCompletion(
365            &self,
366            preferred_fire_date: &NSDate,
367            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
368            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
369        );
370    );
371}
372
373/// WKBackgroundTasks.
374#[cfg(feature = "WKApplication")]
375impl WKApplication {
376    extern_methods!(
377        #[cfg(feature = "block2")]
378        /// # Safety
379        ///
380        /// `user_info` should be of the correct type.
381        #[unsafe(method(scheduleBackgroundRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn scheduleBackgroundRefreshWithPreferredDate_userInfo_scheduledCompletion(
384            &self,
385            preferred_fire_date: &NSDate,
386            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
387            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
388        );
389
390        #[cfg(feature = "block2")]
391        /// # Safety
392        ///
393        /// `user_info` should be of the correct type.
394        #[unsafe(method(scheduleSnapshotRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
395        #[unsafe(method_family = none)]
396        pub unsafe fn scheduleSnapshotRefreshWithPreferredDate_userInfo_scheduledCompletion(
397            &self,
398            preferred_fire_date: &NSDate,
399            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
400            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
401        );
402    );
403}