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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! 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_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkliveworkoutbuilderdelegate?language=objc)
pub unsafe trait HKLiveWorkoutBuilderDelegate: NSObjectProtocol {
#[cfg(all(feature = "HKObjectType", feature = "HKWorkoutBuilder"))]
/// Called every time new samples are added to the workout builder.
///
/// With new samples added, statistics for the collectedTypes may have changed and should be read again
///
///
/// Parameter `workoutBuilder`: The workout builder to which samples were added.
///
/// Parameter `collectedTypes`: The sample types that were added.
#[unsafe(method(workoutBuilder:didCollectDataOfTypes:))]
#[unsafe(method_family = none)]
unsafe fn workoutBuilder_didCollectDataOfTypes(
&self,
workout_builder: &HKLiveWorkoutBuilder,
collected_types: &NSSet<HKSampleType>,
);
#[cfg(feature = "HKWorkoutBuilder")]
/// Called every time a new event is added to the workout builder.
///
///
/// Parameter `workoutBuilder`: The workout builder to which an event was added.
#[unsafe(method(workoutBuilderDidCollectEvent:))]
#[unsafe(method_family = none)]
unsafe fn workoutBuilderDidCollectEvent(&self, workout_builder: &HKLiveWorkoutBuilder);
#[cfg(all(feature = "HKWorkoutActivity", feature = "HKWorkoutBuilder"))]
/// Called every time new activity is started and added to the workout builder.
///
///
/// Parameter `workoutBuilder`: The workout builder to which the activity was added to.
///
/// Parameter `workoutActivity`: The activity that was added.
#[optional]
#[unsafe(method(workoutBuilder:didBeginActivity:))]
#[unsafe(method_family = none)]
unsafe fn workoutBuilder_didBeginActivity(
&self,
workout_builder: &HKLiveWorkoutBuilder,
workout_activity: &HKWorkoutActivity,
);
#[cfg(all(feature = "HKWorkoutActivity", feature = "HKWorkoutBuilder"))]
/// Called every time the end date is set on an activity in the workout builder.
///
///
/// Parameter `workoutBuilder`: The workout builder to which the activity belongs to
///
/// Parameter `workoutActivity`: The activity that was ended.
#[optional]
#[unsafe(method(workoutBuilder:didEndActivity:))]
#[unsafe(method_family = none)]
unsafe fn workoutBuilder_didEndActivity(
&self,
workout_builder: &HKLiveWorkoutBuilder,
workout_activity: &HKWorkoutActivity,
);
}
);
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkliveworkoutbuilder?language=objc)
#[unsafe(super(HKWorkoutBuilder, NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[cfg(feature = "HKWorkoutBuilder")]
pub struct HKLiveWorkoutBuilder;
);
#[cfg(feature = "HKWorkoutBuilder")]
unsafe impl Send for HKLiveWorkoutBuilder {}
#[cfg(feature = "HKWorkoutBuilder")]
unsafe impl Sync for HKLiveWorkoutBuilder {}
#[cfg(feature = "HKWorkoutBuilder")]
extern_conformance!(
unsafe impl NSObjectProtocol for HKLiveWorkoutBuilder {}
);
#[cfg(feature = "HKWorkoutBuilder")]
impl HKLiveWorkoutBuilder {
extern_methods!(
#[cfg(all(
feature = "HKDevice",
feature = "HKHealthStore",
feature = "HKWorkoutConfiguration"
))]
#[unsafe(method(initWithHealthStore:configuration:device:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithHealthStore_configuration_device(
this: Allocated<Self>,
health_store: &HKHealthStore,
configuration: &HKWorkoutConfiguration,
device: Option<&HKDevice>,
) -> Retained<Self>;
/// The delegate object which will be notified of changes to collected data and elapsed workout time.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn HKLiveWorkoutBuilderDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// This is a [weak property][objc2::topics::weak_property].
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn HKLiveWorkoutBuilderDelegate>>,
);
#[cfg(feature = "HKWorkoutSession")]
/// The workout session with which this builder is associated.
#[unsafe(method(workoutSession))]
#[unsafe(method_family = none)]
pub unsafe fn workoutSession(&self) -> Option<Retained<HKWorkoutSession>>;
/// Whether or not the builder should automatically incorporate events generated by the session.
///
/// YES if the builder should automatically incorporate events from the associated session. If NO, the client
/// is expected to add relevant events directly to the builder and those generated by the session will be
/// ignored. Defaults to YES. The result of changing this value after a call to
/// beginCollectionWithStartDate:completion: is undefined.
#[unsafe(method(shouldCollectWorkoutEvents))]
#[unsafe(method_family = none)]
pub unsafe fn shouldCollectWorkoutEvents(&self) -> bool;
/// Setter for [`shouldCollectWorkoutEvents`][Self::shouldCollectWorkoutEvents].
#[unsafe(method(setShouldCollectWorkoutEvents:))]
#[unsafe(method_family = none)]
pub unsafe fn setShouldCollectWorkoutEvents(&self, should_collect_workout_events: bool);
#[cfg(feature = "HKLiveWorkoutDataSource")]
/// The data source that will provide data to this workout builder.
#[unsafe(method(dataSource))]
#[unsafe(method_family = none)]
pub unsafe fn dataSource(&self) -> Option<Retained<HKLiveWorkoutDataSource>>;
#[cfg(feature = "HKLiveWorkoutDataSource")]
/// Setter for [`dataSource`][Self::dataSource].
#[unsafe(method(setDataSource:))]
#[unsafe(method_family = none)]
pub unsafe fn setDataSource(&self, data_source: Option<&HKLiveWorkoutDataSource>);
/// The elapsed duration of the workout as constructed thus far, considering paused time. When the builder
/// is reading events from an active session, it is possible for this value to increase or decrease;
/// when this occurs, the workoutBuilderDidCollectEvent: delegate method will be called.
#[unsafe(method(elapsedTime))]
#[unsafe(method_family = none)]
pub unsafe fn elapsedTime(&self) -> NSTimeInterval;
#[cfg(feature = "HKWorkoutActivity")]
/// The latest activity that has been added to this builder.
///
/// When an activity is in progress it will be returned by this property. The end date of this activity will always
/// be nil. When the activity is ended, the property would be set to nil until a new activity begins.
#[unsafe(method(currentWorkoutActivity))]
#[unsafe(method_family = none)]
pub unsafe fn currentWorkoutActivity(&self) -> Option<Retained<HKWorkoutActivity>>;
);
}
/// Methods declared on superclass `HKWorkoutBuilder`.
#[cfg(feature = "HKWorkoutBuilder")]
impl HKLiveWorkoutBuilder {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
#[cfg(feature = "HKWorkoutBuilder")]
impl HKLiveWorkoutBuilder {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}