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