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::*;

/// Anxiety risk level determined by GAD-7 assessment.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkgad7assessmentrisk?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKGAD7AssessmentRisk(pub NSInteger);
impl HKGAD7AssessmentRisk {
    #[doc(alias = "HKGAD7AssessmentRiskNoneToMinimal")]
    pub const NoneToMinimal: Self = Self(1);
    #[doc(alias = "HKGAD7AssessmentRiskMild")]
    pub const Mild: Self = Self(2);
    #[doc(alias = "HKGAD7AssessmentRiskModerate")]
    pub const Moderate: Self = Self(3);
    #[doc(alias = "HKGAD7AssessmentRiskSevere")]
    pub const Severe: Self = Self(4);
}

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

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

/// Answer to question on GAD-7 assessment.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkgad7assessmentanswer?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKGAD7AssessmentAnswer(pub NSInteger);
impl HKGAD7AssessmentAnswer {
    #[doc(alias = "HKGAD7AssessmentAnswerNotAtAll")]
    pub const NotAtAll: Self = Self(0);
    #[doc(alias = "HKGAD7AssessmentAnswerSeveralDays")]
    pub const SeveralDays: Self = Self(1);
    #[doc(alias = "HKGAD7AssessmentAnswerMoreThanHalfTheDays")]
    pub const MoreThanHalfTheDays: Self = Self(2);
    #[doc(alias = "HKGAD7AssessmentAnswerNearlyEveryDay")]
    pub const NearlyEveryDay: Self = Self(3);
}

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

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

extern "C-unwind" {
    /// Returns the lower bound of the score range for the given GAD-7 risk classification.
    pub fn HKMinimumScoreForGAD7AssessmentRisk(risk: HKGAD7AssessmentRisk) -> NSInteger;
}

extern "C-unwind" {
    /// Returns the upper bound of the score range for the given GAD-7 risk classification.
    pub fn HKMaximumScoreForGAD7AssessmentRisk(risk: HKGAD7AssessmentRisk) -> NSInteger;
}

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

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

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

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

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

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

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

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

#[cfg(all(
    feature = "HKObject",
    feature = "HKSample",
    feature = "HKScoredAssessment"
))]
impl HKGAD7Assessment {
    extern_methods!(
        /// Answers on the GAD-7 assessment. There are exactly 7 answers, one for each multiple choice question. Each answer is of type `HKGAD7AssessmentAnswer`.
        ///
        /// 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 GAD-7 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) -> HKGAD7AssessmentRisk;

        /// Creates a new GAD-7 sample. There must be exactly 7 elements in answers, each answer must be of type `HKGAD7AssessmentAnswer`.
        #[unsafe(method(assessmentWithDate:answers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn assessmentWithDate_answers(
            date: &NSDate,
            answers: &NSArray<NSNumber>,
        ) -> Retained<Self>;

        /// Creates a new GAD-7 sample. There must be exactly 7 elements in answers, each answer must be of type `HKGAD7AssessmentAnswer`.
        ///
        /// # 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>;
    );
}