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

/// [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmaccelerometerhandler?language=objc)
#[cfg(all(feature = "CMAccelerometer", feature = "CMLogItem", feature = "block2"))]
pub type CMAccelerometerHandler =
    *mut block2::DynBlock<dyn Fn(*mut CMAccelerometerData, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmgyrohandler?language=objc)
#[cfg(all(feature = "CMGyro", feature = "CMLogItem", feature = "block2"))]
pub type CMGyroHandler = *mut block2::DynBlock<dyn Fn(*mut CMGyroData, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmdevicemotionhandler?language=objc)
#[cfg(all(feature = "CMDeviceMotion", feature = "CMLogItem", feature = "block2"))]
pub type CMDeviceMotionHandler = *mut block2::DynBlock<dyn Fn(*mut CMDeviceMotion, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmmagnetometerhandler?language=objc)
#[cfg(all(feature = "CMLogItem", feature = "CMMagnetometer", feature = "block2"))]
pub type CMMagnetometerHandler =
    *mut block2::DynBlock<dyn Fn(*mut CMMagnetometerData, *mut NSError)>;

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

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

impl CMMotionManager {
    extern_methods!(
        #[unsafe(method(accelerometerUpdateInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn accelerometerUpdateInterval(&self) -> NSTimeInterval;

        /// Setter for [`accelerometerUpdateInterval`][Self::accelerometerUpdateInterval].
        #[unsafe(method(setAccelerometerUpdateInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAccelerometerUpdateInterval(
            &self,
            accelerometer_update_interval: NSTimeInterval,
        );

        #[unsafe(method(isAccelerometerAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAccelerometerAvailable(&self) -> bool;

        #[unsafe(method(isAccelerometerActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAccelerometerActive(&self) -> bool;

        #[cfg(all(feature = "CMAccelerometer", feature = "CMLogItem"))]
        #[unsafe(method(accelerometerData))]
        #[unsafe(method_family = none)]
        pub unsafe fn accelerometerData(&self) -> Option<Retained<CMAccelerometerData>>;

        #[unsafe(method(startAccelerometerUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn startAccelerometerUpdates(&self);

