objc2-core-motion 0.3.2

Bindings to the CoreMotion 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!(
    /// A CMDyskineticSymptomResult object describes the presence and prevalence of dyskinetic symptoms (specifically, choreiform movements) during a one minute result period when subjects wear the Apple Watch on their most affected arm.
    /// percentUnlikely + percentLikely = 1.0
    /// Please note dyskinetic symptom measurements are designed for subjects with known presence of chorea in the arm and should not be displayed to users who do not report episodes of dyskinetic symptoms.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmdyskineticsymptomresult?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CMDyskineticSymptomResult;
);

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

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

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

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

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

impl CMDyskineticSymptomResult {
    extern_methods!(
        /// The date and time representing the start of the result.
        #[unsafe(method(startDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDate(&self) -> Retained<NSDate>;

        /// The date and time representing the end of the result.
        #[unsafe(method(endDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn endDate(&self) -> Retained<NSDate>;

        /// The percentage of time dyskinetic symptoms were unlikely for the result.
        #[unsafe(method(percentUnlikely))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentUnlikely(&self) -> c_float;

        /// The percentage of time dyskinetic symptoms were likely for the result.
        #[unsafe(method(percentLikely))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentLikely(&self) -> c_float;
    );
}

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

extern_class!(
    /// A CMTremorResult object describes the presence and prevalence of tremor symptoms (specifically, resting tremor) during a one minute result period when subjects wear the Apple Watch on their most affected arm.
    /// percentUnknown + percentNoTremor + percentTremorSlight + percentTremorMild + percentTremorModerate + percentTremorStrong = 1.0
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmtremorresult?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CMTremorResult;
);

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

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

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

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

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

impl CMTremorResult {
    extern_methods!(
        /// The date and time representing the start of the result.
        #[unsafe(method(startDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDate(&self) -> Retained<NSDate>;

        /// The date and time representing the end of the result.
        #[unsafe(method(endDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn endDate(&self) -> Retained<NSDate>;

        /// The percentage of time tremor was unknown for the result.
        /// Unknown periods include times when:
        /// 1. the subject is moving and therefore a resting tremor cannot be assessed, and
        /// 2. the signal strength is too low to measure tremor confidently.
        #[unsafe(method(percentUnknown))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentUnknown(&self) -> c_float;

        /// The percentage of time no tremor was detected for the result.
        #[unsafe(method(percentNone))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentNone(&self) -> c_float;

        /// The percentage of time tremor was likely and displacement amplitude was slight for the result.
        #[unsafe(method(percentSlight))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentSlight(&self) -> c_float;

        /// The percentage of time tremor was likely and displacement amplitude was mild for the result.
        #[unsafe(method(percentMild))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentMild(&self) -> c_float;

        /// The percentage of time tremor was likely and displacement amplitude was moderate for the result.
        #[unsafe(method(percentModerate))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentModerate(&self) -> c_float;

        /// The percentage of time tremor was likely and displacement amplitude was strong for the result.
        #[unsafe(method(percentStrong))]
        #[unsafe(method_family = none)]
        pub unsafe fn percentStrong(&self) -> c_float;
    );
}

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

/// Completion handler for CMDyskineticSymptomResult values.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmdyskineticsymptomresulthandler?language=objc)
#[cfg(feature = "block2")]
pub type CMDyskineticSymptomResultHandler =
    *mut block2::DynBlock<dyn Fn(NonNull<NSArray<CMDyskineticSymptomResult>>, *mut NSError)>;

/// Completion handler for CMTremorResult values.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmtremorresulthandler?language=objc)
#[cfg(feature = "block2")]
pub type CMTremorResultHandler =
    *mut block2::DynBlock<dyn Fn(NonNull<NSArray<CMTremorResult>>, *mut NSError)>;

extern_class!(
    /// A CMMovementDisorderManager object with methods for persistence and query of movement disorder results.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmmovementdisordermanager?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CMMovementDisorderManager;
);

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

impl CMMovementDisorderManager {
    extern_methods!(
        /// Whether movement disorder results are available on this platform.
        ///
        /// Returns: Returns the availability of movement disorder results on this platform.
        #[unsafe(method(isAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAvailable() -> bool;

        /// What version of movement disorder software is available on this platform.
        ///
        /// Returns: Returns the version number of the movement disorder software available on this platform, nil if not.
        /// Format follows Major.Minor.Fix format (e.g. 1.0.0)
        #[unsafe(method(version))]
        #[unsafe(method_family = none)]
        pub unsafe fn version() -> Option<Retained<NSString>>;

        #[cfg(feature = "CMAuthorization")]
        /// Authorization status of movement disorder results for this user.
        ///
        /// Returns: Returns the authorization status of movement disorder results for this user.
        #[unsafe(method(authorizationStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorizationStatus() -> CMAuthorizationStatus;

        /// Enables the calculation and persistence of result values for the specified duration in seconds.
        ///
        /// Parameter `duration`: The duration in seconds to enable the calculation and persistence of result values.
        ///
        /// Warning: Please note that the maximum duration allowed is seven (7) days.
        #[unsafe(method(monitorKinesiasForDuration:))]
        #[unsafe(method_family = none)]
        pub unsafe fn monitorKinesiasForDuration(&self, duration: NSTimeInterval);

        #[cfg(feature = "block2")]
        /// Queries the system for result values for the specified date range.
        ///
        /// Parameter `fromDate`: The begin date for the query range.
        ///
        /// Parameter `toDate`: The end date for the query range.
        ///
        /// Parameter `handler`: The completion handler for accessing and processing result values.
        ///
        /// Warning: Please note that movement disorder results are available for a maximum of seven (7) days.
        ///
        /// # Safety
        ///
        /// `handler` must be a valid pointer.
        #[unsafe(method(queryDyskineticSymptomFromDate:toDate:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryDyskineticSymptomFromDate_toDate_withHandler(
            &self,
            from_date: &NSDate,
            to_date: &NSDate,
            handler: CMDyskineticSymptomResultHandler,
        );

        #[cfg(feature = "block2")]
        /// Queries the system for result values for the specified date range.
        ///
        /// Parameter `fromDate`: The begin date for the query range.
        ///
        /// Parameter `toDate`: The end date for the query range.
        ///
        /// Parameter `handler`: The completion handler for accessing and processing result values.
        ///
        /// Warning: Please note that movement disorder results are available for a maximum of seven (7) days.
        ///
        /// # Safety
        ///
        /// `handler` must be a valid pointer.
        #[unsafe(method(queryTremorFromDate:toDate:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryTremorFromDate_toDate_withHandler(
            &self,
            from_date: &NSDate,
            to_date: &NSDate,
            handler: CMTremorResultHandler,
        );

        /// The last time that data has been processed; queries for periods before this point will return their final results. Data after this point may become available later if monitoring is continuing.
        ///
        /// Warning: Returns nil if no data has been processed or monitoring was not enabled.
        #[unsafe(method(lastProcessedDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn lastProcessedDate(&self) -> Option<Retained<NSDate>>;

        /// The expiration date for the most recent monitoring period.
        ///
        /// Warning: Returns nil if no previous monitoring period is available.
        #[unsafe(method(monitorKinesiasExpirationDate))]
        #[unsafe(method_family = none)]
        pub unsafe fn monitorKinesiasExpirationDate(&self) -> Option<Retained<NSDate>>;
    );
}

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