objc2-external-accessory 0.3.2

Bindings to the ExternalAccessory 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/externalaccessory/eabluetoothaccessorypickererrorcode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct EABluetoothAccessoryPickerErrorCode(pub NSInteger);
impl EABluetoothAccessoryPickerErrorCode {
    #[doc(alias = "EABluetoothAccessoryPickerAlreadyConnected")]
    pub const AlreadyConnected: Self = Self(0);
    #[doc(alias = "EABluetoothAccessoryPickerResultNotFound")]
    pub const ResultNotFound: Self = Self(1);
    #[doc(alias = "EABluetoothAccessoryPickerResultCancelled")]
    pub const ResultCancelled: Self = Self(2);
    #[doc(alias = "EABluetoothAccessoryPickerResultFailed")]
    pub const ResultFailed: Self = Self(3);
}

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

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

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/externalaccessory/eabluetoothaccessorypickererrordomain?language=objc)
    pub static EABluetoothAccessoryPickerErrorDomain: &'static NSString;
}

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

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/externalaccessory/eaaccessorydidconnectnotification?language=objc)
    pub static EAAccessoryDidConnectNotification: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/externalaccessory/eaaccessorydiddisconnectnotification?language=objc)
    pub static EAAccessoryDidDisconnectNotification: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/externalaccessory/eaaccessorykey?language=objc)
    pub static EAAccessoryKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/externalaccessory/eaaccessoryselectedkey?language=objc)
    pub static EAAccessorySelectedKey: &'static NSString;
}

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

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

impl EAAccessoryManager {
    extern_methods!(
        #[unsafe(method(sharedAccessoryManager))]
        #[unsafe(method_family = none)]
        pub unsafe fn sharedAccessoryManager() -> Retained<EAAccessoryManager>;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `completion` must be a valid pointer or null.
        #[unsafe(method(showBluetoothAccessoryPickerWithNameFilter:completion:))]
        #[unsafe(method_family = none)]
        pub unsafe fn showBluetoothAccessoryPickerWithNameFilter_completion(
            &self,
            predicate: Option<&NSPredicate>,
            completion: EABluetoothAccessoryPickerCompletion,
        );

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

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

        #[cfg(feature = "EAAccessory")]
        #[unsafe(method(connectedAccessories))]
        #[unsafe(method_family = none)]
        pub unsafe fn connectedAccessories(&self) -> Retained<NSArray<EAAccessory>>;
    );
}

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