objc2_core_bluetooth/generated/
CBManager.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::*;
5
6use crate::*;
7
8/// Represents the current state of a CBManager.
9///
10///
11///
12///
13///
14///
15///
16///
17/// See also: authorization
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmanagerstate?language=objc)
20// NS_ENUM
21#[repr(transparent)]
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
23pub struct CBManagerState(pub NSInteger);
24impl CBManagerState {
25    #[doc(alias = "CBManagerStateUnknown")]
26    pub const Unknown: Self = Self(0);
27    #[doc(alias = "CBManagerStateResetting")]
28    pub const Resetting: Self = Self(1);
29    #[doc(alias = "CBManagerStateUnsupported")]
30    pub const Unsupported: Self = Self(2);
31    #[doc(alias = "CBManagerStateUnauthorized")]
32    pub const Unauthorized: Self = Self(3);
33    #[doc(alias = "CBManagerStatePoweredOff")]
34    pub const PoweredOff: Self = Self(4);
35    #[doc(alias = "CBManagerStatePoweredOn")]
36    pub const PoweredOn: Self = Self(5);
37}
38
39unsafe impl Encode for CBManagerState {
40    const ENCODING: Encoding = NSInteger::ENCODING;
41}
42
43unsafe impl RefEncode for CBManagerState {
44    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
45}
46
47/// Represents the current authorization state of a CBManager.
48///
49///
50///
51/// possibly due to active restrictions such as parental controls being in place.
52///
53/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmanagerauthorization?language=objc)
54// NS_ENUM
55#[repr(transparent)]
56#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
57pub struct CBManagerAuthorization(pub NSInteger);
58impl CBManagerAuthorization {
59    #[doc(alias = "CBManagerAuthorizationNotDetermined")]
60    pub const NotDetermined: Self = Self(0);
61    #[doc(alias = "CBManagerAuthorizationRestricted")]
62    pub const Restricted: Self = Self(1);
63    #[doc(alias = "CBManagerAuthorizationDenied")]
64    pub const Denied: Self = Self(2);
65    #[doc(alias = "CBManagerAuthorizationAllowedAlways")]
66    pub const AllowedAlways: Self = Self(3);
67}
68
69unsafe impl Encode for CBManagerAuthorization {
70    const ENCODING: Encoding = NSInteger::ENCODING;
71}
72
73unsafe impl RefEncode for CBManagerAuthorization {
74    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
75}
76
77extern_class!(
78    /// [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmanager?language=objc)
79    #[unsafe(super(NSObject))]
80    #[derive(Debug, PartialEq, Eq, Hash)]
81    pub struct CBManager;
82);
83
84unsafe impl NSObjectProtocol for CBManager {}
85
86impl CBManager {
87    extern_methods!(
88        #[unsafe(method(init))]
89        #[unsafe(method_family = init)]
90        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
91
92        /// The current state of the manager, initially set to
93        /// <code>
94        /// CBManagerStateUnknown
95        /// </code>
96        /// .
97        /// Updates are provided by required delegate method {
98        ///
99        /// ```text
100        ///  managerDidUpdateState:}.
101        ///
102        ///  
103        ///
104        /// ```
105        #[unsafe(method(state))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn state(&self) -> CBManagerState;
108
109        /// The current authorization of the manager, initially set to
110        /// <code>
111        /// CBManagerAuthorizationNotDetermined
112        /// </code>
113        /// .
114        /// Updates are provided by required delegate method {
115        ///
116        /// ```text
117        ///  managerDidUpdateState:}.
118        ///   @seealso    state
119        ///  
120        ///
121        /// ```
122        #[deprecated]
123        #[unsafe(method(authorization))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn authorization(&self) -> CBManagerAuthorization;
126
127        /// The current authorization of the manager, initially set to
128        /// <code>
129        /// CBManagerAuthorizationNotDetermined
130        /// </code>
131        /// .
132        /// You can check this in your implementation of required delegate method {
133        ///
134        /// ```text
135        ///  managerDidUpdateState:}. You can also use it to check authorization status before allocating CBManager.
136        ///   @seealso    state
137        ///  
138        ///
139        /// ```
140        #[unsafe(method(authorization))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn authorization_class() -> CBManagerAuthorization;
143    );
144}
145
146/// Methods declared on superclass `NSObject`.
147impl CBManager {
148    extern_methods!(
149        #[unsafe(method(new))]
150        #[unsafe(method_family = new)]
151        pub unsafe fn new() -> Retained<Self>;
152    );
153}