objc2_io_bluetooth/generated/objc2/IOBluetoothSDPDataElement.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#[cfg(feature = "objc2-foundation")]
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 /// An instance of this class represents a single SDP data element as defined by the Bluetooth SDP spec.
12 ///
13 /// The data types described by the spec have been mapped onto the base Foundation classes NSNumber,
14 /// NSArray, NSData as well as IOBluetoothSDPUUID. The number and boolean types (type descriptor 1, 2
15 /// and 5) are represented as NSNumber objects with the exception of 128-bit numbers which are
16 /// represented as NSData objects in their raw format. The UUID type (type descriptor 3) is
17 /// represented by IOBluetoothSDPUUID. The string and URL types (type descriptor 4 and 8) are
18 /// represented by NSString. The sequence types (type descriptor 6 and 7) are represented by NSArray.
19 ///
20 /// Typically, you will not need to create an IOBluetoothSDPDataElement directly, the system will
21 /// do that automatically for both client and server operations. However, the current API for adding
22 /// SDP services to the system does allow the use of an NSDictionary based format for creating new
23 /// services. The purpose for that is to allow a service to be built up completely in a text file
24 /// (a plist for example) and then easily imported into an app and added to the system without a
25 /// lot of tedious code to build up the entire SDP service record.
26 ///
27 /// The basis for that NSDictionary structure comes from the IOBluetoothSDPDataElement. At its
28 /// simplest, a data element is made up of three parts: the type descriptor, the size (from which
29 /// the size descriptor is generated) and the actual value. To provide a complete representation
30 /// of a data element, an NSDictionary with three entries can be used. Each of the three entries
31 /// has a key/value pair representing one of the three attributes of a data element. The first
32 /// key/value pair has a key 'DataElementType' that contains a number value with the actual
33 /// type descriptor for the data element. The second pair has a key 'DataElementSize' that
34 /// contains the actual size of the element in bytes. The size descriptor will be calculated
35 /// based on the size and type of the element. The third pair is the value itself whose key is
36 /// 'DataElementValue' and whose type corresponds to the type mapping above.
37 ///
38 /// In addition to this complete description of a data element, their are some shortcuts that
39 /// can be used for some of the common types and sizes.
40 ///
41 /// If the 'DataElementType' value is one of the numeric types (1, 2), the 'DataElementValue'
42 /// can be an NSData instead of an NSNumber. In that case, the numeric data is taken in network
43 /// byte order (MSB first). Additionally, the 'DataElementSize' parameter may be omitted and the
44 /// size will be taken from the length of the data object.
45 ///
46 /// If the 'DataElementType' value is the nil type (0), no 'DataElementSize' or 'DataElementValue'
47 /// entries are needed.
48 ///
49 /// If the 'DataElementType' value is any of the other types, the 'DataElementSize' entry is not
50 /// needed since the size will be taken directly from the value (data, array, string).
51 ///
52 /// In the case where the element is an unsigned, 32-bit integer (type descriptor 1, size descriptor
53 /// 4), the value itself may simply be a number (instead of a dictionary as in the previous examples).
54 ///
55 /// In the case where the element is a UUID (type descriptor 3), the value itself may be a data object.
56 /// The UUID type will be inferred and the size taken from the length of the data object.
57 ///
58 /// In the case where the element is a text string (type descriptor 4), the value may be a string object.
59 /// The text string type will be inferred and the size taken from the length of the string.
60 ///
61 /// In the case where the element is a data element sequence, the value may be an array object. The
62 /// type will be inferred and the size taken from the length of the array. Additionally, the array
63 /// must contain sub-elements that will be parsed out individually.
64 ///
65 /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothsdpdataelement?language=objc)
66 #[unsafe(super(NSObject))]
67 #[derive(Debug, PartialEq, Eq, Hash)]
68 pub struct IOBluetoothSDPDataElement;
69);
70
71#[cfg(feature = "objc2-foundation")]
72extern_conformance!(
73 unsafe impl NSCoding for IOBluetoothSDPDataElement {}
74);
75
76extern_conformance!(
77 unsafe impl NSObjectProtocol for IOBluetoothSDPDataElement {}
78);
79
80#[cfg(feature = "objc2-foundation")]
81extern_conformance!(
82 unsafe impl NSSecureCoding for IOBluetoothSDPDataElement {}
83);
84
85impl IOBluetoothSDPDataElement {
86 extern_methods!(
87 /// Creates a new IOBluetoothSDPDataElement with the given value.
88 ///
89 /// The value must follow the format listed above and must be an instance of NSData, NSString, NSNumber,
90 /// NSArray, NSDictionary, IOBluetoothSDPUUID.
91 ///
92 /// Parameter `element`: The data element value of one of the specified types.
93 ///
94 /// Returns: Returns the newly allocated data element object. Returns nil if there was an error parsing the element
95 /// value. The returned IOBluetoothSDPDataElement object has been autoreleased, so it is not necessary
96 /// for the caller to release it. If the object is to be referenced and kept around, retain should be
97 /// called.
98 #[unsafe(method(withElementValue:))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn withElementValue(element: Option<&NSObject>) -> Option<Retained<Self>>;
101
102 #[cfg(feature = "Bluetooth")]
103 /// Creates a new IOBluetoothSDPDataElement with the given attributes.
104 ///
105 /// Warning - be careful using this method. There is next to no error checking done on the
106 /// attributes. It is entirely possible to construct an invalid data element. It is recommended
107 /// that +withElementValue: be used instead of this one.
108 ///
109 /// Parameter `typeDescriptor`: The type descriptor for the data element.
110 ///
111 /// Parameter `sizeDescriptor`: The size descriptor for the data element (verify it matches the size parameter).
112 ///
113 /// Parameter `size`: The size of the data element in bytes (make sure it is a valid size for the given size descriptor).
114 ///
115 /// Parameter `value`: The raw value itself. This must be the base NSString, NSNumber, NSArray or NSData objects. It
116 /// may not be NSDictionary. If a dictionary format is present, use +withElementValue:.
117 ///
118 /// Returns: Returns the newly allocated data element object. Returns nil if an error is encountered (not likely
119 /// due to the limited error checking currently done). The returned IOBluetoothSDPDataElement
120 /// object has been autoreleased, so it is not necessary for the caller to release it. If the
121 /// object is to be referenced and kept around, retain should be called.
122 #[unsafe(method(withType:sizeDescriptor:size:value:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn withType_sizeDescriptor_size_value(
125 r#type: BluetoothSDPDataElementTypeDescriptor,
126 new_size_descriptor: BluetoothSDPDataElementSizeDescriptor,
127 new_size: u32,
128 new_value: Option<&NSObject>,
129 ) -> Option<Retained<Self>>;
130
131 #[cfg(feature = "IOBluetoothUserLib")]
132 /// Method call to convert an IOBluetoothSDPDataElementRef into an IOBluetoothSDPDataElement *.
133 ///
134 /// Parameter `sdpDataElementRef`: IOBluetoothSDPDataElementRef for which an IOBluetoothSDPDataElement * is desired.
135 ///
136 /// Returns: Returns the IOBluetoothSDPDataElement * for the given IOBluetoothSDPDataElementRef.
137 #[unsafe(method(withSDPDataElementRef:))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn withSDPDataElementRef(
140 sdp_data_element_ref: Option<&IOBluetoothSDPDataElementRef>,
141 ) -> Option<Retained<Self>>;
142
143 /// Initializes a new IOBluetoothSDPDataElement with the given value.
144 ///
145 /// The value must follow the format listed above and must be an instance of NSData, NSString, NSNumber,
146 /// NSArray, NSDictionary, IOBluetoothSDPUUID.
147 ///
148 /// Parameter `element`: The data element value of one of the specified types.
149 ///
150 /// Returns: Returns self if successful. Returns nil if there was an error parsing the element value.
151 #[unsafe(method(initWithElementValue:))]
152 #[unsafe(method_family = init)]
153 pub unsafe fn initWithElementValue(
154 this: Allocated<Self>,
155 element: Option<&NSObject>,
156 ) -> Option<Retained<Self>>;
157
158 #[cfg(feature = "Bluetooth")]
159 /// Initializes a new IOBluetoothSDPDataElement with the given attributes.
160 ///
161 /// Warning - be careful using this method. There is next to no error checking done on the
162 /// attributes. It is entirely possible to construct an invalid data element. It is recommended
163 /// that +withElementValue: be used instead of this one.
164 ///
165 /// Parameter `typeDescriptor`: The type descriptor for the data element.
166 ///
167 /// Parameter `sizeDescriptor`: The size descriptor for the data element (verify it matches the size parameter).
168 ///
169 /// Parameter `size`: The size of the data element in bytes (make sure it is a valid size for the given size descriptor).
170 ///
171 /// Parameter `value`: The raw value itself. This must be the base NSString, NSNumber, NSArray or NSData objects. It
172 /// may not be NSDictionary. If a dictionary format is present, use +withElementValue:.
173 ///
174 /// Returns: Returns self if successful. Returns nil if an error is encountered (not likely
175 /// due to the limited error checking currently done).
176 #[unsafe(method(initWithType:sizeDescriptor:size:value:))]
177 #[unsafe(method_family = init)]
178 pub unsafe fn initWithType_sizeDescriptor_size_value(
179 this: Allocated<Self>,
180 new_type: BluetoothSDPDataElementTypeDescriptor,
181 new_size_descriptor: BluetoothSDPDataElementSizeDescriptor,
182 new_size: u32,
183 new_value: Option<&NSObject>,
184 ) -> Option<Retained<Self>>;
185
186 #[cfg(feature = "IOBluetoothUserLib")]
187 /// Returns an IOBluetoothSDPDataElementRef representation of the target IOBluetoothSDPDataElement object.
188 ///
189 /// Returns: Returns an IOBluetoothSDPDataElementRef representation of the target IOBluetoothSDPDataElement object.
190 #[unsafe(method(getSDPDataElementRef))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn getSDPDataElementRef(&self)
193 -> Option<Retained<IOBluetoothSDPDataElementRef>>;
194
195 #[cfg(feature = "Bluetooth")]
196 /// Returns the SDP spec defined data element type descriptor for the target data element.
197 ///
198 /// Returns: Returns the type descriptor for the target data element.
199 #[unsafe(method(getTypeDescriptor))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn getTypeDescriptor(&self) -> BluetoothSDPDataElementTypeDescriptor;
202
203 #[cfg(feature = "Bluetooth")]
204 /// Returns the SDP spec defined data element size descriptor for the target data element.
205 ///
206 /// Returns: Returns the size descriptor for the target data element.
207 #[unsafe(method(getSizeDescriptor))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn getSizeDescriptor(&self) -> BluetoothSDPDataElementSizeDescriptor;
210
211 /// Returns the size in bytes of the target data element.
212 ///
213 /// The size is valid whether the data element has a fixed or variable size descriptor.
214 ///
215 /// Returns: Returns the size in bytes of the target data element.
216 #[unsafe(method(getSize))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn getSize(&self) -> u32;
219
220 #[cfg(feature = "objc2-foundation")]
221 /// If the data element is represented by a number, it returns the value as an NSNumber.
222 ///
223 /// The data types represented by a number are 1 (unsigned int), 2 (signed int) and 5 (boolean)
224 /// except for 128-bit versions of 1 and 2.
225 ///
226 /// Returns: Returns an NSNumber representation of the data element if it is a numeric type.
227 #[unsafe(method(getNumberValue))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn getNumberValue(&self) -> Option<Retained<NSNumber>>;
230
231 #[cfg(feature = "objc2-foundation")]
232 /// If the data element is represented by a data object, it returns the value as an NSData.
233 ///
234 /// The data types represented by a data object are 128-bit versions of 1 (unsigned int) and
235 /// 2 (signed int).
236 ///
237 /// Returns: Returns an NSData representation of the data element if it is a 128-bit number.
238 #[unsafe(method(getDataValue))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn getDataValue(&self) -> Option<Retained<NSData>>;
241
242 #[cfg(feature = "objc2-foundation")]
243 /// If the data element is represented by a string object, it returns the value as an NSString.
244 ///
245 /// The data types represented by a string object are 4 (text string) and 8 (URL).
246 ///
247 /// Returns: Returns an NSString representation of the data element if it is a text or URL type.
248 #[unsafe(method(getStringValue))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn getStringValue(&self) -> Option<Retained<NSString>>;
251
252 #[cfg(feature = "objc2-foundation")]
253 /// If the data element is represented by an array object, it returns the value as an NSArray.
254 ///
255 /// The data types represented by an array object are 6 (data element sequence) and 7 (data
256 /// element alternative).
257 ///
258 /// Returns: Returns an NSArray representation of the data element if it is a sequence type.
259 #[unsafe(method(getArrayValue))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn getArrayValue(&self) -> Option<Retained<NSArray>>;
262
263 #[cfg(all(feature = "IOBluetoothSDPUUID", feature = "objc2-foundation"))]
264 /// If the data element is a UUID (type 3), it returns the value as an IOBluetoothSDPUUID.
265 ///
266 /// Returns: Returns an IOBluetoothSDPUUID representation of the data element if it is a UUID.
267 #[unsafe(method(getUUIDValue))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn getUUIDValue(&self) -> Option<Retained<IOBluetoothSDPUUID>>;
270
271 /// Returns the object value of the data element.
272 ///
273 /// The value returned may be an NSNumber, NSString, NSData, NSArray or IOBluetoothSDPDataElement
274 /// depending on the type of the data element.
275 ///
276 /// Returns: Returns the object value of the target data element.
277 #[unsafe(method(getValue))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn getValue(&self) -> Option<Retained<NSObject>>;
280
281 /// Checks to see if the target data element is the same as the dataElement parameter or if it contains
282 /// the dataElement parameter (if its a sequence type).
283 ///
284 /// If the target data element is not a sequence type, this method simply compares the two data elements. If
285 /// it is a sequence type, it will search through the sequence (and sub-sequences) for the dataElement
286 /// parameter.
287 ///
288 /// Parameter `dataElement`: The data element to compare with (and search for).
289 ///
290 /// Returns: Returns TRUE if the target either matches the given data element or if it contains the given data element.
291 #[unsafe(method(containsDataElement:))]
292 #[unsafe(method_family = none)]
293 pub unsafe fn containsDataElement(
294 &self,
295 data_element: Option<&IOBluetoothSDPDataElement>,
296 ) -> bool;
297
298 /// Checks to see if the target data element's value is the same as the value parameter or if it contains
299 /// the value parameter.
300 ///
301 /// This method works just like -containsDataElement: except that it is comparing the value objects directly.
302 ///
303 /// Parameter `cmpValue`: The value to compare with (and search for).
304 ///
305 /// Returns: Returns TRUE if the target's value either matches the given value or if it contains the given value.
306 #[unsafe(method(containsValue:))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn containsValue(&self, cmp_value: Option<&NSObject>) -> bool;
309 );
310}
311
312/// Methods declared on superclass `NSObject`.
313impl IOBluetoothSDPDataElement {
314 extern_methods!(
315 #[unsafe(method(init))]
316 #[unsafe(method_family = init)]
317 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
318
319 #[unsafe(method(new))]
320 #[unsafe(method_family = new)]
321 pub unsafe fn new() -> Retained<Self>;
322 );
323}