//! 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::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Represents a peripheral's service or a service's included service.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbservice?language=objc)
    #[unsafe(super(CBAttribute, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CBAttribute")]
    pub struct CBService;
);

#[cfg(feature = "CBAttribute")]
unsafe impl NSObjectProtocol for CBService {}

#[cfg(feature = "CBAttribute")]
impl CBService {
    extern_methods!(
        #[cfg(all(feature = "CBPeer", feature = "CBPeripheral"))]
        /// A back-pointer to the peripheral this service belongs to.
        #[unsafe(method(peripheral))]
        #[unsafe(method_family = none)]
        pub unsafe fn peripheral(&self) -> Option<Retained<CBPeripheral>>;

        /// The type of the service (primary or secondary).
        #[unsafe(method(isPrimary))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPrimary(&self) -> bool;

        /// A list of included CBServices that have so far been discovered in this service.
        #[unsafe(method(includedServices))]
        #[unsafe(method_family = none)]
        pub unsafe fn includedServices(&self) -> Option<Retained<NSArray<CBService>>>;

        #[cfg(feature = "CBCharacteristic")]
        /// A list of CBCharacteristics that have so far been discovered in this service.
        #[unsafe(method(characteristics))]
        #[unsafe(method_family = none)]
        pub unsafe fn characteristics(&self) -> Option<Retained<NSArray<CBCharacteristic>>>;
    );
}

/// Methods declared on superclass `CBAttribute`.
#[cfg(feature = "CBAttribute")]
impl CBService {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "CBAttribute")]
impl CBService {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Used to create a local service or included service, which can be added to the local database via
    /// <code>
    /// CBPeripheralManager
    /// </code>
    /// .
    /// Once a service is published, it is cached and can no longer be changed. This class adds write access to all properties in the
    ///
    /// ```text
    ///  CBService
    /// ```
    ///
    /// class.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmutableservice?language=objc)
    #[unsafe(super(CBService, CBAttribute, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CBAttribute")]
    pub struct CBMutableService;
);

#[cfg(feature = "CBAttribute")]
unsafe impl NSObjectProtocol for CBMutableService {}

#[cfg(feature = "CBAttribute")]
impl CBMutableService {
    extern_methods!(
        #[unsafe(method(includedServices))]
        #[unsafe(method_family = none)]
        pub unsafe fn includedServices(&self) -> Option<Retained<NSArray<CBService>>>;

        /// Setter for [`includedServices`][Self::includedServices].
        #[unsafe(method(setIncludedServices:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setIncludedServices(&self, included_services: Option<&NSArray<CBService>>);

        #[cfg(feature = "CBCharacteristic")]
        #[unsafe(method(characteristics))]
        #[unsafe(method_family = none)]
        pub unsafe fn characteristics(&self) -> Option<Retained<NSArray<CBCharacteristic>>>;

        #[cfg(feature = "CBCharacteristic")]
        /// Setter for [`characteristics`][Self::characteristics].
        #[unsafe(method(setCharacteristics:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCharacteristics(
            &self,
            characteristics: Option<&NSArray<CBCharacteristic>>,
        );

        #[cfg(feature = "CBUUID")]
        /// Parameter `UUID`: The Bluetooth UUID of the service.
        ///
        /// Parameter `isPrimary`: The type of the service (primary or secondary).
        ///
        ///
        /// Returns a service, initialized with a service type and UUID.
        #[unsafe(method(initWithType:primary:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithType_primary(
            this: Allocated<Self>,
            uuid: &CBUUID,
            is_primary: bool,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `CBAttribute`.
#[cfg(feature = "CBAttribute")]
impl CBMutableService {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "CBAttribute")]
impl CBMutableService {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}
