objc2_health_kit/generated/
HKQuantity.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    /// The HKQuantity class provides an encapsulation of a quantity value and the unit of measurement.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkquantity?language=objc)
14    #[unsafe(super(NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    pub struct HKQuantity;
17);
18
19unsafe impl Send for HKQuantity {}
20
21unsafe impl Sync for HKQuantity {}
22
23extern_conformance!(
24    unsafe impl NSCoding for HKQuantity {}
25);
26
27extern_conformance!(
28    unsafe impl NSCopying for HKQuantity {}
29);
30
31unsafe impl CopyingHelper for HKQuantity {
32    type Result = Self;
33}
34
35extern_conformance!(
36    unsafe impl NSObjectProtocol for HKQuantity {}
37);
38
39extern_conformance!(
40    unsafe impl NSSecureCoding for HKQuantity {}
41);
42
43impl HKQuantity {
44    extern_methods!(
45        #[unsafe(method(init))]
46        #[unsafe(method_family = init)]
47        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
48
49        #[cfg(feature = "HKUnit")]
50        /// Returns a new object representing a quantity measurement with the given unit.
51        #[unsafe(method(quantityWithUnit:doubleValue:))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn quantityWithUnit_doubleValue(
54            unit: &HKUnit,
55            value: c_double,
56        ) -> Retained<Self>;
57
58        #[cfg(feature = "HKUnit")]
59        /// Returns yes if the receiver's value can be converted to a value of the given unit.
60        #[unsafe(method(isCompatibleWithUnit:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn isCompatibleWithUnit(&self, unit: &HKUnit) -> bool;
63
64        #[cfg(feature = "HKUnit")]
65        /// Returns the quantity value converted to the given unit.
66        ///
67        /// Throws an exception if the receiver's value cannot be converted to one of the requested unit.
68        #[unsafe(method(doubleValueForUnit:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn doubleValueForUnit(&self, unit: &HKUnit) -> c_double;
71
72        /// Returns an NSComparisonResult value that indicates whether the receiver is greater than, equal to, or
73        /// less than a given quantity.
74        ///
75        /// Throws an exception if the unit of the given quantity is not compatible with the receiver's unit.
76        #[unsafe(method(compare:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn compare(&self, quantity: &HKQuantity) -> NSComparisonResult;
79    );
80}
81
82/// Methods declared on superclass `NSObject`.
83impl HKQuantity {
84    extern_methods!(
85        #[unsafe(method(new))]
86        #[unsafe(method_family = new)]
87        pub unsafe fn new() -> Retained<Self>;
88    );
89}