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

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

unsafe impl Send for HKWorkoutEffortRelationship {}

unsafe impl Sync for HKWorkoutEffortRelationship {}

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

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

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

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

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

impl HKWorkoutEffortRelationship {
    extern_methods!(
        #[cfg(all(feature = "HKObject", feature = "HKSample", feature = "HKWorkout"))]
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(workout))]
        #[unsafe(method_family = none)]
        pub unsafe fn workout(&self) -> Retained<HKWorkout>;

        #[cfg(feature = "HKWorkoutActivity")]
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(activity))]
        #[unsafe(method_family = none)]
        pub unsafe fn activity(&self) -> Option<Retained<HKWorkoutActivity>>;

        #[cfg(all(feature = "HKObject", feature = "HKSample"))]
        /// The samples related to the workout but not any sub-activities
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(samples))]
        #[unsafe(method_family = none)]
        pub unsafe fn samples(&self) -> Option<Retained<NSArray<HKSample>>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl HKWorkoutEffortRelationship {
    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>;
    );
}

/// Option for specifying which workout effort relationship sample(s) to retrieve
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkworkouteffortrelationshipqueryoptions?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct HKWorkoutEffortRelationshipQueryOptions(pub NSInteger);
impl HKWorkoutEffortRelationshipQueryOptions {
    #[doc(alias = "HKWorkoutEffortRelationshipQueryOptionsDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "HKWorkoutEffortRelationshipQueryOptionsMostRelevant")]
    pub const MostRelevant: Self = Self(1 << 0);
}

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

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

extern_class!(
    /// A concrete subclass of HKQuery that provides an interface to observe associations with a workout sample.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/healthkit/hkworkouteffortrelationshipquery?language=objc)
    #[unsafe(super(HKQuery, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "HKQuery")]
    pub struct HKWorkoutEffortRelationshipQuery;
);

#[cfg(feature = "HKQuery")]
unsafe impl Send for HKWorkoutEffortRelationshipQuery {}

#[cfg(feature = "HKQuery")]
unsafe impl Sync for HKWorkoutEffortRelationshipQuery {}

#[cfg(feature = "HKQuery")]
extern_conformance!(
    unsafe impl NSObjectProtocol for HKWorkoutEffortRelationshipQuery {}
);

#[cfg(feature = "HKQuery")]
impl HKWorkoutEffortRelationshipQuery {
    extern_methods!(
        #[cfg(all(feature = "HKQueryAnchor", feature = "block2"))]
        /// Returns a query that will retrieve HKWorkoutEffortRelationship matching the given predicate that are
        /// newer than the given anchor.
        ///
        /// This is a long running query and it is the responsibility of the caller to stop the query
        /// after they have received the results they desire.
        /// The first call to resultsHandler will contain the inital results which may be empty and future callbacks
        /// will contain new relationships as well as any changes to previous relationships along with a new anchor
        ///
        /// Parameter `predicate`: The predicate on the workout(s) which samples should match.
        ///
        /// Parameter `anchor`: The anchor which was returned by a previous HKWorkoutEffortRelationshipQuery result or update
        /// handler.  Pass nil when querying for the first time.
        ///
        /// Parameter `options`: The options for the query, one of types from `HKWorkoutEffortRelationshipQueryOptions`
        ///
        /// Parameter `resultsHandler`: The block to invoke with related sample results
        ///
        /// # Safety
        ///
        /// `results_handler` block must be sendable.
        #[unsafe(method(initWithPredicate:anchor:options:resultsHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPredicate_anchor_options_resultsHandler(
            this: Allocated<Self>,
            predicate: Option<&NSPredicate>,
            anchor: Option<&HKQueryAnchor>,
            options: HKWorkoutEffortRelationshipQueryOptions,
            results_handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<HKWorkoutEffortRelationshipQuery>,
                    *mut NSArray<HKWorkoutEffortRelationship>,
                    *mut HKQueryAnchor,
                    *mut NSError,
                ),
            >,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `HKQuery`.
#[cfg(feature = "HKQuery")]
impl HKWorkoutEffortRelationshipQuery {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "HKQuery")]
impl HKWorkoutEffortRelationshipQuery {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}