objc2_class_kit/generated/
CLSActivity.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// CLSActivity represents user generated activity data for a given context.
12    ///
13    /// CLSActivity has three major components.
14    ///
15    /// (1) Progress, used to measure the amount of activity a user generates as a percentage.
16    /// (2) Duration, used to measure the length of time a user spent on this activity. Use
17    /// `-start`and
18    /// `-stop`methods.
19    /// (3) Activity Items, used to gather information about the activity generated by a user.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/classkit/clsactivity?language=objc)
22    #[unsafe(super(CLSObject, NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    #[cfg(feature = "CLSObject")]
25    pub struct CLSActivity;
26);
27
28#[cfg(feature = "CLSObject")]
29extern_conformance!(
30    unsafe impl NSCoding for CLSActivity {}
31);
32
33#[cfg(feature = "CLSObject")]
34extern_conformance!(
35    unsafe impl NSObjectProtocol for CLSActivity {}
36);
37
38#[cfg(feature = "CLSObject")]
39extern_conformance!(
40    unsafe impl NSSecureCoding for CLSActivity {}
41);
42
43#[cfg(feature = "CLSObject")]
44impl CLSActivity {
45    extern_methods!(
46        /// Current progress as a decimal representation of a percentage.
47        ///
48        /// Should be [0.0, 1.0].
49        #[unsafe(method(progress))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn progress(&self) -> c_double;
52
53        /// Setter for [`progress`][Self::progress].
54        #[unsafe(method(setProgress:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn setProgress(&self, progress: c_double);
57
58        /// Returns the total time tracked in this activity (excluding any previous activities).
59        ///
60        /// The time between calling
61        /// `-start`and
62        /// `-stop.`
63        #[unsafe(method(duration))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn duration(&self) -> NSTimeInterval;
66
67        #[cfg(feature = "CLSActivityItem")]
68        /// The primary activityItem to be reported on.
69        ///
70        /// This can be nil indicating
71        /// `progress`property is the primary data instead of any activityItems.
72        #[unsafe(method(primaryActivityItem))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn primaryActivityItem(&self) -> Option<Retained<CLSActivityItem>>;
75
76        #[cfg(feature = "CLSActivityItem")]
77        /// Setter for [`primaryActivityItem`][Self::primaryActivityItem].
78        #[unsafe(method(setPrimaryActivityItem:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setPrimaryActivityItem(
81            &self,
82            primary_activity_item: Option<&CLSActivityItem>,
83        );
84
85        /// Adds progress to this activity.
86        ///
87        /// The progress should be a decimal representation of the start and ending percentage [0.0, 1.0].
88        ///
89        /// Parameter `start`: Starting percentage.
90        ///
91        /// Parameter `end`: Ending percentage.
92        #[unsafe(method(addProgressRangeFromStart:toEnd:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn addProgressRangeFromStart_toEnd(&self, start: c_double, end: c_double);
95
96        #[cfg(feature = "CLSActivityItem")]
97        /// Add an activity item to this CLSActivity.
98        #[unsafe(method(addAdditionalActivityItem:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn addAdditionalActivityItem(&self, activity_item: &CLSActivityItem);
101
102        #[cfg(feature = "CLSActivityItem")]
103        /// Array of all additional activity items on this CLSActivity.
104        #[unsafe(method(additionalActivityItems))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn additionalActivityItems(&self) -> Retained<NSArray<CLSActivityItem>>;
107    );
108}
109
110/// Methods declared on superclass `CLSObject`.
111#[cfg(feature = "CLSObject")]
112impl CLSActivity {
113    extern_methods!(
114        #[unsafe(method(new))]
115        #[unsafe(method_family = new)]
116        pub unsafe fn new() -> Retained<Self>;
117
118        #[unsafe(method(init))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121    );
122}
123
124/// Activation.
125#[cfg(feature = "CLSObject")]
126impl CLSActivity {
127    extern_methods!(
128        /// Returns whether this Activity has been started or not.
129        #[unsafe(method(isStarted))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn isStarted(&self) -> bool;
132
133        /// Start Activity.
134        ///
135        /// Starts the activity (or resumes if previously stopped).
136        #[unsafe(method(start))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn start(&self);
139
140        /// Stop Activity.
141        ///
142        /// Stops or pauses the activity and ends the time being tracked on it.
143        #[unsafe(method(stop))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn stop(&self);
146
147        /// Deletes all activity items.
148        ///
149        /// Convenience method to delete all activity items associated with the current activity.
150        #[unsafe(method(removeAllActivityItems))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn removeAllActivityItems(&self);
153    );
154}
155
156/// Activity.
157#[cfg(all(feature = "CLSContext", feature = "CLSObject"))]
158impl CLSContext {
159    extern_methods!(
160        /// Returns the current activity.
161        ///
162        /// Activity associated with a context.  If no activity was ever created this is nil. See:
163        /// `-[CLSContext`createNewActivity]; for more details.
164        #[unsafe(method(currentActivity))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn currentActivity(&self) -> Option<Retained<CLSActivity>>;
167
168        /// Creates a new activity
169        ///
170        /// Creates a new activity and sets it as the current activity.
171        #[unsafe(method(createNewActivity))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn createNewActivity(&self) -> Retained<CLSActivity>;
174    );
175}