objc2-health-kit 0.3.2

Bindings to the HealthKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Depression risk level determined by PHQ-9 assessment.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkphq9assessmentrisk?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKPHQ9AssessmentRisk(pub NSInteger);
impl HKPHQ9AssessmentRisk {
    #[doc(alias = "HKPHQ9AssessmentRiskNoneToMinimal")]
    pub const NoneToMinimal: Self = Self(1);
    #[doc(alias = "HKPHQ9AssessmentRiskMild")]
    pub const Mild: Self = Self(2);
    #[doc(alias = "HKPHQ9AssessmentRiskModerate")]
    pub const Moderate: Self = Self(3);
    #[doc(alias = "HKPHQ9AssessmentRiskModeratelySevere")]
    pub const ModeratelySevere: Self = Self(4);
    #[doc(alias = "HKPHQ9AssessmentRiskSevere")]
    pub const Severe: Self = Self(5);
}

unsafe impl Encode for HKPHQ9AssessmentRisk {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for HKPHQ9AssessmentRisk {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Answer to question on PHQ-9 assessment.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkphq9assessmentanswer?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKPHQ9AssessmentAnswer(pub NSInteger);
impl HKPHQ9AssessmentAnswer {
    #[doc(alias = "HKPHQ9AssessmentAnswerNotAtAll")]
    pub const NotAtAll: Self = Self(0);
    #[doc(alias = "HKPHQ9AssessmentAnswerSeveralDays")]
    pub const SeveralDays: Self = Self(1);
    #[doc(alias = "HKPHQ9AssessmentAnswerMoreThanHalfTheDays")]
    pub const MoreThanHalfTheDays: Self = Self(2);
    #[doc(alias = "HKPHQ9AssessmentAnswerNearlyEveryDay")]
    pub const NearlyEveryDay: Self = Self(3);
    #[doc(alias = "HKPHQ9AssessmentAnswerPreferNotToAnswer")]
    pub const PreferNotToAnswer: Self = Self(4);
}

unsafe impl Encode for HKPHQ9AssessmentAnswer {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for HKPHQ9AssessmentAnswer {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C-unwind" {
    /// Returns the lower bound of the score range for the given PHQ-9 risk classification.
    pub fn HKMinimumScoreForPHQ9AssessmentRisk(risk: HKPHQ9AssessmentRisk) -> NSInteger;
}

extern "C-unwind" {
    /// Returns the upper bound of the score range for the given PHQ-9 risk classification.
    pub fn HKMaximumScoreForPHQ9AssessmentRisk(risk: HKPHQ9AssessmentRisk) -> NSInteger;
}

extern_class!(
    /// Represents the result of a PHQ-9 assessment. Learn more about Pfizer's PHQ-9 at https://support.apple.com/en-us/105070
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkphq9assessment?language=objc)
    #[unsafe(super(HKScoredAssessment, HKSample, HKObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(
        feature = "HKObject",
        feature = "HKSample",
        feature = "HKScoredAssessment"
    ))]
    pub struct HKPHQ9Assessment;
);

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
unsafe impl Send for HKPHQ9Assessment {}

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
unsafe impl Sync for HKPHQ9Assessment {}

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
extern_conformance!(
    unsafe impl NSCoding for HKPHQ9Assessment {}
);

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
extern_conformance!(
    unsafe impl NSCopying for HKPHQ9Assessment {}
);

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
unsafe impl CopyingHelper for HKPHQ9Assessment {
    type Result = Self;
}

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
extern_conformance!(
    unsafe impl NSObjectProtocol for HKPHQ9Assessment {}
);

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
extern_conformance!(
    unsafe impl NSSecureCoding for HKPHQ9Assessment {}
);

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
impl HKPHQ9Assessment {
    extern_methods!(
        /// 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`.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(answers))]
        #[unsafe(method_family = none)]
        pub unsafe fn answers(&self) -> Retained<NSArray<NSNumber>>;

        /// The risk determined by the score on a PHQ-9 assessment.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(risk))]
        #[unsafe(method_family = none)]
        pub unsafe fn risk(&self) -> HKPHQ9AssessmentRisk;

        /// Creates a new PHQ-9 sample. There must be exactly 9 elements in answers, each answer must be of type `HKPHQ9AssessmentAnswer`.
        /// Question #9 is considered optional. If the user does not answer #9, use `HKPHQ9AssessmentAnswerPreferNotToAnswer`
        #[unsafe(method(assessmentWithDate:answers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn assessmentWithDate_answers(
            date: &NSDate,
            answers: &NSArray<NSNumber>,
        ) -> Retained<Self>;

        /// Creates a new PHQ-9 sample. There must be exactly 9 elements in answers, each answer must be of type `HKPHQ9AssessmentAnswer`.
        /// Question #9 is considered optional. If the user does not answer #9, use `HKPHQ9AssessmentAnswerPreferNotToAnswer`
        ///
        /// # Safety
        ///
        /// `metadata` generic should be of the correct type.
        #[unsafe(method(assessmentWithDate:answers:metadata:))]
        #[unsafe(method_family = none)]
        pub unsafe fn assessmentWithDate_answers_metadata(
            date: &NSDate,
            answers: &NSArray<NSNumber>,
            metadata: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}