objc2_health_kit/generated/
HKStatisticsCollectionQuery.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    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkstatisticscollection?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct HKStatisticsCollection;
15);
16
17unsafe impl Send for HKStatisticsCollection {}
18
19unsafe impl Sync for HKStatisticsCollection {}
20
21extern_conformance!(
22    unsafe impl NSObjectProtocol for HKStatisticsCollection {}
23);
24
25impl HKStatisticsCollection {
26    extern_methods!(
27        #[unsafe(method(init))]
28        #[unsafe(method_family = init)]
29        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
30
31        #[cfg(feature = "HKStatistics")]
32        /// Returns the statistics object that this date is inside of
33        ///
34        /// If there are no samples for the given date, an HKStatistics instance with nil quantities will be returned.
35        #[unsafe(method(statisticsForDate:))]
36        #[unsafe(method_family = none)]
37        pub unsafe fn statisticsForDate(&self, date: &NSDate) -> Option<Retained<HKStatistics>>;
38
39        #[cfg(all(feature = "HKStatistics", feature = "block2"))]
40        /// Enumerates all statistics objects from startDate to endDate.
41        ///
42        /// Statistics objects will be enumerated in chronological order. If there are no samples for an interval
43        /// between the start and end date, then the HKStatistics object for that interval will have nil quantities.
44        #[unsafe(method(enumerateStatisticsFromDate:toDate:withBlock:))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn enumerateStatisticsFromDate_toDate_withBlock(
47            &self,
48            start_date: &NSDate,
49            end_date: &NSDate,
50            block: &block2::DynBlock<dyn Fn(NonNull<HKStatistics>, NonNull<Bool>)>,
51        );
52
53        #[cfg(feature = "HKStatistics")]
54        /// Returns a copy of the populated statistics objects.
55        ///
56        /// The statistics objects are ordered chronologically.
57        #[unsafe(method(statistics))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn statistics(&self) -> Retained<NSArray<HKStatistics>>;
60
61        #[cfg(feature = "HKSource")]
62        /// Returns all HKSources found in the contained HKStatistics objects.
63        ///
64        /// Sources will be empty unless HKStatisticsOptionSeparateBySource is specified in the
65        /// HKStatisticsCollectionQuery options.
66        #[unsafe(method(sources))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn sources(&self) -> Retained<NSSet<HKSource>>;
69    );
70}
71
72/// Methods declared on superclass `NSObject`.
73impl HKStatisticsCollection {
74    extern_methods!(
75        #[unsafe(method(new))]
76        #[unsafe(method_family = new)]
77        pub unsafe fn new() -> Retained<Self>;
78    );
79}
80
81extern_class!(
82    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkstatisticscollectionquery?language=objc)
83    #[unsafe(super(HKQuery, NSObject))]
84    #[derive(Debug, PartialEq, Eq, Hash)]
85    #[cfg(feature = "HKQuery")]
86    pub struct HKStatisticsCollectionQuery;
87);
88
89#[cfg(feature = "HKQuery")]
90unsafe impl Send for HKStatisticsCollectionQuery {}
91
92#[cfg(feature = "HKQuery")]
93unsafe impl Sync for HKStatisticsCollectionQuery {}
94
95#[cfg(feature = "HKQuery")]
96extern_conformance!(
97    unsafe impl NSObjectProtocol for HKStatisticsCollectionQuery {}
98);
99
100#[cfg(feature = "HKQuery")]
101impl HKStatisticsCollectionQuery {
102    extern_methods!(
103        #[unsafe(method(anchorDate))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn anchorDate(&self) -> Retained<NSDate>;
106
107        #[cfg(feature = "HKStatistics")]
108        #[unsafe(method(options))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn options(&self) -> HKStatisticsOptions;
111
112        #[unsafe(method(intervalComponents))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn intervalComponents(&self) -> Retained<NSDateComponents>;
115
116        #[cfg(feature = "block2")]
117        /// This property is not atomic.
118        ///
119        /// # Safety
120        ///
121        /// - The returned block must be sendable.
122        /// - This might not be thread-safe.
123        #[unsafe(method(initialResultsHandler))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn initialResultsHandler(
126            &self,
127        ) -> *mut block2::DynBlock<
128            dyn Fn(NonNull<HKStatisticsCollectionQuery>, *mut HKStatisticsCollection, *mut NSError),
129        >;
130
131        #[cfg(feature = "block2")]
132        /// Setter for [`initialResultsHandler`][Self::initialResultsHandler].
133        ///
134        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
135        ///
136        /// # Safety
137        ///
138        /// - `initial_results_handler` block must be sendable.
139        /// - This might not be thread-safe.
140        #[unsafe(method(setInitialResultsHandler:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setInitialResultsHandler(
143            &self,
144            initial_results_handler: Option<
145                &block2::DynBlock<
146                    dyn Fn(
147                        NonNull<HKStatisticsCollectionQuery>,
148                        *mut HKStatisticsCollection,
149                        *mut NSError,
150                    ),
151                >,
152            >,
153        );
154
155        #[cfg(all(feature = "HKStatistics", feature = "block2"))]
156        /// This property is not atomic.
157        ///
158        /// # Safety
159        ///
160        /// - The returned block must be sendable.
161        /// - This might not be thread-safe.
162        #[unsafe(method(statisticsUpdateHandler))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn statisticsUpdateHandler(
165            &self,
166        ) -> *mut block2::DynBlock<
167            dyn Fn(
168                NonNull<HKStatisticsCollectionQuery>,
169                *mut HKStatistics,
170                *mut HKStatisticsCollection,
171                *mut NSError,
172            ),
173        >;
174
175        #[cfg(all(feature = "HKStatistics", feature = "block2"))]
176        /// Setter for [`statisticsUpdateHandler`][Self::statisticsUpdateHandler].
177        ///
178        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
179        ///
180        /// # Safety
181        ///
182        /// - `statistics_update_handler` block must be sendable.
183        /// - This might not be thread-safe.
184        #[unsafe(method(setStatisticsUpdateHandler:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn setStatisticsUpdateHandler(
187            &self,
188            statistics_update_handler: Option<
189                &block2::DynBlock<
190                    dyn Fn(
191                        NonNull<HKStatisticsCollectionQuery>,
192                        *mut HKStatistics,
193                        *mut HKStatisticsCollection,
194                        *mut NSError,
195                    ),
196                >,
197            >,
198        );
199
200        #[cfg(all(feature = "HKObjectType", feature = "HKStatistics"))]
201        #[unsafe(method(initWithQuantityType:quantitySamplePredicate:options:anchorDate:intervalComponents:))]
202        #[unsafe(method_family = init)]
203        pub unsafe fn initWithQuantityType_quantitySamplePredicate_options_anchorDate_intervalComponents(
204            this: Allocated<Self>,
205            quantity_type: &HKQuantityType,
206            quantity_sample_predicate: Option<&NSPredicate>,
207            options: HKStatisticsOptions,
208            anchor_date: &NSDate,
209            interval_components: &NSDateComponents,
210        ) -> Retained<Self>;
211    );
212}
213
214/// Methods declared on superclass `HKQuery`.
215#[cfg(feature = "HKQuery")]
216impl HKStatisticsCollectionQuery {
217    extern_methods!(
218        #[unsafe(method(init))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221    );
222}
223
224/// Methods declared on superclass `NSObject`.
225#[cfg(feature = "HKQuery")]
226impl HKStatisticsCollectionQuery {
227    extern_methods!(
228        #[unsafe(method(new))]
229        #[unsafe(method_family = new)]
230        pub unsafe fn new() -> Retained<Self>;
231    );
232}