1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBCharacteristicProperties(pub NSUInteger);
bitflags::bitflags! {
    impl CBCharacteristicProperties: NSUInteger {
        const CBCharacteristicPropertyBroadcast = 0x01;
        const CBCharacteristicPropertyRead = 0x02;
        const CBCharacteristicPropertyWriteWithoutResponse = 0x04;
        const CBCharacteristicPropertyWrite = 0x08;
        const CBCharacteristicPropertyNotify = 0x10;
        const CBCharacteristicPropertyIndicate = 0x20;
        const CBCharacteristicPropertyAuthenticatedSignedWrites = 0x40;
        const CBCharacteristicPropertyExtendedProperties = 0x80;
        const CBCharacteristicPropertyNotifyEncryptionRequired = 0x100;
        const CBCharacteristicPropertyIndicateEncryptionRequired = 0x200;
    }
}

unsafe impl Encode for CBCharacteristicProperties {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CBAttribute")]
    pub struct CBCharacteristic;

    #[cfg(feature = "CBAttribute")]
    unsafe impl ClassType for CBCharacteristic {
        #[inherits(NSObject)]
        type Super = CBAttribute;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "CBAttribute")]
unsafe impl NSObjectProtocol for CBCharacteristic {}

extern_methods!(
    #[cfg(feature = "CBAttribute")]
    unsafe impl CBCharacteristic {
        #[cfg(feature = "CBService")]
        #[method_id(@__retain_semantics Other service)]
        pub unsafe fn service(&self) -> Option<Retained<CBService>>;

        #[method(properties)]
        pub unsafe fn properties(&self) -> CBCharacteristicProperties;

        #[method_id(@__retain_semantics Other value)]
        pub unsafe fn value(&self) -> Option<Retained<NSData>>;

        #[cfg(feature = "CBDescriptor")]
        #[method_id(@__retain_semantics Other descriptors)]
        pub unsafe fn descriptors(&self) -> Option<Retained<NSArray<CBDescriptor>>>;

        #[deprecated]
        #[method(isBroadcasted)]
        pub unsafe fn isBroadcasted(&self) -> bool;

        #[method(isNotifying)]
        pub unsafe fn isNotifying(&self) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `CBAttribute`
    #[cfg(feature = "CBAttribute")]
    unsafe impl CBCharacteristic {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "CBAttribute")]
    unsafe impl CBCharacteristic {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBAttributePermissions(pub NSUInteger);
bitflags::bitflags! {
    impl CBAttributePermissions: NSUInteger {
        #[doc(alias = "CBAttributePermissionsReadable")]
        const Readable = 0x01;
        #[doc(alias = "CBAttributePermissionsWriteable")]
        const Writeable = 0x02;
        #[doc(alias = "CBAttributePermissionsReadEncryptionRequired")]
        const ReadEncryptionRequired = 0x04;
        #[doc(alias = "CBAttributePermissionsWriteEncryptionRequired")]
        const WriteEncryptionRequired = 0x08;
    }
}

unsafe impl Encode for CBAttributePermissions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CBAttribute")]
    pub struct CBMutableCharacteristic;

    #[cfg(feature = "CBAttribute")]
    unsafe impl ClassType for CBMutableCharacteristic {
        #[inherits(CBAttribute, NSObject)]
        type Super = CBCharacteristic;
        type Mutability = InteriorMutable;
    }
);

#[cfg(feature = "CBAttribute")]
unsafe impl NSObjectProtocol for CBMutableCharacteristic {}

extern_methods!(
    #[cfg(feature = "CBAttribute")]
    unsafe impl CBMutableCharacteristic {
        #[method(permissions)]
        pub unsafe fn permissions(&self) -> CBAttributePermissions;

        #[method(setPermissions:)]
        pub unsafe fn setPermissions(&self, permissions: CBAttributePermissions);

        #[cfg(all(feature = "CBCentral", feature = "CBPeer"))]
        #[method_id(@__retain_semantics Other subscribedCentrals)]
        pub unsafe fn subscribedCentrals(&self) -> Option<Retained<NSArray<CBCentral>>>;

        #[method(properties)]
        pub unsafe fn properties(&self) -> CBCharacteristicProperties;

        #[method(setProperties:)]
        pub unsafe fn setProperties(&self, properties: CBCharacteristicProperties);

        #[method_id(@__retain_semantics Other value)]
        pub unsafe fn value(&self) -> Option<Retained<NSData>>;

        #[method(setValue:)]
        pub unsafe fn setValue(&self, value: Option<&NSData>);

        #[cfg(feature = "CBDescriptor")]
        #[method_id(@__retain_semantics Other descriptors)]
        pub unsafe fn descriptors(&self) -> Option<Retained<NSArray<CBDescriptor>>>;

        #[cfg(feature = "CBDescriptor")]
        #[method(setDescriptors:)]
        pub unsafe fn setDescriptors(&self, descriptors: Option<&NSArray<CBDescriptor>>);

        #[cfg(feature = "CBUUID")]
        #[method_id(@__retain_semantics Init initWithType:properties:value:permissions:)]
        pub unsafe fn initWithType_properties_value_permissions(
            this: Allocated<Self>,
            uuid: &CBUUID,
            properties: CBCharacteristicProperties,
            value: Option<&NSData>,
            permissions: CBAttributePermissions,
        ) -> Retained<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `CBAttribute`
    #[cfg(feature = "CBAttribute")]
    unsafe impl CBMutableCharacteristic {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(feature = "CBAttribute")]
    unsafe impl CBMutableCharacteristic {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Retained<Self>;
    }
);