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::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// This enumerated type is used to represent the location type of a workout session.
///
/// This value represents whether a workout is performed indoors or outdoors.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkworkoutsessionlocationtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKWorkoutSessionLocationType(pub NSInteger);
impl HKWorkoutSessionLocationType {
    #[doc(alias = "HKWorkoutSessionLocationTypeUnknown")]
    pub const Unknown: Self = Self(1);
    #[doc(alias = "HKWorkoutSessionLocationTypeIndoor")]
    pub const Indoor: Self = Self(2);
    #[doc(alias = "HKWorkoutSessionLocationTypeOutdoor")]
    pub const Outdoor: Self = Self(3);
}

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

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

extern_class!(
    /// An HKWorkoutConfiguration is an object that can be used to describe the workout activity.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkworkoutconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct HKWorkoutConfiguration;
);

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

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

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

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

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

impl HKWorkoutConfiguration {
    extern_methods!(
        #[cfg(feature = "HKWorkout")]
        /// Indicates the type of workout for the configuration.
        #[unsafe(method(activityType))]
        #[unsafe(method_family = none)]
        pub unsafe fn activityType(&self) -> HKWorkoutActivityType;

        #[cfg(feature = "HKWorkout")]
        /// Setter for [`activityType`][Self::activityType].
        #[unsafe(method(setActivityType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setActivityType(&self, activity_type: HKWorkoutActivityType);

        /// Indicates the type of location (indoors vs. outdoors) for the configuration.
        #[unsafe(method(locationType))]
        #[unsafe(method_family = none)]
        pub unsafe fn locationType(&self) -> HKWorkoutSessionLocationType;

        /// Setter for [`locationType`][Self::locationType].
        #[unsafe(method(setLocationType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLocationType(&self, location_type: HKWorkoutSessionLocationType);

        #[cfg(feature = "HKMetadataEnums")]
        /// Indicates the type of swimming location (pool vs. open water) where the workout will take place.
        #[unsafe(method(swimmingLocationType))]
        #[unsafe(method_family = none)]
        pub unsafe fn swimmingLocationType(&self) -> HKWorkoutSwimmingLocationType;

        #[cfg(feature = "HKMetadataEnums")]
        /// Setter for [`swimmingLocationType`][Self::swimmingLocationType].
        #[unsafe(method(setSwimmingLocationType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSwimmingLocationType(
            &self,
            swimming_location_type: HKWorkoutSwimmingLocationType,
        );

        #[cfg(feature = "HKQuantity")]
        /// Indicates the length of the pool, when the workout location type is pool.
        ///
        /// This metric represents the length of the pool where the workout takes place. It should be a quantity with
        /// a unit representing length.
        #[unsafe(method(lapLength))]
        #[unsafe(method_family = none)]
        pub unsafe fn lapLength(&self) -> Option<Retained<HKQuantity>>;

        #[cfg(feature = "HKQuantity")]
        /// Setter for [`lapLength`][Self::lapLength].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLapLength:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLapLength(&self, lap_length: Option<&HKQuantity>);
    );
}

/// Methods declared on superclass `NSObject`.
impl HKWorkoutConfiguration {
    extern_methods!(
        #[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>;
    );
}