objc2_io_bluetooth/generated/objc2/
IOBluetoothL2CAPChannel.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-foundation")]
7use objc2_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchanneleventtype?language=objc)
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct IOBluetoothL2CAPChannelEventType(pub c_uint);
15impl IOBluetoothL2CAPChannelEventType {
16    #[doc(alias = "kIOBluetoothL2CAPChannelEventTypeData")]
17    pub const Data: Self = Self(0x0001);
18    #[doc(alias = "kIOBluetoothL2CAPChannelEventTypeOpenComplete")]
19    pub const OpenComplete: Self = Self(0x0002);
20    #[doc(alias = "kIOBluetoothL2CAPChannelEventTypeClosed")]
21    pub const Closed: Self = Self(0x0003);
22    #[doc(alias = "kIOBluetoothL2CAPChannelEventTypeReconfigured")]
23    pub const Reconfigured: Self = Self(0x0004);
24    #[doc(alias = "kIOBluetoothL2CAPChannelEventTypeWriteComplete")]
25    pub const WriteComplete: Self = Self(0x0005);
26    #[doc(alias = "kIOBluetoothL2CAPChannelEventTypeQueueSpaceAvailable")]
27    pub const QueueSpaceAvailable: Self = Self(0x0006);
28}
29
30unsafe impl Encode for IOBluetoothL2CAPChannelEventType {
31    const ENCODING: Encoding = c_uint::ENCODING;
32}
33
34unsafe impl RefEncode for IOBluetoothL2CAPChannelEventType {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchanneldatablock?language=objc)
39#[repr(C)]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub struct IOBluetoothL2CAPChannelDataBlock {
42    pub dataPtr: *mut c_void,
43    pub dataSize: usize,
44}
45
46unsafe impl Encode for IOBluetoothL2CAPChannelDataBlock {
47    const ENCODING: Encoding = Encoding::Struct(
48        "IOBluetoothL2CAPChannelDataBlock",
49        &[<*mut c_void>::ENCODING, <usize>::ENCODING],
50    );
51}
52
53unsafe impl RefEncode for IOBluetoothL2CAPChannelDataBlock {
54    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
55}
56
57/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannelevent_u?language=objc)
58#[repr(C)]
59#[derive(Clone, Copy)]
60pub union IOBluetoothL2CAPChannelEvent_u {
61    pub data: IOBluetoothL2CAPChannelDataBlock,
62    pub writeRefCon: *mut c_void,
63    pub padding: [u8; 32],
64}
65
66unsafe impl Encode for IOBluetoothL2CAPChannelEvent_u {
67    const ENCODING: Encoding = Encoding::Union(
68        "?",
69        &[
70            <IOBluetoothL2CAPChannelDataBlock>::ENCODING,
71            <*mut c_void>::ENCODING,
72            <[u8; 32]>::ENCODING,
73        ],
74    );
75}
76
77unsafe impl RefEncode for IOBluetoothL2CAPChannelEvent_u {
78    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
79}
80
81/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannelevent?language=objc)
82#[repr(C)]
83#[derive(Clone, Copy)]
84pub struct IOBluetoothL2CAPChannelEvent {
85    pub eventType: IOBluetoothL2CAPChannelEventType,
86    pub u: IOBluetoothL2CAPChannelEvent_u,
87    pub status: IOReturn,
88}
89
90unsafe impl Encode for IOBluetoothL2CAPChannelEvent {
91    const ENCODING: Encoding = Encoding::Struct(
92        "IOBluetoothL2CAPChannelEvent",
93        &[
94            <IOBluetoothL2CAPChannelEventType>::ENCODING,
95            <IOBluetoothL2CAPChannelEvent_u>::ENCODING,
96            <IOReturn>::ENCODING,
97        ],
98    );
99}
100
101unsafe impl RefEncode for IOBluetoothL2CAPChannelEvent {
102    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
103}
104
105/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannelincomingdatalistener?language=objc)
106#[cfg(feature = "IOBluetoothUserLib")]
107pub type IOBluetoothL2CAPChannelIncomingDataListener = Option<
108    unsafe extern "C-unwind" fn(*mut IOBluetoothL2CAPChannelRef, *mut c_void, u16, *mut c_void),
109>;
110
111/// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannelincomingeventlistener?language=objc)
112#[cfg(feature = "IOBluetoothUserLib")]
113pub type IOBluetoothL2CAPChannelIncomingEventListener = Option<
114    unsafe extern "C-unwind" fn(
115        *mut IOBluetoothL2CAPChannelRef,
116        *mut c_void,
117        *mut IOBluetoothL2CAPChannelEvent,
118    ),
119>;
120
121extern_class!(
122    /// An instance of IOBluetoothL2CAPChannel represents a single open L2CAP channel.
123    ///
124    /// A client won't create IOBluetoothL2CAPChannel objects directly.  Instead, the IOBluetoothDevice's
125    /// L2CAP channel open API is responsible for opening a new L2CAP channel and returning an
126    /// IOBluetoothL2CAPChannel instance representing that newly opened channel.  Additionally, the IOBluetooth
127    /// notification system will send notifications when new L2CAP channels are open (if requested).
128    ///
129    /// After a new L2CAP channel is opened, the L2CAP configuration process will not be completed until an
130    /// incoming data listener is registered with the IOBluetoothL2CAPChannel object.  The reason for this is
131    /// to due to the limited buffering done of incoming L2CAP data.  This way, we avoid the situation where
132    /// incoming data is received before the client is ready for it.  Once a client is done with an
133    /// IOBluetoothL2CAPChannel that it opened, it should call -closeChannel.  Additionally, if the client
134    /// does not intend to use the connection to the remote device any further, it should call -closeConnection
135    /// on the IOBluetoothDevice object.
136    ///
137    /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannel?language=objc)
138    #[unsafe(super(IOBluetoothObject, NSObject))]
139    #[derive(Debug, PartialEq, Eq, Hash)]
140    #[cfg(feature = "IOBluetoothObject")]
141    pub struct IOBluetoothL2CAPChannel;
142);
143
144#[cfg(all(feature = "IOBluetoothObject", feature = "objc2-foundation"))]
145extern_conformance!(
146    unsafe impl NSCopying for IOBluetoothL2CAPChannel {}
147);
148
149#[cfg(all(feature = "IOBluetoothObject", feature = "objc2-foundation"))]
150unsafe impl CopyingHelper for IOBluetoothL2CAPChannel {
151    type Result = Self;
152}
153
154#[cfg(feature = "IOBluetoothObject")]
155extern_conformance!(
156    unsafe impl NSObjectProtocol for IOBluetoothL2CAPChannel {}
157);
158
159#[cfg(all(feature = "IOBluetoothObject", feature = "objc2-foundation"))]
160extern_conformance!(
161    unsafe impl NSPortDelegate for IOBluetoothL2CAPChannel {}
162);
163
164#[cfg(feature = "IOBluetoothObject")]
165impl IOBluetoothL2CAPChannel {
166    extern_methods!(
167        #[cfg(feature = "IOBluetoothUserNotification")]
168        /// Allows a client to register for L2CAP channel open notifications for any L2CAP channel.
169        ///
170        /// The given selector will be called on the target object whenever any L2CAP channel is opened.
171        /// The selector should accept two arguments.  The first is the user notification object.  The second
172        /// is the IOBluetoothL2CAPChannel that was opened.
173        ///
174        /// Parameter `object`: Target object
175        ///
176        /// Parameter `selector`: Selector to be called on the target object when a new L2CAP channel is opened.
177        ///
178        /// Returns: Returns an IOBluetoothUserNotification representing the outstanding L2CAP channel notification.
179        /// To unregister the notification, call -unregister on the resulting IOBluetoothUserNotification
180        /// object.  If an error is encountered creating the notification, nil is returned.  The returned
181        /// IOBluetoothUserNotification will be valid for as long as the notification is registered.  It is
182        /// not necessary to retain the result.  Once -unregister is called on it, it will no longer be valid.
183        ///
184        /// # Safety
185        ///
186        /// - `object` should be of the correct type.
187        /// - `object` might not allow `None`.
188        /// - `selector` must be a valid selector.
189        #[unsafe(method(registerForChannelOpenNotifications:selector:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn registerForChannelOpenNotifications_selector(
192            object: Option<&AnyObject>,
193            selector: Option<Sel>,
194        ) -> Option<Retained<IOBluetoothUserNotification>>;
195
196        #[cfg(all(
197            feature = "Bluetooth",
198            feature = "IOBluetoothUserLib",
199            feature = "IOBluetoothUserNotification"
200        ))]
201        /// Allows a client to register for L2CAP channel open notifications for certain types of
202        /// L2CAP channels.
203        ///
204        /// The given selector will be called on the target object whenever an L2CAP channel with the given
205        /// attributes is opened.  The selector should accept two arguments.  The first is the user
206        /// notification object.  The second is the IOBluetoothL2CAPChannel that was opened.
207        ///
208        /// Parameter `object`: Target object
209        ///
210        /// Parameter `selector`: Selector to be called on the target object when a new L2CAP channel is opened.
211        ///
212        /// Parameter `psm`: PSM to match a new L2CAP channel.  If the PSM doesn't matter, 0 may be passed in.
213        ///
214        /// Parameter `inDirection`: The desired direction of the L2CAP channel - kIOBluetoothUserNotificationChannelDirectionAny
215        /// if the direction doesn't matter.
216        ///
217        /// Returns: Returns an IOBluetoothUserNotification representing the outstanding L2CAP channel notification.
218        /// To unregister the notification, call -unregister on the resulting IOBluetoothUserNotification
219        /// object.  If an error is encountered creating the notification, nil is returned.  The returned
220        /// IOBluetoothUserNotification will be valid for as long as the notification is registered.  It is
221        /// not necessary to retain the result.  Once -unregister is called on it, it will no longer be valid.
222        ///
223        /// # Safety
224        ///
225        /// - `object` should be of the correct type.
226        /// - `object` might not allow `None`.
227        /// - `selector` must be a valid selector.
228        #[unsafe(method(registerForChannelOpenNotifications:selector:withPSM:direction:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn registerForChannelOpenNotifications_selector_withPSM_direction(
231            object: Option<&AnyObject>,
232            selector: Option<Sel>,
233            psm: BluetoothL2CAPPSM,
234            in_direction: IOBluetoothUserNotificationChannelDirection,
235        ) -> Option<Retained<IOBluetoothUserNotification>>;
236
237        #[cfg(feature = "IOBluetoothUserLib")]
238        /// Returns the IObluetoothL2CAPChannel with the given IOBluetoothObjectID.
239        ///
240        /// The IOBluetoothObjectID can be used as a global reference for a given IOBluetoothL2CAPChannel.  It allows
241        /// two separate applications to refer to the same IOBluetoothL2CAPChannel object.
242        ///
243        /// Parameter `objectID`: IOBluetoothObjectID of the desired IOBluetoothL2CAPChannel.
244        ///
245        /// Returns: Returns the IOBluetoothL2CAPChannel that matches the given IOBluetoothObjectID if one exists.
246        /// If no matching L2CAP channel exists, nil is returned.
247        #[unsafe(method(withObjectID:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn withObjectID(object_id: IOBluetoothObjectID) -> Option<Retained<Self>>;
250
251        /// Initiates the close process on an open L2CAP channel.
252        ///
253        /// This method may only be called by the client that opened the channel in the first place.  In the future
254        /// asynchronous and synchronous versions will be provided that let the client know when the close process
255        /// has been finished.
256        ///
257        /// Returns: Returns kIOReturnSuccess on success.
258        #[unsafe(method(closeChannel))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn closeChannel(&self) -> IOReturn;
261
262        #[cfg(feature = "Bluetooth")]
263        /// Returns the current outgoing MTU for the L2CAP channel.
264        ///
265        /// The outgoing MTU represents the maximum L2CAP packet size for packets being sent to the remote device.
266        ///
267        /// Returns: Returns the current outgoing MTU for the L2CAP channel.
268        #[unsafe(method(outgoingMTU))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn outgoingMTU(&self) -> BluetoothL2CAPMTU;
271
272        #[cfg(feature = "Bluetooth")]
273        #[deprecated]
274        #[unsafe(method(getOutgoingMTU))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn getOutgoingMTU(&self) -> BluetoothL2CAPMTU;
277
278        #[cfg(feature = "Bluetooth")]
279        /// Returns the current incoming MTU for the L2CAP channel.
280        ///
281        /// The incoming MTU represents the maximum L2CAP packet size for packets being sent by the remote device.
282        ///
283        /// Returns: Returns the current incoming MTU for the L2CAP channel.
284        #[unsafe(method(incomingMTU))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn incomingMTU(&self) -> BluetoothL2CAPMTU;
287
288        #[cfg(feature = "Bluetooth")]
289        #[deprecated]
290        #[unsafe(method(getIncomingMTU))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn getIncomingMTU(&self) -> BluetoothL2CAPMTU;
293
294        #[cfg(feature = "Bluetooth")]
295        /// Initiates the process to reconfigure the L2CAP channel with a new outgoing MTU.
296        ///
297        /// Currently, this API does not give an indication that the re-config process has completed.  In
298        /// the future additional API will be available to provide that information both synchronously and
299        /// asynchronously.
300        ///
301        /// Parameter `remoteMTU`: The desired outgoing MTU.
302        ///
303        /// Returns: Returns kIOReturnSuccess if the channel re-configure process was successfully initiated.
304        #[unsafe(method(requestRemoteMTU:))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn requestRemoteMTU(&self, remote_mtu: BluetoothL2CAPMTU) -> IOReturn;
307
308        /// Writes the given data over the target L2CAP channel asynchronously to the remote device using
309        /// IOConnectTrap4() call.
310        ///
311        /// The length of the data may not exceed the L2CAP channel's ougoing MTU.  When the data has
312        /// been successfully passed to the hardware to be transmitted, the delegate method
313        /// -l2capChannelWriteComplete:refcon:status: will be called with the refcon passed
314        /// into this method.
315        ///
316        /// NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
317        ///
318        /// Parameter `data`: Pointer to the buffer containing the data to send.
319        ///
320        /// Parameter `length`: The length of the given data buffer.
321        ///
322        /// Parameter `refcon`: User supplied value that gets passed to the write callback.
323        ///
324        /// Returns: Returns kIOReturnSuccess if the data was buffered successfully.
325        ///
326        /// # Safety
327        ///
328        /// - `data` must be a valid pointer.
329        /// - `refcon` must be a valid pointer.
330        #[unsafe(method(writeAsyncTrap:length:refcon:))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn writeAsyncTrap_length_refcon(
333            &self,
334            data: *mut c_void,
335            length: u16,
336            refcon: *mut c_void,
337        ) -> IOReturn;
338
339        /// Writes the given data over the target L2CAP channel asynchronously to the remote device.
340        ///
341        /// The length of the data may not exceed the L2CAP channel's ougoing MTU.  When the data has
342        /// been successfully passed to the hardware to be transmitted, the delegate method
343        /// -l2capChannelWriteComplete:refcon:status: will be called with the refcon passed
344        /// into this method.
345        ///
346        /// NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
347        ///
348        /// Parameter `data`: Pointer to the buffer containing the data to send.
349        ///
350        /// Parameter `length`: The length of the given data buffer.
351        ///
352        /// Parameter `refcon`: User supplied value that gets passed to the write callback.
353        ///
354        /// Returns: Returns kIOReturnSuccess if the data was buffered successfully.
355        ///
356        /// # Safety
357        ///
358        /// - `data` must be a valid pointer.
359        /// - `refcon` must be a valid pointer.
360        #[unsafe(method(writeAsync:length:refcon:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn writeAsync_length_refcon(
363            &self,
364            data: *mut c_void,
365            length: u16,
366            refcon: *mut c_void,
367        ) -> IOReturn;
368
369        /// Writes the given data synchronously over the target L2CAP channel to the remote device.
370        ///
371        /// The length of the data may not exceed the L2CAP channel's ougoing MTU.  This method will
372        /// block until the data has been successfully sent to the hardware for transmission (or an error
373        /// occurs).
374        ///
375        /// NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
376        ///
377        /// Parameter `data`: Pointer to the buffer containing the data to send.
378        ///
379        /// Parameter `length`: The length of the given data buffer.
380        ///
381        /// Returns: Returns kIOReturnSuccess if the data was written successfully.
382        ///
383        /// # Safety
384        ///
385        /// `data` must be a valid pointer.
386        #[unsafe(method(writeSync:length:))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn writeSync_length(&self, data: *mut c_void, length: u16) -> IOReturn;
389
390        /// Allows an object to register itself as client of the L2CAP channel.
391        ///
392        /// A channel delegate is the object the L2CAP channel uses as target for data and events. The
393        /// developer will implement only the the methods he/she is interested in. A list of the
394        /// possible methods is at the end of this file in the definition of the informal protocol
395        /// IOBluetoothL2CAPChannelDelegate.
396        /// A newly opened L2CAP channel will not complete its configuration process until the client
397        /// that opened it registers a connectionHandler.  This prevents that case where incoming
398        /// data is received before the client is ready.
399        ///
400        /// NOTE: This method is only available in Mac OS X 10.2.5 (Bluetooth v1.2) or later.
401        ///
402        /// Parameter `channelDelegate`: the object that will play the role of channel delegate [NOTE the l2cap channel will retain the delegate].
403        ///
404        /// Returns: Returns kIOReturnSuccess if the delegate is successfully registered.
405        ///
406        /// # Safety
407        ///
408        /// - `channel_delegate` should be of the correct type.
409        /// - `channel_delegate` might not allow `None`.
410        #[unsafe(method(setDelegate:))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn setDelegate(&self, channel_delegate: Option<&AnyObject>) -> IOReturn;
413
414        #[cfg(feature = "objc2-foundation")]
415        /// Allows an object to register itself as client of the L2CAP channel.
416        ///
417        /// A channel delegate is the object the L2CAP channel uses as target for data and events. The
418        /// developer will implement only the the methods he/she is interested in. A list of the
419        /// possible methods is at the end of this file in the definition of the informal protocol
420        /// IOBluetoothL2CAPChannelDelegate.
421        /// A newly opened L2CAP channel will not complete its configuration process until the client
422        /// that opened it registers a connectionHandler.  This prevents that case where incoming
423        /// data is received before the client is ready.
424        ///
425        /// NOTE: This method is only available in Mac OS X 10.5 (Bluetooth v2.0) or later.
426        ///
427        /// Parameter `channelDelegate`: the object that will play the role of channel delegate.
428        ///
429        /// Parameter `channelConfiguration`: the dictionary that describes the initial configuration for
430        /// the channel.
431        ///
432        /// Returns: Returns kIOReturnSuccess if the delegate is successfully registered.
433        ///
434        /// # Safety
435        ///
436        /// - `channel_delegate` should be of the correct type.
437        /// - `channel_delegate` might not allow `None`.
438        /// - `channel_configuration` generic should be of the correct type.
439        /// - `channel_configuration` might not allow `None`.
440        #[unsafe(method(setDelegate:withConfiguration:))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn setDelegate_withConfiguration(
443            &self,
444            channel_delegate: Option<&AnyObject>,
445            channel_configuration: Option<&NSDictionary>,
446        ) -> IOReturn;
447
448        /// Returns the currently assigned delegate
449        ///
450        /// An incoming channel is one that was initiated by a remote device.
451        ///
452        /// Returns: Returns the current delegate, or nil if one is not set.
453        #[unsafe(method(delegate))]
454        #[unsafe(method_family = none)]
455        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;
456
457        #[cfg(feature = "IOBluetoothDevice")]
458        /// Returns the IOBluetoothDevice to which the target L2CAP channel is open.
459        ///
460        /// Returns: Returns the IOBluetoothDevice to which the target L2CAP channel is open.
461        #[unsafe(method(device))]
462        #[unsafe(method_family = none)]
463        pub unsafe fn device(&self) -> Option<Retained<IOBluetoothDevice>>;
464
465        #[cfg(feature = "IOBluetoothDevice")]
466        #[deprecated]
467        #[unsafe(method(getDevice))]
468        #[unsafe(method_family = none)]
469        pub unsafe fn getDevice(&self) -> Option<Retained<IOBluetoothDevice>>;
470
471        #[cfg(feature = "IOBluetoothUserLib")]
472        /// Returns the IOBluetoothObjectID of the given IOBluetoothL2CAPChannel.
473        ///
474        /// The IOBluetoothObjectID can be used as a global reference for a given IOBluetoothL2CAPChannel.  It allows
475        /// two separate applications to refer to the same IOBluetoothL2CAPChannel.
476        ///
477        /// Returns: Returns the IOBluetoothObjectID of the given IOBluetoothL2CAPChannel.
478        #[unsafe(method(objectID))]
479        #[unsafe(method_family = none)]
480        pub unsafe fn objectID(&self) -> IOBluetoothObjectID;
481
482        #[cfg(feature = "IOBluetoothUserLib")]
483        #[deprecated]
484        #[unsafe(method(getObjectID))]
485        #[unsafe(method_family = none)]
486        pub unsafe fn getObjectID(&self) -> IOBluetoothObjectID;
487
488        #[cfg(feature = "Bluetooth")]
489        /// Returns the PSM for the target L2CAP channel.
490        ///
491        /// Returns: Returns the PSM for the target L2CAP channel.
492        #[unsafe(method(PSM))]
493        #[unsafe(method_family = none)]
494        pub unsafe fn PSM(&self) -> BluetoothL2CAPPSM;
495
496        #[cfg(feature = "Bluetooth")]
497        #[deprecated]
498        #[unsafe(method(getPSM))]
499        #[unsafe(method_family = none)]
500        pub unsafe fn getPSM(&self) -> BluetoothL2CAPPSM;
501
502        #[cfg(feature = "Bluetooth")]
503        /// Returns the local L2CAP channel ID for the target L2CAP channel.
504        ///
505        /// Returns: Returns the local L2CAP channel ID for the target L2CAP channel.
506        #[unsafe(method(localChannelID))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn localChannelID(&self) -> BluetoothL2CAPChannelID;
509
510        #[cfg(feature = "Bluetooth")]
511        #[deprecated]
512        #[unsafe(method(getLocalChannelID))]
513        #[unsafe(method_family = none)]
514        pub unsafe fn getLocalChannelID(&self) -> BluetoothL2CAPChannelID;
515
516        #[cfg(feature = "Bluetooth")]
517        /// Returns the remote L2CAP channel ID for the target L2CAP channel.
518        ///
519        /// Returns: Returns the remote L2CAP channel ID for the target L2CAP channel.
520        #[unsafe(method(remoteChannelID))]
521        #[unsafe(method_family = none)]
522        pub unsafe fn remoteChannelID(&self) -> BluetoothL2CAPChannelID;
523
524        #[cfg(feature = "Bluetooth")]
525        #[deprecated]
526        #[unsafe(method(getRemoteChannelID))]
527        #[unsafe(method_family = none)]
528        pub unsafe fn getRemoteChannelID(&self) -> BluetoothL2CAPChannelID;
529
530        /// Returns TRUE if the channel is an incoming channel.
531        ///
532        /// An incoming channel is one that was initiated by a remote device.
533        ///
534        /// Returns: Returns TRUE if the channel is an incoming channel.
535        #[unsafe(method(isIncoming))]
536        #[unsafe(method_family = none)]
537        pub unsafe fn isIncoming(&self) -> bool;
538
539        #[cfg(feature = "IOBluetoothUserNotification")]
540        /// Allows a client to register for a channel close notification.
541        ///
542        /// The given selector will be called on the target observer when the L2CAP channel is closed.
543        /// The selector should contain two arguments.  The first is the user notification object. The second
544        /// is the IOBluetoothL2CAPChannel that was closed.
545        ///
546        /// Parameter `observer`: Target observer object
547        ///
548        /// Parameter `inSelector`: Selector to be sent to the observer when the L2CAP channel is closed.
549        ///
550        /// Returns: Returns an IOBluetoothUserNotification representing the outstanding L2CAP channel close notification.
551        /// To unregister the notification, call -unregister of the returned IOBluetoothUserNotification
552        /// object.  If an error is encountered creating the notification, nil is returned.
553        ///
554        /// # Safety
555        ///
556        /// - `observer` should be of the correct type.
557        /// - `observer` might not allow `None`.
558        /// - `in_selector` must be a valid selector.
559        #[unsafe(method(registerForChannelCloseNotification:selector:))]
560        #[unsafe(method_family = none)]
561        pub unsafe fn registerForChannelCloseNotification_selector(
562            &self,
563            observer: Option<&AnyObject>,
564            in_selector: Option<Sel>,
565        ) -> Option<Retained<IOBluetoothUserNotification>>;
566    );
567}
568
569/// Methods declared on superclass `NSObject`.
570#[cfg(feature = "IOBluetoothObject")]
571impl IOBluetoothL2CAPChannel {
572    extern_methods!(
573        #[unsafe(method(init))]
574        #[unsafe(method_family = init)]
575        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
576
577        #[unsafe(method(new))]
578        #[unsafe(method_family = new)]
579        pub unsafe fn new() -> Retained<Self>;
580    );
581}
582
583extern_protocol!(
584    /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchanneldelegate?language=objc)
585    pub unsafe trait IOBluetoothL2CAPChannelDelegate {
586        #[cfg(feature = "IOBluetoothObject")]
587        /// # Safety
588        ///
589        /// - `l2cap_channel` might not allow `None`.
590        /// - `data_pointer` must be a valid pointer.
591        #[optional]
592        #[unsafe(method(l2capChannelData:data:length:))]
593        #[unsafe(method_family = none)]
594        unsafe fn l2capChannelData_data_length(
595            &self,
596            l2cap_channel: Option<&IOBluetoothL2CAPChannel>,
597            data_pointer: *mut c_void,
598            data_length: usize,
599        );
600
601        #[cfg(feature = "IOBluetoothObject")]
602        /// # Safety
603        ///
604        /// `l2cap_channel` might not allow `None`.
605        #[optional]
606        #[unsafe(method(l2capChannelOpenComplete:status:))]
607        #[unsafe(method_family = none)]
608        unsafe fn l2capChannelOpenComplete_status(
609            &self,
610            l2cap_channel: Option<&IOBluetoothL2CAPChannel>,
611            error: IOReturn,
612        );
613
614        #[cfg(feature = "IOBluetoothObject")]
615        /// # Safety
616        ///
617        /// `l2cap_channel` might not allow `None`.
618        #[optional]
619        #[unsafe(method(l2capChannelClosed:))]
620        #[unsafe(method_family = none)]
621        unsafe fn l2capChannelClosed(&self, l2cap_channel: Option<&IOBluetoothL2CAPChannel>);
622
623        #[cfg(feature = "IOBluetoothObject")]
624        /// # Safety
625        ///
626        /// `l2cap_channel` might not allow `None`.
627        #[optional]
628        #[unsafe(method(l2capChannelReconfigured:))]
629        #[unsafe(method_family = none)]
630        unsafe fn l2capChannelReconfigured(&self, l2cap_channel: Option<&IOBluetoothL2CAPChannel>);
631
632        #[cfg(feature = "IOBluetoothObject")]
633        /// # Safety
634        ///
635        /// - `l2cap_channel` might not allow `None`.
636        /// - `refcon` must be a valid pointer.
637        #[optional]
638        #[unsafe(method(l2capChannelWriteComplete:refcon:status:))]
639        #[unsafe(method_family = none)]
640        unsafe fn l2capChannelWriteComplete_refcon_status(
641            &self,
642            l2cap_channel: Option<&IOBluetoothL2CAPChannel>,
643            refcon: *mut c_void,
644            error: IOReturn,
645        );
646
647        #[cfg(feature = "IOBluetoothObject")]
648        /// # Safety
649        ///
650        /// `l2cap_channel` might not allow `None`.
651        #[optional]
652        #[unsafe(method(l2capChannelQueueSpaceAvailable:))]
653        #[unsafe(method_family = none)]
654        unsafe fn l2capChannelQueueSpaceAvailable(
655            &self,
656            l2cap_channel: Option<&IOBluetoothL2CAPChannel>,
657        );
658    }
659);
660
661extern "C" {
662    /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannelpublishednotification?language=objc)
663    #[cfg(feature = "objc2-foundation")]
664    pub static IOBluetoothL2CAPChannelPublishedNotification: Option<&'static NSString>;
665}
666
667extern "C" {
668    /// [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothl2capchannelterminatednotification?language=objc)
669    #[cfg(feature = "objc2-foundation")]
670    pub static IOBluetoothL2CAPChannelTerminatedNotification: Option<&'static NSString>;
671}