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 a vision prescription type
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkvisionprescriptiontype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKVisionPrescriptionType(pub NSUInteger);
impl HKVisionPrescriptionType {
    #[doc(alias = "HKVisionPrescriptionTypeGlasses")]
    pub const Glasses: Self = Self(1);
    #[doc(alias = "HKVisionPrescriptionTypeContacts")]
    pub const Contacts: Self = Self(2);
}

unsafe impl Encode for HKVisionPrescriptionType {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    /// HKSample subclass representing a vision prescription
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkvisionprescription?language=objc)
    #[unsafe(super(HKSample, HKObject, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "HKObject", feature = "HKSample"))]
    pub struct HKVisionPrescription;
);

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

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

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

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

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

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

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

#[cfg(all(feature = "HKObject", feature = "HKSample"))]
impl HKVisionPrescription {
    extern_methods!(
        /// A vision prescription type (glasses or contacts)
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(prescriptionType))]
        #[unsafe(method_family = none)]
        pub unsafe fn prescriptionType(&self) -> HKVisionPrescriptionType;

        /// The date the prescription was issued
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(dateIssued))]
        #[unsafe(method_family = none)]
        pub unsafe fn dateIssued(&self) -> Retained<NSDate>;

        /// The date the prescription will expire
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(expirationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn expirationDate(&self) -> Option<Retained<NSDate>>;

        #[cfg(feature = "HKDevice")]
        /// Parameter `type`: The prescription type
        ///
        /// Parameter `dateIssued`: The date the prescription was issued
        ///
        /// Parameter `expirationDate`: The date the prescription expires
        ///
        /// Parameter `device`: The device that generated the sample
        ///
        /// Parameter `metadata`: The metadata for the sample
        ///
        /// # Safety
        ///
        /// `metadata` generic should be of the correct type.
        #[unsafe(method(prescriptionWithType:dateIssued:expirationDate:device:metadata:))]
        #[unsafe(method_family = none)]
        pub unsafe fn prescriptionWithType_dateIssued_expirationDate_device_metadata(
            r#type: HKVisionPrescriptionType,
            date_issued: &NSDate,
            expiration_date: Option<&NSDate>,
            device: Option<&HKDevice>,
            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>;
    );
}