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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
//! 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!(
/// An HKQuantitySeriesSampleBuilder is used to generate HKQuantitySample(s) with multiple
/// quantities.
///
/// An HKQuantitySeriesSampleBuilder is used to incrementally create a new quantity series
/// sample in the HealthKit database. This class may be used to create long-running quantity
/// series samples that are associated with an activity like a workout. After inserting each
/// of the quantities that make up the series, the series may be finalized by calling
/// -finishSeriesWithMetadata:completion:. Calling -discard invalidates the series and
/// discards any data that was previously associated with it.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkquantityseriessamplebuilder?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct HKQuantitySeriesSampleBuilder;
);
unsafe impl Send for HKQuantitySeriesSampleBuilder {}
unsafe impl Sync for HKQuantitySeriesSampleBuilder {}
extern_conformance!(
unsafe impl NSObjectProtocol for HKQuantitySeriesSampleBuilder {}
);
impl HKQuantitySeriesSampleBuilder {
extern_methods!(
#[cfg(all(
feature = "HKDevice",
feature = "HKHealthStore",
feature = "HKObjectType"
))]
/// The designated initializer to create an HKQuantitySeriesSampleBuilder.
///
/// The HKHealthStore is retained during the life of the object for the saving of the
/// series data and final return of the series sample.
///
///
/// Parameter `healthStore`: Specifies the HKHealthStore object to use for building the series.
///
/// Parameter `quantityType`: Specifies the quantity type for which to build the series.
///
/// Parameter `startDate`: The date from which the produced sample(s) start.
///
/// Parameter `device`: The optional device represents the HKDevice from which the data is
/// provided.
#[unsafe(method(initWithHealthStore:quantityType:startDate:device:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithHealthStore_quantityType_startDate_device(
this: Allocated<Self>,
health_store: &HKHealthStore,
quantity_type: &HKQuantityType,
start_date: &NSDate,
device: Option<&HKDevice>,
) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "HKObjectType")]
#[unsafe(method(quantityType))]
#[unsafe(method_family = none)]
pub unsafe fn quantityType(&self) -> Retained<HKQuantityType>;
#[unsafe(method(startDate))]
#[unsafe(method_family = none)]
pub unsafe fn startDate(&self) -> Retained<NSDate>;
#[cfg(feature = "HKDevice")]
#[unsafe(method(device))]
#[unsafe(method_family = none)]
pub unsafe fn device(&self) -> Option<Retained<HKDevice>>;
#[cfg(feature = "HKQuantity")]
/// Associate a new quantity with the receiver with a specific date interval.
///
/// Use this method to add a quantity to the series. The quantity must have a unit
/// that is compatible with the receiver's quantity type.
/// See -[HKQuantityType isCompatibleWithUnit:].
/// Note that quantities may be inserted in any order,
/// but will be sorted by dateInterval.startDate when the series is finished.
///
///
/// Parameter `quantity`: The quantity to insert.
///
/// Parameter `dateInterval`: The dateInterval associated with the quantity.
/// If dateInterval.startDate is the same as a previously-provided
/// quantity, the new value will replace the old value.
/// An HKErrorInvalidArgument will be returned if
/// dateInterval.startDate is earlier than the receiver's startDate.
#[unsafe(method(insertQuantity:dateInterval:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn insertQuantity_dateInterval_error(
&self,
quantity: &HKQuantity,
date_interval: &NSDateInterval,
) -> Result<(), Retained<NSError>>;
#[cfg(feature = "HKQuantity")]
/// Associate a new quantity with the receiver at a specific instantaneous
/// date interval.
///
/// This method acts as a convenience for insertQuantity:dateInterval:completion:
/// where dateInterval has a duration of 0.
///
///
/// Parameter `quantity`: The quantity to insert.
///
/// Parameter `date`: The start date associated with the quantity. If this is the same
/// start date as a previously-provided quantity, the new value will
/// replace the old value. An HKErrorInvalidArgument will be returned
/// if date is earlier than the receiver's startDate.
#[unsafe(method(insertQuantity:date:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn insertQuantity_date_error(
&self,
quantity: &HKQuantity,
date: &NSDate,
) -> Result<(), Retained<NSError>>;
#[cfg(all(
feature = "HKObject",
feature = "HKQuantitySample",
feature = "HKSample",
feature = "block2"
))]
/// Finalizes the series and returns the resulting HKQuantitySample(s).
///
/// Call this method when all quantities for the series have been inserted.
/// The completion handler will return the resulting HKQuantitySample(s)
/// Note that it is possible for a single HKQuantitySeriesSampleBuilder to produce
/// multiple samples. If no quantity data was added, then samples will be nil and
/// an error will be returned. After calling this method, the receiver will be
/// considered invalid and calling any other method will result in an error.
///
///
/// Parameter `metadata`: Optional metadata may be added to associate with the series.
/// Predefined keys are found in HKMetadata.h, or custom NSString
/// keys used by the client are allowed. Acceptable metadata value types
/// are NSString, NSDate, NSNumber and HKQuantity.
///
/// Parameter `endDate`: Optional date at which the produced sample(s) end.
/// An HKErrorInvalidArgument will be returned if endDate
/// is earlier than the receiver's startDate,
/// or is earlier than the dateInterval.endDate of any inserted quantity.
///
/// Parameter `completion`: The completion handler will return the resulting HKQuantitySample(s)
/// for the series. Note that it is possible for a single
/// HKQuantitySeriesSampleBuilder to produce multiple samples.
/// If data could not be inserted because of an authorization failure,
/// samples will be nil and and an error with code
/// HKErrorAuthorizationDenied or HKErrorAuthorizationNotDetermined
/// will be returned. If the resulting sample(s) could not be accessed
/// after they have been created, then samples will be nil and an error
/// with code HKErrorDatabaseInaccessible will be returned. Any other
/// error indicates the resulting samples could not be returned.
/// After calling this method, the receiver will be considered invalid
/// and calling any other method will result in an error.
///
/// # Safety
///
/// `metadata` generic should be of the correct type.
#[unsafe(method(finishSeriesWithMetadata:endDate:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn finishSeriesWithMetadata_endDate_completion(
&self,
metadata: Option<&NSDictionary<NSString, AnyObject>>,
end_date: Option<&NSDate>,
completion: &block2::DynBlock<dyn Fn(*mut NSArray<HKQuantitySample>, *mut NSError)>,
);
#[cfg(all(
feature = "HKObject",
feature = "HKQuantitySample",
feature = "HKSample",
feature = "block2"
))]
/// Finalizes the series and returns the resulting HKQuantitySample(s).
///
/// Call this method when all quantities for the series have been inserted.
/// The completion handler will return the resulting HKQuantitySample(s)
/// Note that it is possible for a single HKQuantitySeriesSampleBuilder to produce
/// multiple samples. If no quantity data was added, then samples will be nil and
/// an error will be returned. This method functions as a convenience for
/// finishSeriesWithMetadata:endDate:completion: when endDate is nil.
/// After calling this method, the receiver will be considered invalid
/// and calling any other method will result in an error.
///
///
/// Parameter `metadata`: Optional metadata may be added to associate with the series.
/// Predefined keys are found in HKMetadata.h, or custom NSString
/// keys used by the client are allowed. Acceptable metadata value types
/// are NSString, NSDate, NSNumber and HKQuantity.
///
/// Parameter `completion`: The completion handler will return the resulting HKQuantitySample(s)
/// for the series. Note that it is possible for a single
/// HKQuantitySeriesSampleBuilder to produce multiple samples.
/// If data could not be inserted because of an authorization failure,
/// samples will be nil and and an error with code
/// HKErrorAuthorizationDenied or HKErrorAuthorizationNotDetermined
/// will be returned. If the resulting sample(s) could not be accessed
/// after they have been created, then samples will be nil and an error
/// with code HKErrorDatabaseInaccessible will be returned. Any other
/// error indicates the resulting samples could not be returned.
/// After calling this method, the receiver will be considered invalid
/// and calling any other method will result in an error.
///
/// # Safety
///
/// `metadata` generic should be of the correct type.
#[unsafe(method(finishSeriesWithMetadata:completion:))]
#[unsafe(method_family = none)]
pub unsafe fn finishSeriesWithMetadata_completion(
&self,
metadata: Option<&NSDictionary<NSString, AnyObject>>,
completion: &block2::DynBlock<dyn Fn(*mut NSArray<HKQuantitySample>, *mut NSError)>,
);
/// Discards all previously inserted data and invalidates the series.
///
/// Calling this method will delete all quantities that were previously inserted into
/// the series and invalidate the receiver. Calling other methods on the receiver
/// after calling -discard will result in an exception.
#[unsafe(method(discard))]
#[unsafe(method_family = none)]
pub unsafe fn discard(&self);
);
}
/// Methods declared on superclass `NSObject`.
impl HKQuantitySeriesSampleBuilder {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}