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