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

/// [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmstepupdatehandler?language=objc)
#[cfg(feature = "block2")]
pub type CMStepUpdateHandler =
    *mut block2::DynBlock<dyn Fn(NSInteger, NonNull<NSDate>, *mut NSError)>;

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

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

impl CMStepCounter {
    extern_methods!(
        #[unsafe(method(isStepCountingAvailable))]
        #[unsafe(method_family = none)]
        pub unsafe fn isStepCountingAvailable() -> bool;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(queryStepCountStartingFrom:to:toQueue:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn queryStepCountStartingFrom_to_toQueue_withHandler(
            &self,
            start: &NSDate,
            end: &NSDate,
            queue: &NSOperationQueue,
            handler: CMStepQueryHandler,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `handler` must be a valid pointer.
        #[unsafe(method(startStepCountingUpdatesToQueue:updateOn:withHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startStepCountingUpdatesToQueue_updateOn_withHandler(
            &self,
            queue: &NSOperationQueue,
            step_counts: NSInteger,
            handler: CMStepUpdateHandler,
        );

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

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