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

/// Represents the conduction type used for an HKAudiogramSensitivityTest
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkaudiogramconductiontype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKAudiogramConductionType(pub NSInteger);
impl HKAudiogramConductionType {
    #[doc(alias = "HKAudiogramConductionTypeAir")]
    pub const Air: Self = Self(0);
}

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

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

/// Represents the test side used for an HKAudiogramSensitivityTest
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkaudiogramsensitivitytestside?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKAudiogramSensitivityTestSide(pub NSInteger);
impl HKAudiogramSensitivityTestSide {
    #[doc(alias = "HKAudiogramSensitivityTestSideLeft")]
    pub const Left: Self = Self(0);
    #[doc(alias = "HKAudiogramSensitivityTestSideRight")]
    pub const Right: Self = Self(1);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkaudiogramsensitivitytest?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HKAudiogramSensitivityTest;
);

unsafe impl Send for HKAudiogramSensitivityTest {}

unsafe impl Sync for HKAudiogramSensitivityTest {}

extern_conformance!(
    unsafe impl NSCoding for HKAudiogramSensitivityTest {}
);

extern_conformance!(
    unsafe impl NSCopying for HKAudiogramSensitivityTest {}
);

unsafe impl CopyingHelper for HKAudiogramSensitivityTest {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for HKAudiogramSensitivityTest {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for HKAudiogramSensitivityTest {}
);

impl HKAudiogramSensitivityTest {
    extern_methods!(
        #[cfg(feature = "HKQuantity")]
        /// Ear sensitivity measured in dB from a baseline of 0 dB. Reduced hearing sensitivity corresponds to an increase from 0 dB.
        /// The unit of measurement is `HKUnit.decibelHearingLevelUnit` or "dBHL".
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(sensitivity))]
        #[unsafe(method_family = none)]
        pub unsafe fn sensitivity(&self) -> Retained<HKQuantity>;

        /// The conduction type
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> HKAudiogramConductionType;

        /// Indicates if the test was conducted with or without masking
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(masked))]
        #[unsafe(method_family = none)]
        pub unsafe fn masked(&self) -> bool;

        /// The test side
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(side))]
        #[unsafe(method_family = none)]
        pub unsafe fn side(&self) -> HKAudiogramSensitivityTestSide;

        #[cfg(feature = "HKAudiogramSensitivityPointClampingRange")]
        /// If present, indicates that the range within which the sensitivity point should be clamped.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(clampingRange))]
        #[unsafe(method_family = none)]
        pub unsafe fn clampingRange(
            &self,
        ) -> Option<Retained<HKAudiogramSensitivityPointClampingRange>>;

        #[cfg(all(
            feature = "HKAudiogramSensitivityPointClampingRange",
            feature = "HKQuantity"
        ))]
        /// Creates a sensitivity test which can be added to a HKAudiogramSensitivityPoint
        ///
        /// Parameter `sensitivity`: The ear sensitivity measured in dB from a baseline of 0 dB with unit `HKUnit.decibelHearingLevelUnit` or "dBHL".
        ///
        /// Parameter `type`: The type of test
        ///
        /// Parameter `masked`: If the test was conducted with or without masking
        ///
        /// Parameter `side`: The test side which was tested
        ///
        /// Parameter `clampingRange`: The clamping range (if any)
        ///
        /// Parameter `errorOut`: If there was a problem creating this instance this will contain the error.
        ///
        /// Returns: New instance of a Sensitivity Test or nil if there were problems
        /// creating the instance.  Errors may include incorrect quantity units or sensitivity out of range
        #[unsafe(method(initWithSensitivity:type:masked:side:clampingRange:error:_))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSensitivity_type_masked_side_clampingRange_error(
            this: Allocated<Self>,
            sensitivity: &HKQuantity,
            r#type: HKAudiogramConductionType,
            masked: bool,
            side: HKAudiogramSensitivityTestSide,
            clamping_range: Option<&HKAudiogramSensitivityPointClampingRange>,
        ) -> Result<Retained<Self>, Retained<NSError>>;

        #[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>;
    );
}