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/cmheadphonedevicemotionhandler?language=objc)
#[cfg(all(feature = "CMDeviceMotion", feature = "CMLogItem", feature = "block2"))]
pub type CMHeadphoneDeviceMotionHandler =
    *mut block2::DynBlock<dyn Fn(*mut CMDeviceMotion, *mut NSError)>;

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

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

impl CMHeadphoneMotionManager {
    extern_methods!(
        #[cfg(feature = "CMAuthorization")]
        #[unsafe(method(authorizationStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorizationStatus() -> CMAuthorizationStatus;

        #[cfg(feature = "CMHeadphoneMotionManagerDelegate")]
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn CMHeadphoneMotionManagerDelegate>>>;

        #[cfg(feature = "CMHeadphoneMotionManagerDelegate")]
        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn CMHeadphoneMotionManagerDelegate>>,
        );

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

        #[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: CMHeadphoneDeviceMotionHandler,
        );

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

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

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

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