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