objc2_health_kit/generated/
HKPHQ9Assessment.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// Depression risk level determined by PHQ-9 assessment.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkphq9assessmentrisk?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct HKPHQ9AssessmentRisk(pub NSInteger);
16impl HKPHQ9AssessmentRisk {
17    #[doc(alias = "HKPHQ9AssessmentRiskNoneToMinimal")]
18    pub const NoneToMinimal: Self = Self(1);
19    #[doc(alias = "HKPHQ9AssessmentRiskMild")]
20    pub const Mild: Self = Self(2);
21    #[doc(alias = "HKPHQ9AssessmentRiskModerate")]
22    pub const Moderate: Self = Self(3);
23    #[doc(alias = "HKPHQ9AssessmentRiskModeratelySevere")]
24    pub const ModeratelySevere: Self = Self(4);
25    #[doc(alias = "HKPHQ9AssessmentRiskSevere")]
26    pub const Severe: Self = Self(5);
27}
28
29unsafe impl Encode for HKPHQ9AssessmentRisk {
30    const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for HKPHQ9AssessmentRisk {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37/// Answer to question on PHQ-9 assessment.
38///
39/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkphq9assessmentanswer?language=objc)
40// NS_ENUM
41#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct HKPHQ9AssessmentAnswer(pub NSInteger);
44impl HKPHQ9AssessmentAnswer {
45    #[doc(alias = "HKPHQ9AssessmentAnswerNotAtAll")]
46    pub const NotAtAll: Self = Self(0);
47    #[doc(alias = "HKPHQ9AssessmentAnswerSeveralDays")]
48    pub const SeveralDays: Self = Self(1);
49    #[doc(alias = "HKPHQ9AssessmentAnswerMoreThanHalfTheDays")]
50    pub const MoreThanHalfTheDays: Self = Self(2);
51    #[doc(alias = "HKPHQ9AssessmentAnswerNearlyEveryDay")]
52    pub const NearlyEveryDay: Self = Self(3);
53    #[doc(alias = "HKPHQ9AssessmentAnswerPreferNotToAnswer")]
54    pub const PreferNotToAnswer: Self = Self(4);
55}
56
57unsafe impl Encode for HKPHQ9AssessmentAnswer {
58    const ENCODING: Encoding = NSInteger::ENCODING;
59}
60
61unsafe impl RefEncode for HKPHQ9AssessmentAnswer {
62    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
63}
64
65extern "C-unwind" {
66    /// Returns the lower bound of the score range for the given PHQ-9 risk classification.
67    pub fn HKMinimumScoreForPHQ9AssessmentRisk(risk: HKPHQ9AssessmentRisk) -> NSInteger;
68}
69
70extern "C-unwind" {
71    /// Returns the upper bound of the score range for the given PHQ-9 risk classification.
72    pub fn HKMaximumScoreForPHQ9AssessmentRisk(risk: HKPHQ9AssessmentRisk) -> NSInteger;
73}
74
75extern_class!(
76    /// Represents the result of a PHQ-9 assessment. Learn more about Pfizer's PHQ-9 at https://support.apple.com/en-us/105070
77    ///
78    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkphq9assessment?language=objc)
79    #[unsafe(super(HKScoredAssessment, HKSample, HKObject, NSObject))]
80    #[derive(Debug, PartialEq, Eq, Hash)]
81    #[cfg(all(
82        feature = "HKObject",
83        feature = "HKSample",
84        feature = "HKScoredAssessment"
85    ))]
86    pub struct HKPHQ9Assessment;
87);
88
89#[cfg(all(
90    feature = "HKObject",
91    feature = "HKSample",
92    feature = "HKScoredAssessment"
93))]
94unsafe impl Send for HKPHQ9Assessment {}
95
96#[cfg(all(
97    feature = "HKObject",
98    feature = "HKSample",
99    feature = "HKScoredAssessment"
100))]
101unsafe impl Sync for HKPHQ9Assessment {}
102
103#[cfg(all(
104    feature = "HKObject",
105    feature = "HKSample",
106    feature = "HKScoredAssessment"
107))]
108extern_conformance!(
109    unsafe impl NSCoding for HKPHQ9Assessment {}
110);
111
112#[cfg(all(
113    feature = "HKObject",
114    feature = "HKSample",
115    feature = "HKScoredAssessment"
116))]
117extern_conformance!(
118    unsafe impl NSCopying for HKPHQ9Assessment {}
119);
120
121#[cfg(all(
122    feature = "HKObject",
123    feature = "HKSample",
124    feature = "HKScoredAssessment"
125))]
126unsafe impl CopyingHelper for HKPHQ9Assessment {
127    type Result = Self;
128}
129
130#[cfg(all(
131    feature = "HKObject",
132    feature = "HKSample",
133    feature = "HKScoredAssessment"
134))]
135extern_conformance!(
136    unsafe impl NSObjectProtocol for HKPHQ9Assessment {}
137);
138
139#[cfg(all(
140    feature = "HKObject",
141    feature = "HKSample",
142    feature = "HKScoredAssessment"
143))]
144extern_conformance!(
145    unsafe impl NSSecureCoding for HKPHQ9Assessment {}
146);
147
148#[cfg(all(
149    feature = "HKObject",
150    feature = "HKSample",
151    feature = "HKScoredAssessment"
152))]
153impl HKPHQ9Assessment {
154    extern_methods!(
155        /// Answers on the PHQ-9 assessment. There are exactly 9 answers, one for each multiple choice question. Each answer is of type `HKPHQ9AssessmentAnswer`. If the 9th question was unanswered,  the answer is `HKPHQ9AssessmentAnswerPreferNotToAnswer`.
156        ///
157        /// This property is not atomic.
158        ///
159        /// # Safety
160        ///
161        /// This might not be thread-safe.
162        #[unsafe(method(answers))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn answers(&self) -> Retained<NSArray<NSNumber>>;
165
166        /// The risk determined by the score on a PHQ-9 assessment.
167        ///
168        /// This property is not atomic.
169        ///
170        /// # Safety
171        ///
172        /// This might not be thread-safe.
173        #[unsafe(method(risk))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn risk(&self) -> HKPHQ9AssessmentRisk;
176
177        /// Creates a new PHQ-9 sample. There must be exactly 9 elements in answers, each answer must be of type `HKPHQ9AssessmentAnswer`.
178        /// Question #9 is considered optional. If the user does not answer #9, use `HKPHQ9AssessmentAnswerPreferNotToAnswer`
179        #[unsafe(method(assessmentWithDate:answers:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn assessmentWithDate_answers(
182            date: &NSDate,
183            answers: &NSArray<NSNumber>,
184        ) -> Retained<Self>;
185
186        /// Creates a new PHQ-9 sample. There must be exactly 9 elements in answers, each answer must be of type `HKPHQ9AssessmentAnswer`.
187        /// Question #9 is considered optional. If the user does not answer #9, use `HKPHQ9AssessmentAnswerPreferNotToAnswer`
188        ///
189        /// # Safety
190        ///
191        /// `metadata` generic should be of the correct type.
192        #[unsafe(method(assessmentWithDate:answers:metadata:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn assessmentWithDate_answers_metadata(
195            date: &NSDate,
196            answers: &NSArray<NSNumber>,
197            metadata: Option<&NSDictionary<NSString, AnyObject>>,
198        ) -> Retained<Self>;
199
200        #[unsafe(method(init))]
201        #[unsafe(method_family = init)]
202        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
203
204        #[unsafe(method(new))]
205        #[unsafe(method_family = new)]
206        pub unsafe fn new() -> Retained<Self>;
207    );
208}