        #[cfg(all(feature = "CMAccelerometer", feature = "CMLogItem", feature = "block2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(startAccelerometerUpdatesToQueue:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startAccelerometerUpdatesToQueue_withHandler(
            &self,
            queue: &NSOperationQueue,
            handler: CMAccelerometerHandler,
        );

        #[unsafe(method(stopAccelerometerUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopAccelerometerUpdates(&self);

        #[unsafe(method(gyroUpdateInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn gyroUpdateInterval(&self) -> NSTimeInterval;

        /// Setter for [`gyroUpdateInterval`][Self::gyroUpdateInterval].
        #[unsafe(method(setGyroUpdateInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGyroUpdateInterval(&self, gyro_update_interval: NSTimeInterval);

        #[unsafe(method(isGyroAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isGyroAvailable(&self) -> bool;

        #[unsafe(method(isGyroActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isGyroActive(&self) -> bool;

        #[cfg(all(feature = "CMGyro", feature = "CMLogItem"))]
        #[unsafe(method(gyroData))]
        #[unsafe(method_family = none)]
        pub unsafe fn gyroData(&self) -> Option<Retained<CMGyroData>>;

        #[unsafe(method(startGyroUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn startGyroUpdates(&self);

        #[cfg(all(feature = "CMGyro", feature = "CMLogItem", feature = "block2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(startGyroUpdatesToQueue:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startGyroUpdatesToQueue_withHandler(
            &self,
            queue: &NSOperationQueue,
            handler: CMGyroHandler,
        );

        #[unsafe(method(stopGyroUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopGyroUpdates(&self);

        #[unsafe(method(magnetometerUpdateInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn magnetometerUpdateInterval(&self) -> NSTimeInterval;

        /// Setter for [`magnetometerUpdateInterval`][Self::magnetometerUpdateInterval].
        #[unsafe(method(setMagnetometerUpdateInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMagnetometerUpdateInterval(
            &self,
            magnetometer_update_interval: NSTimeInterval,
        );

        #[unsafe(method(isMagnetometerAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isMagnetometerAvailable(&self) -> bool;

        #[unsafe(method(isMagnetometerActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isMagnetometerActive(&self) -> bool;

        #[cfg(all(feature = "CMLogItem", feature = "CMMagnetometer"))]
        #[unsafe(method(magnetometerData))]
        #[unsafe(method_family = none)]
        pub unsafe fn magnetometerData(&self) -> Option<Retained<CMMagnetometerData>>;

        #[unsafe(method(startMagnetometerUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn startMagnetometerUpdates(&self);

        #[cfg(all(feature = "CMLogItem", feature = "CMMagnetometer", feature = "block2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(startMagnetometerUpdatesToQueue:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startMagnetometerUpdatesToQueue_withHandler(
            &self,
            queue: &NSOperationQueue,
            handler: CMMagnetometerHandler,
        );

        #[unsafe(method(stopMagnetometerUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopMagnetometerUpdates(&self);

        #[unsafe(method(deviceMotionUpdateInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn deviceMotionUpdateInterval(&self) -> NSTimeInterval;

        /// Setter for [`deviceMotionUpdateInterval`][Self::deviceMotionUpdateInterval].
        #[unsafe(method(setDeviceMotionUpdateInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDeviceMotionUpdateInterval(
            &self,
            device_motion_update_interval: NSTimeInterval,
        );

        #[cfg(feature = "CMAttitude")]
        #[unsafe(method(availableAttitudeReferenceFrames))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableAttitudeReferenceFrames() -> CMAttitudeReferenceFrame;

        #[cfg(feature = "CMAttitude")]
        #[unsafe(method(attitudeReferenceFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn attitudeReferenceFrame(&self) -> CMAttitudeReferenceFrame;

        #[unsafe(method(isDeviceMotionAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isDeviceMotionAvailable(&self) -> bool;

        #[unsafe(method(isDeviceMotionActive))]
        #[unsafe(method_family = none)]
        pub unsafe fn isDeviceMotionActive(&self) -> bool;

        #[cfg(all(feature = "CMDeviceMotion", feature = "CMLogItem"))]
        #[unsafe(method(deviceMotion))]
        #[unsafe(method_family = none)]
        pub unsafe fn deviceMotion(&self) -> Option<Retained<CMDeviceMotion>>;

        #[unsafe(method(startDeviceMotionUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDeviceMotionUpdates(&self);

        #[cfg(all(feature = "CMDeviceMotion", feature = "CMLogItem", feature = "block2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(startDeviceMotionUpdatesToQueue:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDeviceMotionUpdatesToQueue_withHandler(
            &self,
            queue: &NSOperationQueue,
            handler: CMDeviceMotionHandler,
        );

        #[cfg(feature = "CMAttitude")]
        #[unsafe(method(startDeviceMotionUpdatesUsingReferenceFrame:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDeviceMotionUpdatesUsingReferenceFrame(
            &self,
            reference_frame: CMAttitudeReferenceFrame,
        );

        #[cfg(all(
            feature = "CMAttitude",
            feature = "CMDeviceMotion",
            feature = "CMLogItem",
            feature = "block2"
        ))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(startDeviceMotionUpdatesUsingReferenceFrame:toQueue:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startDeviceMotionUpdatesUsingReferenceFrame_toQueue_withHandler(
            &self,
            reference_frame: CMAttitudeReferenceFrame,
            queue: &NSOperationQueue,
            handler: CMDeviceMotionHandler,
        );

        #[unsafe(method(stopDeviceMotionUpdates))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopDeviceMotionUpdates(&self);

        #[unsafe(method(showsDeviceMovementDisplay))]
        #[unsafe(method_family = none)]
        pub unsafe fn showsDeviceMovementDisplay(&self) -> bool;

        /// Setter for [`showsDeviceMovementDisplay`][Self::showsDeviceMovementDisplay].
        #[unsafe(method(setShowsDeviceMovementDisplay:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setShowsDeviceMovementDisplay(&self, shows_device_movement_display: bool);
    );
}

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