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 #[unsafe(method(setCustomTypeName:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn setCustomTypeName(&self, custom_type_name: Option<&NSString>);
201
202 /// Title of this context.
203 ///
204 /// For example:
205 /// _Level_1
206 /// _._
207 #[unsafe(method(title))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn title(&self) -> Retained<NSString>;
210
211 /// Setter for [`title`][Self::title].
212 #[unsafe(method(setTitle:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setTitle(&self, title: &NSString);
215
216 /// The displayOrder is by default sorted ascending.
217 ///
218 /// 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.
219 #[unsafe(method(displayOrder))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn displayOrder(&self) -> NSInteger;
222
223 /// Setter for [`displayOrder`][Self::displayOrder].
224 #[unsafe(method(setDisplayOrder:))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn setDisplayOrder(&self, display_order: NSInteger);
227
228 /// Topic associated with this context.
229 ///
230 /// See above for valid, predefined topics.
231 #[unsafe(method(topic))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn topic(&self) -> Option<Retained<CLSContextTopic>>;
234
235 /// Setter for [`topic`][Self::topic].
236 #[unsafe(method(setTopic:))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn setTopic(&self, topic: Option<&CLSContextTopic>);
239
240 /// This property is true if the context can be assigned as an activity.
241 ///
242 /// 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.
243 #[unsafe(method(isAssignable))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn isAssignable(&self) -> bool;
246
247 /// Setter for [`isAssignable`][Self::isAssignable].
248 #[unsafe(method(setAssignable:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setAssignable(&self, assignable: bool);
251
252 /// 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.
253 ///
254 /// The default value is [0, NSIntegerMax - 1]. This is
255 /// _NSRange(0...Int.max-1)_in
256 /// _Swift_or
257 /// _NSMakeRange(0,NSIntegerMax)_in
258 /// _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.
259 #[unsafe(method(suggestedAge))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn suggestedAge(&self) -> NSRange;
262
263 /// Setter for [`suggestedAge`][Self::suggestedAge].
264 #[unsafe(method(setSuggestedAge:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn setSuggestedAge(&self, suggested_age: NSRange);
267
268 /// Suggested time range, expressed in minutes, to complete the activity. This information will help teachers as they choose activities for their students.
269 ///
270 /// The default value is [0, NSIntegerMax - 1]. This is
271 /// _NSRange(0...Int.max-1)_in
272 /// _Swift_or
273 /// _NSMakeRange(0,NSIntegerMax)_in
274 /// _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.
275 #[unsafe(method(suggestedCompletionTime))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn suggestedCompletionTime(&self) -> NSRange;
278
279 /// Setter for [`suggestedCompletionTime`][Self::suggestedCompletionTime].
280 #[unsafe(method(setSuggestedCompletionTime:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn setSuggestedCompletionTime(&self, suggested_completion_time: NSRange);
283
284 #[cfg(feature = "CLSProgressReportingCapability")]
285 /// Specifies progress reporting capablities of the app for this context.
286 ///
287 /// 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.
288 #[unsafe(method(progressReportingCapabilities))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn progressReportingCapabilities(
291 &self,
292 ) -> Retained<NSSet<CLSProgressReportingCapability>>;
293
294 /// An optional user-visible summary describing the context limited to 4000 characters in length.
295 ///
296 /// 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.
297 #[unsafe(method(summary))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn summary(&self) -> Option<Retained<NSString>>;
300
301 /// Setter for [`summary`][Self::summary].
302 #[unsafe(method(setSummary:))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn setSummary(&self, summary: Option<&NSString>);
305
306 #[cfg(feature = "objc2-core-graphics")]
307 /// An optional thumbnail image associated with the context.
308 ///
309 /// 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.
310 #[unsafe(method(thumbnail))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn thumbnail(&self) -> Option<Retained<CGImage>>;
313
314 #[cfg(feature = "objc2-core-graphics")]
315 /// Setter for [`thumbnail`][Self::thumbnail].
316 #[unsafe(method(setThumbnail:))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn setThumbnail(&self, thumbnail: Option<&CGImage>);
319
320 /// Initialize and configure the type of content this context represents.
321 ///
322 /// Parameter `identifier`: App-assigned identifier for this context. 256 characters max length.
323 ///
324 /// Parameter `type`: The type of content this context represents.
325 ///
326 /// Parameter `title`: Title for what this context represents. 256 characters max length.
327 #[unsafe(method(initWithType:identifier:title:))]
328 #[unsafe(method_family = init)]
329 pub unsafe fn initWithType_identifier_title(
330 this: Allocated<Self>,
331 r#type: CLSContextType,
332 identifier: &NSString,
333 title: &NSString,
334 ) -> Retained<Self>;
335
336 /// Returns true if self is the active context.
337 #[unsafe(method(isActive))]
338 #[unsafe(method_family = none)]
339 pub unsafe fn isActive(&self) -> bool;
340
341 /// Marks contexts as active.
342 ///
343 /// 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.
344 #[unsafe(method(becomeActive))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn becomeActive(&self);
347
348 /// Resign being active.
349 ///
350 /// This method does nothing if the reciever of the message is not active.
351 #[unsafe(method(resignActive))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn resignActive(&self);
354
355 /// Sets the type.
356 ///
357 /// Use this to update a previously saved context.
358 #[unsafe(method(setType:))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn setType(&self, r#type: CLSContextType);
361
362 #[cfg(feature = "CLSProgressReportingCapability")]
363 /// Add or replace additional progress reporting capabilities of the app for this context.
364 ///
365 /// 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.
366 ///
367 /// Parameter `capabilities`: Progress reporting capabilities to add or replace existing capabilties.
368 #[unsafe(method(addProgressReportingCapabilities:))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn addProgressReportingCapabilities(
371 &self,
372 capabilities: &NSSet<CLSProgressReportingCapability>,
373 );
374
375 /// Clears CLSProgressReportingCapability objects added to the receiver.
376 ///
377 /// Removes all capabilities added via '-addProgressReportingCapabilities:'. The context will have the default progress reporting capability of kind CLSProgressReportingCapabilityKindDuration.
378 #[unsafe(method(resetProgressReportingCapabilities))]
379 #[unsafe(method_family = none)]
380 pub unsafe fn resetProgressReportingCapabilities(&self);
381 );
382}
383
384/// Hierarchy.
385#[cfg(feature = "CLSObject")]
386impl CLSContext {
387 extern_methods!(
388 /// Returns the parent of this context.
389 #[unsafe(method(parent))]
390 #[unsafe(method_family = none)]
391 pub unsafe fn parent(&self) -> Option<Retained<CLSContext>>;
392
393 /// Removes this child context from its parent.
394 ///
395 /// 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.
396 #[unsafe(method(removeFromParent))]
397 #[unsafe(method_family = none)]
398 pub unsafe fn removeFromParent(&self);
399
400 /// Adds a child context.
401 ///
402 /// A context can only have a single parent.
403 ///
404 /// Note: objectID of child context may change after it's been added.
405 #[unsafe(method(addChildContext:))]
406 #[unsafe(method_family = none)]
407 pub unsafe fn addChildContext(&self, child: &CLSContext);
408
409 #[cfg(feature = "block2")]
410 /// 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.
411 ///
412 /// If there are any missing contexts, they will be filled in by calling the following method on the context's data store's delegate:
413 ///
414 /// ```text
415 /// -[CLSDataStoreDelegate createContextForIdentifier:parentContext:parentIdentifierPath:]
416 /// ```
417 ///
418 /// 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.
419 #[unsafe(method(descendantMatchingIdentifierPath:completion:))]
420 #[unsafe(method_family = none)]
421 pub unsafe fn descendantMatchingIdentifierPath_completion(
422 &self,
423 identifier_path: &NSArray<NSString>,
424 completion: &block2::DynBlock<dyn Fn(*mut CLSContext, *mut NSError)>,
425 );
426
427 /// Child contexts that can be navigated to from this context.
428 ///
429 /// Returns all the child contexts added via
430 ///
431 /// ```text
432 /// -[CLSContext addNavigationChildContext:]
433 /// ```
434 #[unsafe(method(navigationChildContexts))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn navigationChildContexts(&self) -> Retained<NSArray<CLSContext>>;
437
438 /// Adds a child context to specify the user can navigate to the child from this context.
439 ///
440 /// Used only for presentation purpose. Unlike
441 ///
442 /// ```text
443 /// -[CLSContext addChildContext:]
444 /// ```
445 ///
446 /// , this method does not affect the identifierPath.
447 #[unsafe(method(addNavigationChildContext:))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn addNavigationChildContext(&self, child: &CLSContext);
450
451 /// Removes the navigation path to the child context from this context.
452 ///
453 /// Used only for presentation purpose. Unlike
454 ///
455 /// ```text
456 /// -[CLSContext removeFromParent:]
457 /// ```
458 ///
459 /// , this method does not affect the identiferPath.
460 #[unsafe(method(removeNavigationChildContext:))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn removeNavigationChildContext(&self, child: &CLSContext);
463 );
464}