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        #[unsafe(method(setTaskCompletedWithDefaultStateRestored:estimatedSnapshotExpiration:userInfo:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setTaskCompletedWithDefaultStateRestored_estimatedSnapshotExpiration_userInfo(
169            &self,
170            restored_default_state: bool,
171            estimated_snapshot_expiration: Option<&NSDate>,
172            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
173        );
174    );
175}
176
177/// Methods declared on superclass `NSObject`.
178impl WKSnapshotRefreshBackgroundTask {
179    extern_methods!(
180        #[unsafe(method(init))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
183
184        #[unsafe(method(new))]
185        #[unsafe(method_family = new)]
186        pub unsafe fn new() -> Retained<Self>;
187    );
188}
189
190extern_class!(
191    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkurlsessionrefreshbackgroundtask?language=objc)
192    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
193    #[derive(Debug, PartialEq, Eq, Hash)]
194    pub struct WKURLSessionRefreshBackgroundTask;
195);
196
197extern_conformance!(
198    unsafe impl NSObjectProtocol for WKURLSessionRefreshBackgroundTask {}
199);
200
201impl WKURLSessionRefreshBackgroundTask {
202    extern_methods!(
203        #[unsafe(method(sessionIdentifier))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn sessionIdentifier(&self) -> Retained<NSString>;
206    );
207}
208
209/// Methods declared on superclass `NSObject`.
210impl WKURLSessionRefreshBackgroundTask {
211    extern_methods!(
212        #[unsafe(method(init))]
213        #[unsafe(method_family = init)]
214        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
215
216        #[unsafe(method(new))]
217        #[unsafe(method_family = new)]
218        pub unsafe fn new() -> Retained<Self>;
219    );
220}
221
222extern_class!(
223    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkwatchconnectivityrefreshbackgroundtask?language=objc)
224    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
225    #[derive(Debug, PartialEq, Eq, Hash)]
226    pub struct WKWatchConnectivityRefreshBackgroundTask;
227);
228
229extern_conformance!(
230    unsafe impl NSObjectProtocol for WKWatchConnectivityRefreshBackgroundTask {}
231);
232
233impl WKWatchConnectivityRefreshBackgroundTask {
234    extern_methods!();
235}
236
237/// Methods declared on superclass `NSObject`.
238impl WKWatchConnectivityRefreshBackgroundTask {
239    extern_methods!(
240        #[unsafe(method(init))]
241        #[unsafe(method_family = init)]
242        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
243
244        #[unsafe(method(new))]
245        #[unsafe(method_family = new)]
246        pub unsafe fn new() -> Retained<Self>;
247    );
248}
249
250extern_class!(
251    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkrelevantshortcutrefreshbackgroundtask?language=objc)
252    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
253    #[derive(Debug, PartialEq, Eq, Hash)]
254    pub struct WKRelevantShortcutRefreshBackgroundTask;
255);
256
257extern_conformance!(
258    unsafe impl NSObjectProtocol for WKRelevantShortcutRefreshBackgroundTask {}
259);
260
261impl WKRelevantShortcutRefreshBackgroundTask {
262    extern_methods!();
263}
264
265/// Methods declared on superclass `NSObject`.
266impl WKRelevantShortcutRefreshBackgroundTask {
267    extern_methods!(
268        #[unsafe(method(init))]
269        #[unsafe(method_family = init)]
270        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
271
272        #[unsafe(method(new))]
273        #[unsafe(method_family = new)]
274        pub unsafe fn new() -> Retained<Self>;
275    );
276}
277
278extern_class!(
279    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkintentdidrunrefreshbackgroundtask?language=objc)
280    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
281    #[derive(Debug, PartialEq, Eq, Hash)]
282    pub struct WKIntentDidRunRefreshBackgroundTask;
283);
284
285extern_conformance!(
286    unsafe impl NSObjectProtocol for WKIntentDidRunRefreshBackgroundTask {}
287);
288
289impl WKIntentDidRunRefreshBackgroundTask {
290    extern_methods!();
291}
292
293/// Methods declared on superclass `NSObject`.
294impl WKIntentDidRunRefreshBackgroundTask {
295    extern_methods!(
296        #[unsafe(method(init))]
297        #[unsafe(method_family = init)]
298        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
299
300        #[unsafe(method(new))]
301        #[unsafe(method_family = new)]
302        pub unsafe fn new() -> Retained<Self>;
303    );
304}
305
306extern_class!(
307    /// Updates from Bluetooth are available to the application.
308    /// Register a CBCentralManagerDelegate to receive the updates,
309    /// and then call this task's completion handler.
310    ///
311    /// See also [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkbluetoothalertrefreshbackgroundtask?language=objc)
312    #[unsafe(super(WKRefreshBackgroundTask, NSObject))]
313    #[derive(Debug, PartialEq, Eq, Hash)]
314    pub struct WKBluetoothAlertRefreshBackgroundTask;
315);
316
317extern_conformance!(
318    unsafe impl NSObjectProtocol for WKBluetoothAlertRefreshBackgroundTask {}
319);
320
321impl WKBluetoothAlertRefreshBackgroundTask {
322    extern_methods!();
323}
324
325/// Methods declared on superclass `NSObject`.
326impl WKBluetoothAlertRefreshBackgroundTask {
327    extern_methods!(
328        #[unsafe(method(init))]
329        #[unsafe(method_family = init)]
330        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
331
332        #[unsafe(method(new))]
333        #[unsafe(method_family = new)]
334        pub unsafe fn new() -> Retained<Self>;
335    );
336}
337
338/// WKBackgroundTasks.
339#[cfg(feature = "WKExtension")]
340impl WKExtension {
341    extern_methods!(
342        #[cfg(feature = "block2")]
343        #[unsafe(method(scheduleBackgroundRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn scheduleBackgroundRefreshWithPreferredDate_userInfo_scheduledCompletion(
346            &self,
347            preferred_fire_date: &NSDate,
348            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
349            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
350        );
351
352        #[cfg(feature = "block2")]
353        #[unsafe(method(scheduleSnapshotRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn scheduleSnapshotRefreshWithPreferredDate_userInfo_scheduledCompletion(
356            &self,
357            preferred_fire_date: &NSDate,
358            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
359            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
360        );
361    );
362}
363
364/// WKBackgroundTasks.
365#[cfg(feature = "WKApplication")]
366impl WKApplication {
367    extern_methods!(
368        #[cfg(feature = "block2")]
369        #[unsafe(method(scheduleBackgroundRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn scheduleBackgroundRefreshWithPreferredDate_userInfo_scheduledCompletion(
372            &self,
373            preferred_fire_date: &NSDate,
374            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
375            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
376        );
377
378        #[cfg(feature = "block2")]
379        #[unsafe(method(scheduleSnapshotRefreshWithPreferredDate:userInfo:scheduledCompletion:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn scheduleSnapshotRefreshWithPreferredDate_userInfo_scheduledCompletion(
382            &self,
383            preferred_fire_date: &NSDate,
384            user_info: Option<&AnyObject /* NSSecureCoding+ NSObjectProtocol */>,
385            scheduled_completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
386        );
387    );
388}