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
84extern_conformance!(
85    unsafe impl NSObjectProtocol for CBManager {}
86);
87
88impl CBManager {
89    extern_methods!(
90        #[unsafe(method(init))]
91        #[unsafe(method_family = init)]
92        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
93
94        /// The current state of the manager, initially set to
95        /// <code>
96        /// CBManagerStateUnknown
97        /// </code>
98        /// .
99        /// Updates are provided by required delegate method {
100        ///
101        /// ```text
102        ///  managerDidUpdateState:}.
103        ///
104        ///  
105        ///
106        /// ```
107        #[unsafe(method(state))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn state(&self) -> CBManagerState;
110
111        /// The current authorization of the manager, initially set to
112        /// <code>
113        /// CBManagerAuthorizationNotDetermined
114        /// </code>
115        /// .
116        /// Updates are provided by required delegate method {
117        ///
118        /// ```text
119        ///  managerDidUpdateState:}.
120        ///   @seealso    state
121        ///  
122        ///
123        /// ```
124        #[deprecated]
125        #[unsafe(method(authorization))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn authorization(&self) -> CBManagerAuthorization;
128
129        /// The current authorization of the manager, initially set to
130        /// <code>
131        /// CBManagerAuthorizationNotDetermined
132        /// </code>
133        /// .
134        /// You can check this in your implementation of required delegate method {
135        ///
136        /// ```text
137        ///  managerDidUpdateState:}. You can also use it to check authorization status before allocating CBManager.
138        ///   @seealso    state
139        ///  
140        ///
141        /// ```
142        #[unsafe(method(authorization))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn authorization_class() -> CBManagerAuthorization;
145    );
146}
147
148/// Methods declared on superclass `NSObject`.
149impl CBManager {
150    extern_methods!(
151        #[unsafe(method(new))]
152        #[unsafe(method_family = new)]
153        pub unsafe fn new() -> Retained<Self>;
154    );
155}