objc2-io-bluetooth 0.3.2

Bindings to the IOBluetooth framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An NSData subclass that represents a UUID as defined in the Bluetooth SDP spec.
    ///
    /// The IOBluetoothSDPUUID class can represent a UUID of any valid size (16, 32 or 128 bits).
    /// It provides the ability to compare two UUIDs no matter what their size as well as the ability
    /// to promote the size of a UUID to a larger one.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/iobluetooth/iobluetoothsdpuuid?language=objc)
    #[unsafe(super(NSData, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-foundation")]
    pub struct IOBluetoothSDPUUID;
);

#[cfg(feature = "objc2-foundation")]
extern_conformance!(
    unsafe impl NSCoding for IOBluetoothSDPUUID {}
);

#[cfg(feature = "objc2-foundation")]
extern_conformance!(
    unsafe impl NSObjectProtocol for IOBluetoothSDPUUID {}
);

#[cfg(feature = "objc2-foundation")]
extern_conformance!(
    unsafe impl NSSecureCoding for IOBluetoothSDPUUID {}
);

#[cfg(feature = "objc2-foundation")]
impl IOBluetoothSDPUUID {
    extern_methods!(
        /// Creates a new IOBluetoothSDPUUID object with the given bytes of the given length.
        ///
        /// If the length is invalid for a UUID, nil is returned.
        ///
        /// Parameter `bytes`: An array of bytes representing the UUID.
        ///
        /// Parameter `length`: The length of the array of bytes.
        ///
        /// Returns: Returns the new IOBluetoothSDPUUID object or nil on failure.
        ///
        /// # Safety
        ///
        /// `bytes` must be a valid pointer.
        #[unsafe(method(uuidWithBytes:length:))]
        #[unsafe(method_family = none)]
        pub unsafe fn uuidWithBytes_length(
            bytes: *const c_void,
            length: c_uint,
        ) -> Option<Retained<Self>>;

        /// Creates a new IOBluetoothSDPUUID object from the given NSData.
        ///
        /// If the length of the NSData is invalid for a UUID, nil is returned.
        ///
        /// Parameter `data`: The NSData containing the UUID bytes.
        ///
        /// Returns: Returns the new IOBluetoothSDPUUID object or nil on failure.
        ///
        /// # Safety
        ///
        /// `data` might not allow `None`.
        #[unsafe(method(uuidWithData:))]
        #[unsafe(method_family = none)]
        pub unsafe fn uuidWithData(data: Option<&NSData>) -> Option<Retained<Self>>;

        #[cfg(feature = "Bluetooth")]
        /// Creates a new 16-bit IOBluetoothSDPUUID with the given UUID16
        ///
        /// Parameter `uuid16`: A scalar representing a 16-bit UUID
        ///
        /// Returns: Returns the new IOBluetoothSDPUUID object.
        #[unsafe(method(uuid16:))]
        #[unsafe(method_family = none)]
        pub unsafe fn uuid16(uuid16: BluetoothSDPUUID16) -> Option<Retained<Self>>;

        #[cfg(feature = "Bluetooth")]
        /// Creates a new 32-bit IOBluetoothSDPUUID with the given UUID32
        ///
        /// Parameter `uuid32`: A scalar representing a 32-bit UUID
        ///
        /// Returns: Returns the new IOBluetoothSDPUUID object.
        #[unsafe(method(uuid32:))]
        #[unsafe(method_family = none)]
        pub unsafe fn uuid32(uuid32: BluetoothSDPUUID32) -> Option<Retained<Self>>;

        #[cfg(feature = "IOBluetoothUserLib")]
        /// Method call to convert an IOBluetoothSDPUUIDRef into an IOBluetoothSDPUUID *.
        ///
        /// Parameter `sdpUUIDRef`: IOBluetoothSDPUUIDRef for which an IOBluetoothSDPUUID * is desired.
        ///
        /// Returns: Returns the IOBluetoothSDPUUID * for the given IOBluetoothSDPUUIDRef.
        ///
        /// # Safety
        ///
        /// `sdp_uuid_ref` might not allow `None`.
        #[deprecated]
        #[unsafe(method(withSDPUUIDRef:))]
        #[unsafe(method_family = none)]
        pub unsafe fn withSDPUUIDRef(
            sdp_uuid_ref: Option<&IOBluetoothSDPUUIDRef>,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "Bluetooth")]
        /// Initializes a new 16-bit IOBluetoothSDPUUID with the given UUID16
        ///
        /// Parameter `uuid16`: A scalar representing a 16-bit UUID
        ///
        /// Returns: Returns self.
        #[unsafe(method(initWithUUID16:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithUUID16(
            this: Allocated<Self>,
            uuid16: BluetoothSDPUUID16,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "Bluetooth")]
        /// Creates a new 32-bit IOBluetoothSDPUUID with the given UUID32
        ///
        /// Parameter `uuid32`: A scalar representing a 32-bit UUID
        ///
        /// Returns: Returns self.
        #[unsafe(method(initWithUUID32:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithUUID32(
            this: Allocated<Self>,
            uuid32: BluetoothSDPUUID32,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "IOBluetoothUserLib")]
        /// Returns an IOBluetoothSDPUUIDRef representation of the target IOBluetoothSDPUUID object.
        ///
        /// Returns: Returns an IOBluetoothSDPUUIDRef representation of the target IOBluetoothSDPUUID object.
        #[deprecated]
        #[unsafe(method(getSDPUUIDRef))]
        #[unsafe(method_family = none)]
        pub unsafe fn getSDPUUIDRef(&self) -> Option<Retained<IOBluetoothSDPUUIDRef>>;

        /// Returns an IOBluetoothSDPUUID object matching the target UUID, but with the given number of bytes.
        ///
        /// If the target object is the same length as newLength, it returns self.  If newLength is greater
        /// it creates a new IOBluetoothSDPUUID object with the correct value for the given length.  If
        /// newLength is smaller, it will attempt to create a new IOBluetoothSDPUUID that is smaller if
        /// the data matches the Bluetooth UUID base.  This downconversion is currently unimplemented.
        ///
        /// Parameter `newLength`: The desired length for the UUID.
        ///
        /// Returns: Returns an IOBluetoothSDPUUID object with the same data as the target but with the given length if it
        /// is possible to do so.  Otherwise, nil is returned.
        #[unsafe(method(getUUIDWithLength:))]
        #[unsafe(method_family = none)]
        pub unsafe fn getUUIDWithLength(&self, new_length: c_uint) -> Option<Retained<Self>>;

        /// Compares the target IOBluetoothSDPUUID object with the given otherUUID object.
        ///
        /// This method will compare the two UUID values independent of their length.
        ///
        /// Parameter `otherUUID`: The UUID object to be compared with the target.
        ///
        /// Returns: Returns true if the UUID values of each object are equal.  This includes the case where the sizes are different
        /// but the data itself is the same when the Bluetooth UUID base is applied.
        ///
        /// # Safety
        ///
        /// `other_uuid` might not allow `None`.
        #[unsafe(method(isEqualToUUID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn isEqualToUUID(&self, other_uuid: Option<&IOBluetoothSDPUUID>) -> bool;

        #[unsafe(method(classForCoder))]
        #[unsafe(method_family = none)]
        pub unsafe fn classForCoder(&self) -> Option<&'static AnyClass>;

        #[unsafe(method(classForArchiver))]
        #[unsafe(method_family = none)]
        pub unsafe fn classForArchiver(&self) -> Option<&'static AnyClass>;

        #[unsafe(method(classForPortCoder))]
        #[unsafe(method_family = none)]
        pub unsafe fn classForPortCoder(&self) -> Option<&'static AnyClass>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-foundation")]
impl IOBluetoothSDPUUID {
    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>;
    );
}