objc2_accessory_setup_kit/generated/
ASAccessory.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// A type that defines values for the state of an accessory.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessorystate?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct ASAccessoryState(pub NSInteger);
16impl ASAccessoryState {
17    /// The accessory is invalid or unauthorized.
18    #[doc(alias = "ASAccessoryStateUnauthorized")]
19    pub const Unauthorized: Self = Self(0);
20    /// The accessory is selected, but full authorization is still pending.
21    #[doc(alias = "ASAccessoryStateAwaitingAuthorization")]
22    pub const AwaitingAuthorization: Self = Self(10);
23    /// The accessory is authorized and available.
24    #[doc(alias = "ASAccessoryStateAuthorized")]
25    pub const Authorized: Self = Self(20);
26}
27
28unsafe impl Encode for ASAccessoryState {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for ASAccessoryState {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36/// Accessory Rename Options
37///
38/// See also [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessoryrenameoptions?language=objc)
39// NS_OPTIONS
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct ASAccessoryRenameOptions(pub NSUInteger);
43bitflags::bitflags! {
44    impl ASAccessoryRenameOptions: NSUInteger {
45/// An option to change an accessory's SSID along with its display name.
46        #[doc(alias = "ASAccessoryRenameSSID")]
47        const SSID = 1<<0;
48    }
49}
50
51unsafe impl Encode for ASAccessoryRenameOptions {
52    const ENCODING: Encoding = NSUInteger::ENCODING;
53}
54
55unsafe impl RefEncode for ASAccessoryRenameOptions {
56    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59/// Accessory Support Options
60///
61/// See also [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessorysupportoptions?language=objc)
62// NS_OPTIONS
63#[repr(transparent)]
64#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
65pub struct ASAccessorySupportOptions(pub NSUInteger);
66bitflags::bitflags! {
67    impl ASAccessorySupportOptions: NSUInteger {
68/// The accessory supports Bluetooth Low Energy pairing.
69        #[doc(alias = "ASAccessorySupportBluetoothPairingLE")]
70        const BluetoothPairingLE = 1<<1;
71/// The accessory supports bridging to Bluetooth classic transport.
72///
73/// This option indicates that when connecting with low energy transport, the accessory supports activating Bluetooth classic transport profiles.
74        #[doc(alias = "ASAccessorySupportBluetoothTransportBridging")]
75        const BluetoothTransportBridging = 1<<2;
76/// The accessory supports Bluetooth Low Energy HID service.
77        #[doc(alias = "ASAccessorySupportBluetoothHID")]
78        const BluetoothHID = 1<<3;
79    }
80}
81
82unsafe impl Encode for ASAccessorySupportOptions {
83    const ENCODING: Encoding = NSUInteger::ENCODING;
84}
85
86unsafe impl RefEncode for ASAccessorySupportOptions {
87    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
88}
89
90/// [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessorywifiawarepaireddeviceid?language=objc)
91pub type ASAccessoryWiFiAwarePairedDeviceID = u64;
92
93extern_class!(
94    /// [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessory?language=objc)
95    #[unsafe(super(NSObject))]
96    #[derive(Debug, PartialEq, Eq, Hash)]
97    pub struct ASAccessory;
98);
99
100unsafe impl Send for ASAccessory {}
101
102unsafe impl Sync for ASAccessory {}
103
104extern_conformance!(
105    unsafe impl NSObjectProtocol for ASAccessory {}
106);
107
108impl ASAccessory {
109    extern_methods!(
110        /// The current authorization state of the accessory.
111        ///
112        /// This property is not atomic.
113        ///
114        /// # Safety
115        ///
116        /// This might not be thread-safe.
117        #[unsafe(method(state))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn state(&self) -> ASAccessoryState;
120
121        /// The accessory's unique Bluetooth identifier, if any.
122        ///
123        /// Use this identifier to establish a connection to the accessory.
124        ///
125        /// This property is not atomic.
126        ///
127        /// # Safety
128        ///
129        /// This might not be thread-safe.
130        #[unsafe(method(bluetoothIdentifier))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn bluetoothIdentifier(&self) -> Option<Retained<NSUUID>>;
133
134        /// The accessory's Bluetooth identifier, if any, for use when bridging classic transport profiles.
135        ///
136        /// This property is not atomic.
137        ///
138        /// # Safety
139        ///
140        /// This might not be thread-safe.
141        #[unsafe(method(bluetoothTransportBridgingIdentifier))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn bluetoothTransportBridgingIdentifier(&self) -> Option<Retained<NSData>>;
144
145        /// The accessory's name, suitable for displaying to someone using your app.
146        ///
147        /// This property is not atomic.
148        ///
149        /// # Safety
150        ///
151        /// This might not be thread-safe.
152        #[unsafe(method(displayName))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn displayName(&self) -> Retained<NSString>;
155
156        /// The accessory's Wi-Fi SSID, if any.
157        ///
158        /// Use this identifier to establish a connection to the accessory.
159        ///
160        /// This property is not atomic.
161        ///
162        /// # Safety
163        ///
164        /// This might not be thread-safe.
165        #[unsafe(method(SSID))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn SSID(&self) -> Option<Retained<NSString>>;
168
169        /// The accessory's Wi-Fi Aware Pairing Identifier.
170        ///
171        /// Use this identifier to establish a connection to the accessory using Wi-Fi Aware Framework.
172        ///
173        /// This property is not atomic.
174        ///
175        /// # Safety
176        ///
177        /// This might not be thread-safe.
178        #[unsafe(method(wifiAwarePairedDeviceID))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn wifiAwarePairedDeviceID(&self) -> ASAccessoryWiFiAwarePairedDeviceID;
181
182        #[cfg(feature = "ASDiscoveryDescriptor")]
183        /// The descriptor used to discover the accessory.
184        ///
185        /// This property is not atomic.
186        ///
187        /// # Safety
188        ///
189        /// This might not be thread-safe.
190        #[unsafe(method(descriptor))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn descriptor(&self) -> Retained<ASDiscoveryDescriptor>;
193    );
194}
195
196/// Methods declared on superclass `NSObject`.
197impl ASAccessory {
198    extern_methods!(
199        #[unsafe(method(init))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
202
203        #[unsafe(method(new))]
204        #[unsafe(method_family = new)]
205        pub unsafe fn new() -> Retained<Self>;
206    );
207}