objc2_foundation/generated/
NSUserActivity.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::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsuseractivitypersistentidentifier?language=objc)
10#[cfg(feature = "NSString")]
11pub type NSUserActivityPersistentIdentifier = NSString;
12
13extern_class!(
14    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsuseractivity?language=objc)
15    #[unsafe(super(NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    pub struct NSUserActivity;
18);
19
20extern_conformance!(
21    unsafe impl NSObjectProtocol for NSUserActivity {}
22);
23
24impl NSUserActivity {
25    extern_methods!(
26        #[cfg(feature = "NSString")]
27        #[unsafe(method(initWithActivityType:))]
28        #[unsafe(method_family = init)]
29        pub fn initWithActivityType(
30            this: Allocated<Self>,
31            activity_type: &NSString,
32        ) -> Retained<Self>;
33
34        #[deprecated = "Use initWithActivityType: with a specific activity type string"]
35        #[unsafe(method(init))]
36        #[unsafe(method_family = init)]
37        pub fn init(this: Allocated<Self>) -> Retained<Self>;
38
39        #[cfg(feature = "NSString")]
40        #[unsafe(method(activityType))]
41        #[unsafe(method_family = none)]
42        pub fn activityType(&self) -> Retained<NSString>;
43
44        #[cfg(feature = "NSString")]
45        #[unsafe(method(title))]
46        #[unsafe(method_family = none)]
47        pub fn title(&self) -> Option<Retained<NSString>>;
48
49        #[cfg(feature = "NSString")]
50        /// Setter for [`title`][Self::title].
51        ///
52        /// This is [copied][crate::NSCopying::copy] when set.
53        #[unsafe(method(setTitle:))]
54        #[unsafe(method_family = none)]
55        pub fn setTitle(&self, title: Option<&NSString>);
56
57        #[cfg(feature = "NSDictionary")]
58        #[unsafe(method(userInfo))]
59        #[unsafe(method_family = none)]
60        pub fn userInfo(&self) -> Option<Retained<NSDictionary>>;
61
62        #[cfg(feature = "NSDictionary")]
63        /// Setter for [`userInfo`][Self::userInfo].
64        ///
65        /// This is [copied][crate::NSCopying::copy] when set.
66        ///
67        /// # Safety
68        ///
69        /// `user_info` generic should be of the correct type.
70        #[unsafe(method(setUserInfo:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setUserInfo(&self, user_info: Option<&NSDictionary>);
73
74        #[cfg(feature = "NSDictionary")]
75        /// # Safety
76        ///
77        /// `other_dictionary` generic should be of the correct type.
78        #[unsafe(method(addUserInfoEntriesFromDictionary:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn addUserInfoEntriesFromDictionary(&self, other_dictionary: &NSDictionary);
81
82        #[cfg(all(feature = "NSSet", feature = "NSString"))]
83        #[unsafe(method(requiredUserInfoKeys))]
84        #[unsafe(method_family = none)]
85        pub fn requiredUserInfoKeys(&self) -> Option<Retained<NSSet<NSString>>>;
86
87        #[cfg(all(feature = "NSSet", feature = "NSString"))]
88        /// Setter for [`requiredUserInfoKeys`][Self::requiredUserInfoKeys].
89        ///
90        /// This is [copied][crate::NSCopying::copy] when set.
91        #[unsafe(method(setRequiredUserInfoKeys:))]
92        #[unsafe(method_family = none)]
93        pub fn setRequiredUserInfoKeys(&self, required_user_info_keys: Option<&NSSet<NSString>>);
94
95        #[unsafe(method(needsSave))]
96        #[unsafe(method_family = none)]
97        pub fn needsSave(&self) -> bool;
98
99        /// Setter for [`needsSave`][Self::needsSave].
100        #[unsafe(method(setNeedsSave:))]
101        #[unsafe(method_family = none)]
102        pub fn setNeedsSave(&self, needs_save: bool);
103
104        #[cfg(feature = "NSURL")]
105        #[unsafe(method(webpageURL))]
106        #[unsafe(method_family = none)]
107        pub fn webpageURL(&self) -> Option<Retained<NSURL>>;
108
109        #[cfg(feature = "NSURL")]
110        /// Setter for [`webpageURL`][Self::webpageURL].
111        ///
112        /// This is [copied][crate::NSCopying::copy] when set.
113        #[unsafe(method(setWebpageURL:))]
114        #[unsafe(method_family = none)]
115        pub fn setWebpageURL(&self, webpage_url: Option<&NSURL>);
116
117        #[cfg(feature = "NSURL")]
118        #[unsafe(method(referrerURL))]
119        #[unsafe(method_family = none)]
120        pub fn referrerURL(&self) -> Option<Retained<NSURL>>;
121
122        #[cfg(feature = "NSURL")]
123        /// Setter for [`referrerURL`][Self::referrerURL].
124        ///
125        /// This is [copied][crate::NSCopying::copy] when set.
126        #[unsafe(method(setReferrerURL:))]
127        #[unsafe(method_family = none)]
128        pub fn setReferrerURL(&self, referrer_url: Option<&NSURL>);
129
130        #[cfg(feature = "NSDate")]
131        #[unsafe(method(expirationDate))]
132        #[unsafe(method_family = none)]
133        pub fn expirationDate(&self) -> Option<Retained<NSDate>>;
134
135        #[cfg(feature = "NSDate")]
136        /// Setter for [`expirationDate`][Self::expirationDate].
137        ///
138        /// This is [copied][crate::NSCopying::copy] when set.
139        #[unsafe(method(setExpirationDate:))]
140        #[unsafe(method_family = none)]
141        pub fn setExpirationDate(&self, expiration_date: Option<&NSDate>);
142
143        #[cfg(all(feature = "NSSet", feature = "NSString"))]
144        #[unsafe(method(keywords))]
145        #[unsafe(method_family = none)]
146        pub fn keywords(&self) -> Retained<NSSet<NSString>>;
147
148        #[cfg(all(feature = "NSSet", feature = "NSString"))]
149        /// Setter for [`keywords`][Self::keywords].
150        ///
151        /// This is [copied][crate::NSCopying::copy] when set.
152        #[unsafe(method(setKeywords:))]
153        #[unsafe(method_family = none)]
154        pub fn setKeywords(&self, keywords: &NSSet<NSString>);
155
156        #[unsafe(method(supportsContinuationStreams))]
157        #[unsafe(method_family = none)]
158        pub fn supportsContinuationStreams(&self) -> bool;
159
160        /// Setter for [`supportsContinuationStreams`][Self::supportsContinuationStreams].
161        #[unsafe(method(setSupportsContinuationStreams:))]
162        #[unsafe(method_family = none)]
163        pub fn setSupportsContinuationStreams(&self, supports_continuation_streams: bool);
164
165        #[unsafe(method(delegate))]
166        #[unsafe(method_family = none)]
167        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSUserActivityDelegate>>>;
168
169        /// Setter for [`delegate`][Self::delegate].
170        ///
171        /// This is a [weak property][objc2::topics::weak_property].
172        #[unsafe(method(setDelegate:))]
173        #[unsafe(method_family = none)]
174        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSUserActivityDelegate>>);
175
176        #[cfg(feature = "NSString")]
177        #[unsafe(method(targetContentIdentifier))]
178        #[unsafe(method_family = none)]
179        pub fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
180
181        #[cfg(feature = "NSString")]
182        /// Setter for [`targetContentIdentifier`][Self::targetContentIdentifier].
183        ///
184        /// This is [copied][crate::NSCopying::copy] when set.
185        #[unsafe(method(setTargetContentIdentifier:))]
186        #[unsafe(method_family = none)]
187        pub fn setTargetContentIdentifier(&self, target_content_identifier: Option<&NSString>);
188
189        #[unsafe(method(becomeCurrent))]
190        #[unsafe(method_family = none)]
191        pub fn becomeCurrent(&self);
192
193        #[unsafe(method(resignCurrent))]
194        #[unsafe(method_family = none)]
195        pub fn resignCurrent(&self);
196
197        #[unsafe(method(invalidate))]
198        #[unsafe(method_family = none)]
199        pub fn invalidate(&self);
200
201        #[cfg(all(feature = "NSError", feature = "NSStream", feature = "block2"))]
202        /// # Safety
203        ///
204        /// `completion_handler` block must be sendable.
205        #[unsafe(method(getContinuationStreamsWithCompletionHandler:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn getContinuationStreamsWithCompletionHandler(
208            &self,
209            completion_handler: &block2::DynBlock<
210                dyn Fn(*mut NSInputStream, *mut NSOutputStream, *mut NSError),
211            >,
212        );
213
214        #[unsafe(method(isEligibleForHandoff))]
215        #[unsafe(method_family = none)]
216        pub fn isEligibleForHandoff(&self) -> bool;
217
218        /// Setter for [`isEligibleForHandoff`][Self::isEligibleForHandoff].
219        #[unsafe(method(setEligibleForHandoff:))]
220        #[unsafe(method_family = none)]
221        pub fn setEligibleForHandoff(&self, eligible_for_handoff: bool);
222
223        #[unsafe(method(isEligibleForSearch))]
224        #[unsafe(method_family = none)]
225        pub fn isEligibleForSearch(&self) -> bool;
226
227        /// Setter for [`isEligibleForSearch`][Self::isEligibleForSearch].
228        #[unsafe(method(setEligibleForSearch:))]
229        #[unsafe(method_family = none)]
230        pub fn setEligibleForSearch(&self, eligible_for_search: bool);
231
232        #[unsafe(method(isEligibleForPublicIndexing))]
233        #[unsafe(method_family = none)]
234        pub fn isEligibleForPublicIndexing(&self) -> bool;
235
236        /// Setter for [`isEligibleForPublicIndexing`][Self::isEligibleForPublicIndexing].
237        #[unsafe(method(setEligibleForPublicIndexing:))]
238        #[unsafe(method_family = none)]
239        pub fn setEligibleForPublicIndexing(&self, eligible_for_public_indexing: bool);
240
241        #[unsafe(method(isEligibleForPrediction))]
242        #[unsafe(method_family = none)]
243        pub fn isEligibleForPrediction(&self) -> bool;
244
245        /// Setter for [`isEligibleForPrediction`][Self::isEligibleForPrediction].
246        #[unsafe(method(setEligibleForPrediction:))]
247        #[unsafe(method_family = none)]
248        pub fn setEligibleForPrediction(&self, eligible_for_prediction: bool);
249
250        #[cfg(feature = "NSString")]
251        #[unsafe(method(persistentIdentifier))]
252        #[unsafe(method_family = none)]
253        pub fn persistentIdentifier(&self) -> Option<Retained<NSUserActivityPersistentIdentifier>>;
254
255        #[cfg(feature = "NSString")]
256        /// Setter for [`persistentIdentifier`][Self::persistentIdentifier].
257        ///
258        /// This is [copied][crate::NSCopying::copy] when set.
259        #[unsafe(method(setPersistentIdentifier:))]
260        #[unsafe(method_family = none)]
261        pub fn setPersistentIdentifier(
262            &self,
263            persistent_identifier: Option<&NSUserActivityPersistentIdentifier>,
264        );
265
266        #[cfg(all(feature = "NSArray", feature = "NSString", feature = "block2"))]
267        /// # Safety
268        ///
269        /// `handler` block must be sendable.
270        #[unsafe(method(deleteSavedUserActivitiesWithPersistentIdentifiers:completionHandler:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn deleteSavedUserActivitiesWithPersistentIdentifiers_completionHandler(
273            persistent_identifiers: &NSArray<NSUserActivityPersistentIdentifier>,
274            handler: &block2::DynBlock<dyn Fn()>,
275        );
276
277        #[cfg(feature = "block2")]
278        /// # Safety
279        ///
280        /// `handler` block must be sendable.
281        #[unsafe(method(deleteAllSavedUserActivitiesWithCompletionHandler:))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn deleteAllSavedUserActivitiesWithCompletionHandler(
284            handler: &block2::DynBlock<dyn Fn()>,
285        );
286    );
287}
288
289/// Methods declared on superclass `NSObject`.
290impl NSUserActivity {
291    extern_methods!(
292        #[unsafe(method(new))]
293        #[unsafe(method_family = new)]
294        pub fn new() -> Retained<Self>;
295    );
296}
297
298impl DefaultRetained for NSUserActivity {
299    #[inline]
300    fn default_retained() -> Retained<Self> {
301        Self::new()
302    }
303}
304
305extern "C" {
306    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsuseractivitytypebrowsingweb?language=objc)
307    #[cfg(feature = "NSString")]
308    pub static NSUserActivityTypeBrowsingWeb: &'static NSString;
309}
310
311extern_protocol!(
312    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsuseractivitydelegate?language=objc)
313    pub unsafe trait NSUserActivityDelegate: NSObjectProtocol {
314        #[optional]
315        #[unsafe(method(userActivityWillSave:))]
316        #[unsafe(method_family = none)]
317        fn userActivityWillSave(&self, user_activity: &NSUserActivity);
318
319        #[optional]
320        #[unsafe(method(userActivityWasContinued:))]
321        #[unsafe(method_family = none)]
322        fn userActivityWasContinued(&self, user_activity: &NSUserActivity);
323
324        #[cfg(feature = "NSStream")]
325        #[optional]
326        #[unsafe(method(userActivity:didReceiveInputStream:outputStream:))]
327        #[unsafe(method_family = none)]
328        fn userActivity_didReceiveInputStream_outputStream(
329            &self,
330            user_activity: &NSUserActivity,
331            input_stream: &NSInputStream,
332            output_stream: &NSOutputStream,
333        );
334    }
335);