//! 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 crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbackgroundactivityresult?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSBackgroundActivityResult(pub NSInteger);
impl NSBackgroundActivityResult {
    #[doc(alias = "NSBackgroundActivityResultFinished")]
    pub const Finished: Self = Self(1);
    #[doc(alias = "NSBackgroundActivityResultDeferred")]
    pub const Deferred: Self = Self(2);
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsbackgroundactivitycompletionhandler?language=objc)
#[cfg(feature = "block2")]
pub type NSBackgroundActivityCompletionHandler =
    *mut block2::DynBlock<dyn Fn(NSBackgroundActivityResult)>;

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

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

impl NSBackgroundActivityScheduler {
    extern_methods!(
        #[cfg(feature = "NSString")]
        #[unsafe(method(initWithIdentifier:))]
        #[unsafe(method_family = init)]
        pub fn initWithIdentifier(this: Allocated<Self>, identifier: &NSString) -> Retained<Self>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub fn identifier(&self) -> Retained<NSString>;

        #[cfg(feature = "NSObjCRuntime")]
        #[unsafe(method(qualityOfService))]
        #[unsafe(method_family = none)]
        pub fn qualityOfService(&self) -> NSQualityOfService;

        #[cfg(feature = "NSObjCRuntime")]
        /// Setter for [`qualityOfService`][Self::qualityOfService].
        #[unsafe(method(setQualityOfService:))]
        #[unsafe(method_family = none)]
        pub fn setQualityOfService(&self, quality_of_service: NSQualityOfService);

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

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

        #[cfg(feature = "NSDate")]
        #[unsafe(method(interval))]
        #[unsafe(method_family = none)]
        pub fn interval(&self) -> NSTimeInterval;

        #[cfg(feature = "NSDate")]
        /// Setter for [`interval`][Self::interval].
        #[unsafe(method(setInterval:))]
        #[unsafe(method_family = none)]
        pub fn setInterval(&self, interval: NSTimeInterval);

        #[cfg(feature = "NSDate")]
        #[unsafe(method(tolerance))]
        #[unsafe(method_family = none)]
        pub fn tolerance(&self) -> NSTimeInterval;

        #[cfg(feature = "NSDate")]
        /// Setter for [`tolerance`][Self::tolerance].
        #[unsafe(method(setTolerance:))]
        #[unsafe(method_family = none)]
        pub fn setTolerance(&self, tolerance: NSTimeInterval);

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `block` block must be sendable.
        #[unsafe(method(scheduleWithBlock:))]
        #[unsafe(method_family = none)]
        pub unsafe fn scheduleWithBlock(
            &self,
            block: &block2::DynBlock<dyn Fn(NSBackgroundActivityCompletionHandler)>,
        );

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

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

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

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSBackgroundActivityScheduler {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
