//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbl2cappsm?language=objc)
pub type CBL2CAPPSM = u16;

extern_class!(
    /// A CBL2CAPChannel represents a live L2CAP connection to a remote device
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbl2capchannel?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CBL2CAPChannel;
);

unsafe impl NSObjectProtocol for CBL2CAPChannel {}

impl CBL2CAPChannel {
    extern_methods!(
        #[cfg(feature = "CBPeer")]
        /// The peer connected to the channel
        #[unsafe(method(peer))]
        #[unsafe(method_family = none)]
        pub unsafe fn peer(&self) -> Option<Retained<CBPeer>>;

        /// An NSStream used for reading data from the remote peer
        #[unsafe(method(inputStream))]
        #[unsafe(method_family = none)]
        pub unsafe fn inputStream(&self) -> Option<Retained<NSInputStream>>;

        /// An NSStream used for writing data to the peer
        #[unsafe(method(outputStream))]
        #[unsafe(method_family = none)]
        pub unsafe fn outputStream(&self) -> Option<Retained<NSOutputStream>>;

        /// The PSM (Protocol/Service Multiplexer) of the channel
        #[unsafe(method(PSM))]
        #[unsafe(method_family = none)]
        pub unsafe fn PSM(&self) -> CBL2CAPPSM;
    );
}

/// Methods declared on superclass `NSObject`.
impl CBL2CAPChannel {
    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>;
    );
}
