objc2_class_kit/generated/
CLSContext.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#[cfg(feature = "objc2-core-graphics")]
7use objc2_core_graphics::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttype?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct CLSContextType(pub NSInteger);
17impl CLSContextType {
18    #[doc(alias = "CLSContextTypeNone")]
19    pub const None: Self = Self(0);
20    #[doc(alias = "CLSContextTypeApp")]
21    pub const App: Self = Self(1);
22    #[doc(alias = "CLSContextTypeChapter")]
23    pub const Chapter: Self = Self(2);
24    #[doc(alias = "CLSContextTypeSection")]
25    pub const Section: Self = Self(3);
26    #[doc(alias = "CLSContextTypeLevel")]
27    pub const Level: Self = Self(4);
28    #[doc(alias = "CLSContextTypePage")]
29    pub const Page: Self = Self(5);
30    #[doc(alias = "CLSContextTypeTask")]
31    pub const Task: Self = Self(6);
32    #[doc(alias = "CLSContextTypeChallenge")]
33    pub const Challenge: Self = Self(7);
34    #[doc(alias = "CLSContextTypeQuiz")]
35    pub const Quiz: Self = Self(8);
36    #[doc(alias = "CLSContextTypeExercise")]
37    pub const Exercise: Self = Self(9);
38    #[doc(alias = "CLSContextTypeLesson")]
39    pub const Lesson: Self = Self(10);
40    #[doc(alias = "CLSContextTypeBook")]
41    pub const Book: Self = Self(11);
42    #[doc(alias = "CLSContextTypeGame")]
43    pub const Game: Self = Self(12);
44    #[doc(alias = "CLSContextTypeDocument")]
45    pub const Document: Self = Self(13);
46    #[doc(alias = "CLSContextTypeAudio")]
47    pub const Audio: Self = Self(14);
48    #[doc(alias = "CLSContextTypeVideo")]
49    pub const Video: Self = Self(15);
50    #[doc(alias = "CLSContextTypeCourse")]
51    pub const Course: Self = Self(16);
52    #[doc(alias = "CLSContextTypeCustom")]
53    pub const Custom: Self = Self(17);
54}
55
56unsafe impl Encode for CLSContextType {
57    const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for CLSContextType {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopic?language=objc)
65// NS_TYPED_ENUM
66pub type CLSContextTopic = NSString;
67
68extern "C" {
69    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopicmath?language=objc)
70    pub static CLSContextTopicMath: &'static CLSContextTopic;
71}
72
73extern "C" {
74    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopicscience?language=objc)
75    pub static CLSContextTopicScience: &'static CLSContextTopic;
76}
77
78extern "C" {
79    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopicliteracyandwriting?language=objc)
80    pub static CLSContextTopicLiteracyAndWriting: &'static CLSContextTopic;
81}
82
83extern "C" {
84    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopicworldlanguage?language=objc)
85    pub static CLSContextTopicWorldLanguage: &'static CLSContextTopic;
86}
87
88extern "C" {
89    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopicsocialscience?language=objc)
90    pub static CLSContextTopicSocialScience: &'static CLSContextTopic;
91}
92
93extern "C" {
94    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopiccomputerscienceandengineering?language=objc)
95    pub static CLSContextTopicComputerScienceAndEngineering: &'static CLSContextTopic;
96}
97
98extern "C" {
99    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopicartsandmusic?language=objc)
100    pub static CLSContextTopicArtsAndMusic: &'static CLSContextTopic;
101}
102
103extern "C" {
104    /// [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontexttopichealthandfitness?language=objc)
105    pub static CLSContextTopicHealthAndFitness: &'static CLSContextTopic;
106}
107
108extern_class!(
109    /// Contexts represent activities, documents, and areas within your app.
110    ///
111    /// Contexts have two major components.
112    ///
113    /// (1) Child contexts, used to model your app hierarchy.
114    /// (2) Activity, holds user generated data that pertains to this context.
115    ///
116    /// See also [Apple's documentation](https://developer.apple.com/documentation/classkit/clscontext?language=objc)
117    #[unsafe(super(CLSObject, NSObject))]
118    #[derive(Debug, PartialEq, Eq, Hash)]
119    #[cfg(feature = "CLSObject")]
120    pub struct CLSContext;
121);
122
123#[cfg(feature = "CLSObject")]
124extern_conformance!(
125    unsafe impl NSCoding for CLSContext {}
126);
127
128#[cfg(feature = "CLSObject")]
129extern_conformance!(
130    unsafe impl NSObjectProtocol for CLSContext {}
131);
132
133#[cfg(feature = "CLSObject")]
134extern_conformance!(
135    unsafe impl NSSecureCoding for CLSContext {}
136);
137
138#[cfg(feature = "CLSObject")]
139impl CLSContext {
140    extern_methods!(
141        #[unsafe(method(new))]
142        #[unsafe(method_family = new)]
143        pub unsafe fn new() -> Retained<Self>;
144
145        #[unsafe(method(init))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
148
149        /// Context identifier path of this context.
150        ///
151        /// The identifier path starts with the main app context object and finishes with the identifier of this context. This is the identifier path that one would use in
152        ///
153        /// ```text
154        ///  -[CLSDataStore contextsMatchingIdintifierPath:completion:]
155        /// ```
156        ///
157        /// to find `this' context.
158        #[unsafe(method(identifierPath))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn identifierPath(&self) -> Retained<NSArray<NSString>>;
161
162        /// App-assigned identifier. This identifier should work across users and devices and be unique with regards to its siblings within its parent.
163        ///
164        /// The identifier could be used to embed information later used for deep linking. For example:
165        /// _hydrogen-element,_or
166        /// _chapter-1._
167        #[unsafe(method(identifier))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn identifier(&self) -> Retained<NSString>;
170
171        /// Alternative deep link URL using universal links.
172        ///
173        /// If your app supports universal links, you can supply them here to link the content this context represents.
174        #[unsafe(method(universalLinkURL))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn universalLinkURL(&self) -> Option<Retained<NSURL>>;
177
178        /// Setter for [`universalLinkURL`][Self::universalLinkURL].
179        #[unsafe(method(setUniversalLinkURL:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setUniversalLinkURL(&self, universal_link_url: Option<&NSURL>);
182
183        /// Type of this context
184        ///
185        /// The type that best describes this context.
186        #[unsafe(method(type))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn r#type(&self) -> CLSContextType;
189
190        /// An optional user-visible name for the context if its type is CLSContextTypeCustom.
191        ///
192        /// This property is relevant only if the type is CLSContextTypeCustom. This string should be localized. If this property is not set for a context of type CLSContextTypeCustom, Schoolwork app will use a default localized string ‘Custom’ as the name of the activity representing this context.
193        #[unsafe(method(customTypeName))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn customTypeName(&self) -> Option<Retained<NSString>>;
196
197        /// Setter for [`customTypeName`][Self::customTypeName].
198        ///
199        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
200        #[unsafe(method(setCustomTypeName:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setCustomTypeName(&self, custom_type_name: Option<&NSString>);
203
204        /// Title of this context.
205        ///
206        /// For example:
207        /// _Level_1
208        /// _._
209        #[unsafe(method(title))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn title(&self) -> Retained<NSString>;
212
213        /// Setter for [`title`][Self::title].
214        ///
215        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
216        #[unsafe(method(setTitle:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setTitle(&self, title: &NSString);
219
220        /// The displayOrder is by default sorted ascending.
221        ///
222        /// Set the displayOrder if you want your contexts to be displayed in a particular order. The sort key is used as a way to sort sibling contexts in a particular order.
223        #[unsafe(method(displayOrder))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn displayOrder(&self) -> NSInteger;
226
227        /// Setter for [`displayOrder`][Self::displayOrder].
228        #[unsafe(method(setDisplayOrder:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setDisplayOrder(&self, display_order: NSInteger);
231
232        /// Topic associated with this context.
233        ///
234        /// See above for valid, predefined topics.
235        #[unsafe(method(topic))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn topic(&self) -> Option<Retained<CLSContextTopic>>;
238
239        /// Setter for [`topic`][Self::topic].
240        ///
241        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
242        #[unsafe(method(setTopic:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setTopic(&self, topic: Option<&CLSContextTopic>);
245
246        /// This property is true if the context can be assigned as an activity.
247        ///
248        /// The default value of this property is true. This should be set to false for a context that is used as a container for other contexts, but by itself, is not an assignable activity.
249        #[unsafe(method(isAssignable))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn isAssignable(&self) -> bool;
252
253        /// Setter for [`isAssignable`][Self::isAssignable].
254        #[unsafe(method(setAssignable:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn setAssignable(&self, assignable: bool);
257
258        /// Suggested age range of students, expressed in years, for whom this context is suitable. This information is intended to help teachers to choose age-appropriate activities for their students.
259        ///
260        /// The default value is [0, NSIntegerMax - 1]. This is
261        /// _NSRange(0...Int.max-1)_in
262        /// _Swift_or
263        /// _NSMakeRange(0,NSIntegerMax)_in
264        /// _Objective-C._Set the lower bound to 0 to specify no minimum age limit and set the upper bound to NSIntegerMax - 1 to specify no maximum age limit.
265        #[unsafe(method(suggestedAge))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn suggestedAge(&self) -> NSRange;
268
269        /// Setter for [`suggestedAge`][Self::suggestedAge].
270        #[unsafe(method(setSuggestedAge:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setSuggestedAge(&self, suggested_age: NSRange);
273
274        /// Suggested time range, expressed in minutes, to complete the activity. This information will help teachers as they choose activities for their students.
275        ///
276        /// The default value is [0, NSIntegerMax - 1]. This is
277        /// _NSRange(0...Int.max-1)_in
278        /// _Swift_or
279        /// _NSMakeRange(0,NSIntegerMax)_in
280        /// _Objective-C._Set the lower bound value to 0 to specify no minimum time limit and set the upper bound to NSIntegerMax - 1 to specify no maximum time limit.
281        #[unsafe(method(suggestedCompletionTime))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn suggestedCompletionTime(&self) -> NSRange;
284
285        /// Setter for [`suggestedCompletionTime`][Self::suggestedCompletionTime].
286        #[unsafe(method(setSuggestedCompletionTime:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn setSuggestedCompletionTime(&self, suggested_completion_time: NSRange);
289
290        #[cfg(feature = "CLSProgressReportingCapability")]
291        /// Specifies progress reporting capablities of the app for this context.
292        ///
293        /// This information is intended to help teachers as they choose activities for their students. By default a CLSContext will have one CLSProgressReportingCapability instance of kind CLSProgressReportingCapabilityKindDuration. More progress reporting capabilities can be specified via '-addProgressReportingCapabilities:' to customize this set.
294        #[unsafe(method(progressReportingCapabilities))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn progressReportingCapabilities(
297            &self,
298        ) -> Retained<NSSet<CLSProgressReportingCapability>>;
299
300        /// An optional user-visible summary describing the context limited to 4000 characters in length.
301        ///
302        /// This may be used to provide information about the types of activities available under a given context or the context itself. This string should be localized.
303        #[unsafe(method(summary))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn summary(&self) -> Option<Retained<NSString>>;
306
307        /// Setter for [`summary`][Self::summary].
308        ///
309        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
310        #[unsafe(method(setSummary:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn setSummary(&self, summary: Option<&NSString>);
313
314        #[cfg(feature = "objc2-core-graphics")]
315        /// An optional thumbnail image associated with the context.
316        ///
317        /// The size of this image should be equal to or larger than 80x80 pixels and equal to or smaller than 330x330 pixels. Images larger than 330x330 pixels will be scaled down. Images with both dimensions smaller than 80x80 pixels will not be accepted.
318        #[unsafe(method(thumbnail))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn thumbnail(&self) -> Option<Retained<CGImage>>;
321
322        #[cfg(feature = "objc2-core-graphics")]
323        /// Setter for [`thumbnail`][Self::thumbnail].
324        #[unsafe(method(setThumbnail:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn setThumbnail(&self, thumbnail: Option<&CGImage>);
327
328        /// Initialize and configure the type of content this context represents.
329        ///
330        /// Parameter `identifier`: App-assigned identifier for this context. 256 characters max length.
331        ///
332        /// Parameter `type`: The type of content this context represents.
333        ///
334        /// Parameter `title`: Title for what this context represents. 256 characters max length.
335        #[unsafe(method(initWithType:identifier:title:))]
336        #[unsafe(method_family = init)]
337        pub unsafe fn initWithType_identifier_title(
338            this: Allocated<Self>,
339            r#type: CLSContextType,
340            identifier: &NSString,
341            title: &NSString,
342        ) -> Retained<Self>;
343
344        /// Returns true if self is the active context.
345        #[unsafe(method(isActive))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn isActive(&self) -> bool;
348
349        /// Marks contexts as active.
350        ///
351        /// If a context is already active, it will remain active. If another context is active, the other will resign active before this one becomes active.
352        #[unsafe(method(becomeActive))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn becomeActive(&self);
355
356        /// Resign being active.
357        ///
358        /// This method does nothing if the reciever of the message is not active.
359        #[unsafe(method(resignActive))]
360        #[unsafe(method_family = none)]
361        pub unsafe fn resignActive(&self);
362
363        /// Sets the type.
364        ///
365        /// Use this to update a previously saved context.
366        #[unsafe(method(setType:))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn setType(&self, r#type: CLSContextType);
369
370        #[cfg(feature = "CLSProgressReportingCapability")]
371        /// Add or replace additional progress reporting capabilities of the app for this context.
372        ///
373        /// If this parameter contains multiple items with the same value for kind, then one of them will be arbitrarily selected and used. If this parameter contains a capability of kind CLSProgressReportingCapabilityKindDuration, it will be ignored.
374        ///
375        /// Parameter `capabilities`: Progress reporting capabilities to add or replace existing capabilties.
376        #[unsafe(method(addProgressReportingCapabilities:))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn addProgressReportingCapabilities(
379            &self,
380            capabilities: &NSSet<CLSProgressReportingCapability>,
381        );
382
383        /// Clears CLSProgressReportingCapability objects added to the receiver.
384        ///
385        /// Removes all capabilities added via '-addProgressReportingCapabilities:'. The context will have the default progress reporting capability of kind CLSProgressReportingCapabilityKindDuration.
386        #[unsafe(method(resetProgressReportingCapabilities))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn resetProgressReportingCapabilities(&self);
389    );
390}
391
392/// Hierarchy.
393#[cfg(feature = "CLSObject")]
394impl CLSContext {
395    extern_methods!(
396        /// Returns the parent of this context.
397        #[unsafe(method(parent))]
398        #[unsafe(method_family = none)]
399        pub unsafe fn parent(&self) -> Option<Retained<CLSContext>>;
400
401        /// Removes this child context from its parent.
402        ///
403        /// If you remove a context from its parent and do not add it as a child of another context, it will be deleted when you call -save on the dataStore.
404        #[unsafe(method(removeFromParent))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn removeFromParent(&self);
407
408        /// Adds a child context.
409        ///
410        /// A context can only have a single parent.
411        ///
412        /// Note: objectID of child context may change after it's been added.
413        #[unsafe(method(addChildContext:))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn addChildContext(&self, child: &CLSContext);
416
417        #[cfg(feature = "block2")]
418        /// Returns a descendant of this context matching the context path you provide. Context path must start with an identifier of a child context of the context to which this message is sent.
419        ///
420        /// If there are any missing contexts, they will be filled in by calling the following method on the context's data store's delegate:
421        ///
422        /// ```text
423        ///  -[CLSDataStoreDelegate createContextForIdentifier:parentContext:parentIdentifierPath:]
424        /// ```
425        ///
426        /// If the dataStore does not have a delegate and there are missing contexts then an incomplete list of contexts will be passed to the completion handler. Completion block is called on a background thread.
427        #[unsafe(method(descendantMatchingIdentifierPath:completion:))]
428        #[unsafe(method_family = none)]
429        pub unsafe fn descendantMatchingIdentifierPath_completion(
430            &self,
431            identifier_path: &NSArray<NSString>,
432            completion: &block2::DynBlock<dyn Fn(*mut CLSContext, *mut NSError)>,
433        );
434
435        /// Child contexts that can be navigated to from this context.
436        ///
437        /// Returns all the child contexts added via
438        ///
439        /// ```text
440        ///  -[CLSContext addNavigationChildContext:]
441        /// ```
442        #[unsafe(method(navigationChildContexts))]
443        #[unsafe(method_family = none)]
444        pub unsafe fn navigationChildContexts(&self) -> Retained<NSArray<CLSContext>>;
445
446        /// Adds a child context to specify the user can navigate to the child from this context.
447        ///
448        /// Used only for presentation purpose. Unlike
449        ///
450        /// ```text
451        ///  -[CLSContext addChildContext:]
452        /// ```
453        ///
454        /// , this method does not affect the identifierPath.
455        #[unsafe(method(addNavigationChildContext:))]
456        #[unsafe(method_family = none)]
457        pub unsafe fn addNavigationChildContext(&self, child: &CLSContext);
458
459        /// Removes the navigation path to the child context from this context.
460        ///
461        /// Used only for presentation purpose. Unlike
462        ///
463        /// ```text
464        ///  -[CLSContext removeFromParent:]
465        /// ```
466        ///
467        /// , this method does not affect the identiferPath.
468        #[unsafe(method(removeNavigationChildContext:))]
469        #[unsafe(method_family = none)]
470        pub unsafe fn removeNavigationChildContext(&self, child: &CLSContext);
471    );
472}