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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;
use crate::*;
extern_class!(
/// An instance of this class represents a single SDP data element as defined by the Bluetooth SDP spec.
///
/// The data types described by the spec have been mapped onto the base Foundation classes NSNumber,
/// NSArray, NSData as well as IOBluetoothSDPUUID. The number and boolean types (type descriptor 1, 2
/// and 5) are represented as NSNumber objects with the exception of 128-bit numbers which are
/// represented as NSData objects in their raw format. The UUID type (type descriptor 3) is
/// represented by IOBluetoothSDPUUID. The string and URL types (type descriptor 4 and 8) are
/// represented by NSString. The sequence types (type descriptor 6 and 7) are represented by NSArray.
///
/// Typically, you will not need to create an IOBluetoothSDPDataElement directly, the system will
/// do that automatically for both client and server operations. However, the current API for adding
/// SDP services to the system does allow the use of an NSDictionary based format for creating new
/// services. The purpose for that is to allow a service to be built up completely in a text file
/// (a plist for example) and then easily imported into an app and added to the system without a
/// lot of tedious code to build up the entire SDP service record.
///
/// The basis for that NSDictionary structure comes from the IOBluetoothSDPDataElement. At its
/// simplest, a data element is made up of three parts: the type descriptor, the size (from which
/// the size descriptor is generated) and the actual value. To provide a complete representation
/// of a data element, an NSDictionary with three entries can be used. Each of the three entries
/// has a key/value pair representing one of the three attributes of a data element. The first
/// key/value pair has a key 'DataElementType' that contains a number value with the actual
/// type descriptor for the data element. The second pair has a key 'DataElementSize' that
/// contains the actual size of the element in bytes. The size descriptor will be calculated
/// based on the size and type of the element. The third pair is the value itself whose key is
/// 'DataElementValue' and whose type corresponds to the type mapping above.
///
/// In addition to this complete description of a data element, their are some shortcuts that
/// can be used for some of the common types and sizes.
///
/// If the 'DataElementType' value is one of the numeric types (1, 2), the 'DataElementValue'
/// can be an NSData instead of an NSNumber. In that case, the numeric data is taken in network
/// byte order (MSB first). Additionally, the 'DataElementSize' parameter may be omitted and the
/// size will be taken from the length of the data object.
///
/// If the 'DataElementType' value is the nil type (0), no 'DataElementSize' or 'DataElementValue'
/// entries are needed.
///
/// If the 'DataElementType' value is any of the other types, the 'DataElementSize' entry is not
/// needed since the size will be taken directly from the value (data, array, string).
///
/// In the case where the element is an unsigned, 32-bit integer (type descriptor 1, size descriptor
/// 4), the value itself may simply be a number (instead of a dictionary as in the previous examples).
///
/// In the case where the element is a UUID (type descriptor 3), the value itself may be a data object.
/// The UUID type will be inferred and the size taken from the length of the data object.
///
/// In the case where the element is a text string (type descriptor 4), the value may be a string object.
/// The text string type will be inferred and the size taken from the length of the string.
///
/// In the case where the element is a data element sequence, the value may be an array object. The
/// type will be inferred and the size taken from the length of the array. Additionally, the array
/// must contain sub-elements that will be parsed out individually.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothsdpdataelement?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct IOBluetoothSDPDataElement;
);
#[cfg(feature = "objc2-foundation")]
extern_conformance!(
unsafe impl NSCoding for IOBluetoothSDPDataElement {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for IOBluetoothSDPDataElement {}
);
#[cfg(feature = "objc2-foundation")]
extern_conformance!(
unsafe impl NSSecureCoding for IOBluetoothSDPDataElement {}
);
impl IOBluetoothSDPDataElement {
extern_methods!(
/// Creates a new IOBluetoothSDPDataElement with the given value.
///
/// The value must follow the format listed above and must be an instance of NSData, NSString, NSNumber,
/// NSArray, NSDictionary, IOBluetoothSDPUUID.
///
/// Parameter `element`: The data element value of one of the specified types.
///
/// Returns: Returns the newly allocated data element object. Returns nil if there was an error parsing the element
/// value. The returned IOBluetoothSDPDataElement object has been autoreleased, so it is not necessary
/// for the caller to release it. If the object is to be referenced and kept around, retain should be
/// called.
///
/// # Safety
///
/// - `element` should be of the correct type.
/// - `element` might not allow `None`.
#[unsafe(method(withElementValue:))]
#[unsafe(method_family = none)]
pub unsafe fn withElementValue(element: Option<&NSObject>) -> Option<Retained<Self>>;
#[cfg(feature = "Bluetooth")]
/// Creates a new IOBluetoothSDPDataElement with the given attributes.
///
/// Warning - be careful using this method. There is next to no error checking done on the
/// attributes. It is entirely possible to construct an invalid data element. It is recommended
/// that +withElementValue: be used instead of this one.
///
/// Parameter `typeDescriptor`: The type descriptor for the data element.
///
/// Parameter `sizeDescriptor`: The size descriptor for the data element (verify it matches the size parameter).
///
/// Parameter `size`: The size of the data element in bytes (make sure it is a valid size for the given size descriptor).
///
/// Parameter `value`: The raw value itself. This must be the base NSString, NSNumber, NSArray or NSData objects. It
/// may not be NSDictionary. If a dictionary format is present, use +withElementValue:.
///
/// Returns: Returns the newly allocated data element object. Returns nil if an error is encountered (not likely
/// due to the limited error checking currently done). The returned IOBluetoothSDPDataElement
/// object has been autoreleased, so it is not necessary for the caller to release it. If the
/// object is to be referenced and kept around, retain should be called.
///
/// # Safety
///
/// - `new_value` should be of the correct type.
/// - `new_value` might not allow `None`.
#[unsafe(method(withType:sizeDescriptor:size:value:))]
#[unsafe(method_family = none)]
pub unsafe fn withType_sizeDescriptor_size_value(
r#type: BluetoothSDPDataElementTypeDescriptor,
new_size_descriptor: BluetoothSDPDataElementSizeDescriptor,
new_size: u32,
new_value: Option<&NSObject>,
) -> Option<Retained<Self>>;
#[cfg(feature = "IOBluetoothUserLib")]
/// Method call to convert an IOBluetoothSDPDataElementRef into an IOBluetoothSDPDataElement *.
///
/// Parameter `sdpDataElementRef`: IOBluetoothSDPDataElementRef for which an IOBluetoothSDPDataElement * is desired.
///
/// Returns: Returns the IOBluetoothSDPDataElement * for the given IOBluetoothSDPDataElementRef.
///
/// # Safety
///
/// `sdp_data_element_ref` might not allow `None`.
#[unsafe(method(withSDPDataElementRef:))]
#[unsafe(method_family = none)]
pub unsafe fn withSDPDataElementRef(
sdp_data_element_ref: Option<&IOBluetoothSDPDataElementRef>,
) -> Option<Retained<Self>>;
/// Initializes a new IOBluetoothSDPDataElement with the given value.
///
/// The value must follow the format listed above and must be an instance of NSData, NSString, NSNumber,
/// NSArray, NSDictionary, IOBluetoothSDPUUID.
///
/// Parameter `element`: The data element value of one of the specified types.
///
/// Returns: Returns self if successful. Returns nil if there was an error parsing the element value.
///
/// # Safety
///
/// - `element` should be of the correct type.
/// - `element` might not allow `None`.
#[unsafe(method(initWithElementValue:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithElementValue(
this: Allocated<Self>,
element: Option<&NSObject>,
) -> Option<Retained<Self>>;
#[cfg(feature = "Bluetooth")]
/// Initializes a new IOBluetoothSDPDataElement with the given attributes.
///
/// Warning - be careful using this method. There is next to no error checking done on the
/// attributes. It is entirely possible to construct an invalid data element. It is recommended
/// that +withElementValue: be used instead of this one.
///
/// Parameter `typeDescriptor`: The type descriptor for the data element.
///
/// Parameter `sizeDescriptor`: The size descriptor for the data element (verify it matches the size parameter).
///
/// Parameter `size`: The size of the data element in bytes (make sure it is a valid size for the given size descriptor).
///
/// Parameter `value`: The raw value itself. This must be the base NSString, NSNumber, NSArray or NSData objects. It
/// may not be NSDictionary. If a dictionary format is present, use +withElementValue:.
///
/// Returns: Returns self if successful. Returns nil if an error is encountered (not likely
/// due to the limited error checking currently done).
///
/// # Safety
///
/// - `new_value` should be of the correct type.
/// - `new_value` might not allow `None`.
#[unsafe(method(initWithType:sizeDescriptor:size:value:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithType_sizeDescriptor_size_value(
this: Allocated<Self>,
new_type: BluetoothSDPDataElementTypeDescriptor,
new_size_descriptor: BluetoothSDPDataElementSizeDescriptor,
new_size: u32,
new_value: Option<&NSObject>,
) -> Option<Retained<Self>>;
#[cfg(feature = "IOBluetoothUserLib")]
/// Returns an IOBluetoothSDPDataElementRef representation of the target IOBluetoothSDPDataElement object.
///
/// Returns: Returns an IOBluetoothSDPDataElementRef representation of the target IOBluetoothSDPDataElement object.
#[unsafe(method(getSDPDataElementRef))]
#[unsafe(method_family = none)]
pub unsafe fn getSDPDataElementRef(&self)
-> Option<Retained<IOBluetoothSDPDataElementRef>>;
#[cfg(feature = "Bluetooth")]
/// Returns the SDP spec defined data element type descriptor for the target data element.
///
/// Returns: Returns the type descriptor for the target data element.
#[unsafe(method(getTypeDescriptor))]
#[unsafe(method_family = none)]
pub unsafe fn getTypeDescriptor(&self) -> BluetoothSDPDataElementTypeDescriptor;
#[cfg(feature = "Bluetooth")]
/// Returns the SDP spec defined data element size descriptor for the target data element.
///
/// Returns: Returns the size descriptor for the target data element.
#[unsafe(method(getSizeDescriptor))]
#[unsafe(method_family = none)]
pub unsafe fn getSizeDescriptor(&self) -> BluetoothSDPDataElementSizeDescriptor;
/// Returns the size in bytes of the target data element.
///
/// The size is valid whether the data element has a fixed or variable size descriptor.
///
/// Returns: Returns the size in bytes of the target data element.
#[unsafe(method(getSize))]
#[unsafe(method_family = none)]
pub unsafe fn getSize(&self) -> u32;
#[cfg(feature = "objc2-foundation")]
/// If the data element is represented by a number, it returns the value as an NSNumber.
///
/// The data types represented by a number are 1 (unsigned int), 2 (signed int) and 5 (boolean)
/// except for 128-bit versions of 1 and 2.
///
/// Returns: Returns an NSNumber representation of the data element if it is a numeric type.
#[unsafe(method(getNumberValue))]
#[unsafe(method_family = none)]
pub unsafe fn getNumberValue(&self) -> Option<Retained<NSNumber>>;
#[cfg(feature = "objc2-foundation")]
/// If the data element is represented by a data object, it returns the value as an NSData.
///
/// The data types represented by a data object are 128-bit versions of 1 (unsigned int) and
/// 2 (signed int).
///
/// Returns: Returns an NSData representation of the data element if it is a 128-bit number.
#[unsafe(method(getDataValue))]
#[unsafe(method_family = none)]
pub unsafe fn getDataValue(&self) -> Option<Retained<NSData>>;
#[cfg(feature = "objc2-foundation")]
/// If the data element is represented by a string object, it returns the value as an NSString.
///
/// The data types represented by a string object are 4 (text string) and 8 (URL).
///
/// Returns: Returns an NSString representation of the data element if it is a text or URL type.
#[unsafe(method(getStringValue))]
#[unsafe(method_family = none)]
pub unsafe fn getStringValue(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "objc2-foundation")]
/// If the data element is represented by an array object, it returns the value as an NSArray.
///
/// The data types represented by an array object are 6 (data element sequence) and 7 (data
/// element alternative).
///
/// Returns: Returns an NSArray representation of the data element if it is a sequence type.
#[unsafe(method(getArrayValue))]
#[unsafe(method_family = none)]
pub unsafe fn getArrayValue(&self) -> Option<Retained<NSArray>>;
#[cfg(all(feature = "IOBluetoothSDPUUID", feature = "objc2-foundation"))]
/// If the data element is a UUID (type 3), it returns the value as an IOBluetoothSDPUUID.
///
/// Returns: Returns an IOBluetoothSDPUUID representation of the data element if it is a UUID.
#[unsafe(method(getUUIDValue))]
#[unsafe(method_family = none)]
pub unsafe fn getUUIDValue(&self) -> Option<Retained<IOBluetoothSDPUUID>>;
/// Returns the object value of the data element.
///
/// The value returned may be an NSNumber, NSString, NSData, NSArray or IOBluetoothSDPDataElement
/// depending on the type of the data element.
///
/// Returns: Returns the object value of the target data element.
#[unsafe(method(getValue))]
#[unsafe(method_family = none)]
pub unsafe fn getValue(&self) -> Option<Retained<NSObject>>;
/// Checks to see if the target data element is the same as the dataElement parameter or if it contains
/// the dataElement parameter (if its a sequence type).
///
/// If the target data element is not a sequence type, this method simply compares the two data elements. If
/// it is a sequence type, it will search through the sequence (and sub-sequences) for the dataElement
/// parameter.
///
/// Parameter `dataElement`: The data element to compare with (and search for).
///
/// Returns: Returns TRUE if the target either matches the given data element or if it contains the given data element.
///
/// # Safety
///
/// `data_element` might not allow `None`.
#[unsafe(method(containsDataElement:))]
#[unsafe(method_family = none)]
pub unsafe fn containsDataElement(
&self,
data_element: Option<&IOBluetoothSDPDataElement>,
) -> bool;
/// Checks to see if the target data element's value is the same as the value parameter or if it contains
/// the value parameter.
///
/// This method works just like -containsDataElement: except that it is comparing the value objects directly.
///
/// Parameter `cmpValue`: The value to compare with (and search for).
///
/// Returns: Returns TRUE if the target's value either matches the given value or if it contains the given value.
///
/// # Safety
///
/// - `cmp_value` should be of the correct type.
/// - `cmp_value` might not allow `None`.
#[unsafe(method(containsValue:))]
#[unsafe(method_family = none)]
pub unsafe fn containsValue(&self, cmp_value: Option<&NSObject>) -> bool;
);
}
/// Methods declared on superclass `NSObject`.
impl IOBluetoothSDPDataElement {
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>;
);
}