objc2-core-bluetooth 0.3.2

Bindings to the CoreBluetooth framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// Represents the current state of a CBManager.
///
///
///
///
///
///
///
///
/// See also: authorization
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmanagerstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBManagerState(pub NSInteger);
impl CBManagerState {
    #[doc(alias = "CBManagerStateUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "CBManagerStateResetting")]
    pub const Resetting: Self = Self(1);
    #[doc(alias = "CBManagerStateUnsupported")]
    pub const Unsupported: Self = Self(2);
    #[doc(alias = "CBManagerStateUnauthorized")]
    pub const Unauthorized: Self = Self(3);
    #[doc(alias = "CBManagerStatePoweredOff")]
    pub const PoweredOff: Self = Self(4);
    #[doc(alias = "CBManagerStatePoweredOn")]
    pub const PoweredOn: Self = Self(5);
}

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

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

/// Represents the current authorization state of a CBManager.
///
///
///
/// possibly due to active restrictions such as parental controls being in place.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmanagerauthorization?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBManagerAuthorization(pub NSInteger);
impl CBManagerAuthorization {
    #[doc(alias = "CBManagerAuthorizationNotDetermined")]
    pub const NotDetermined: Self = Self(0);
    #[doc(alias = "CBManagerAuthorizationRestricted")]
    pub const Restricted: Self = Self(1);
    #[doc(alias = "CBManagerAuthorizationDenied")]
    pub const Denied: Self = Self(2);
    #[doc(alias = "CBManagerAuthorizationAllowedAlways")]
    pub const AllowedAlways: Self = Self(3);
}

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

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

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

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

impl CBManager {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// The current state of the manager, initially set to
        /// <code>
        /// CBManagerStateUnknown
        /// </code>
        /// .
        /// Updates are provided by required delegate method {
        ///
        /// ```text
        ///  managerDidUpdateState:}.
        ///
        ///  
        ///
        /// ```
        #[unsafe(method(state))]
        #[unsafe(method_family = none)]
        pub unsafe fn state(&self) -> CBManagerState;

        /// The current authorization of the manager, initially set to
        /// <code>
        /// CBManagerAuthorizationNotDetermined
        /// </code>
        /// .
        /// Updates are provided by required delegate method {
        ///
        /// ```text
        ///  managerDidUpdateState:}.
        ///   @seealso    state
        ///  
        ///
        /// ```
        #[deprecated]
        #[unsafe(method(authorization))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorization(&self) -> CBManagerAuthorization;

        /// The current authorization of the manager, initially set to
        /// <code>
        /// CBManagerAuthorizationNotDetermined
        /// </code>
        /// .
        /// You can check this in your implementation of required delegate method {
        ///
        /// ```text
        ///  managerDidUpdateState:}. You can also use it to check authorization status before allocating CBManager.
        ///   @seealso    state
        ///  
        ///
        /// ```
        #[unsafe(method(authorization))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorization_class() -> CBManagerAuthorization;
    );
}

/// Methods declared on superclass `NSObject`.
impl CBManager {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}