objc2_core_bluetooth/generated/
CBService.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// Represents a peripheral's service or a service's included service.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbservice?language=objc)
14    #[unsafe(super(CBAttribute, NSObject))]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    #[cfg(feature = "CBAttribute")]
17    pub struct CBService;
18);
19
20#[cfg(feature = "CBAttribute")]
21unsafe impl NSObjectProtocol for CBService {}
22
23#[cfg(feature = "CBAttribute")]
24impl CBService {
25    extern_methods!(
26        #[cfg(all(feature = "CBPeer", feature = "CBPeripheral"))]
27        /// A back-pointer to the peripheral this service belongs to.
28        #[unsafe(method(peripheral))]
29        #[unsafe(method_family = none)]
30        pub unsafe fn peripheral(&self) -> Option<Retained<CBPeripheral>>;
31
32        /// The type of the service (primary or secondary).
33        #[unsafe(method(isPrimary))]
34        #[unsafe(method_family = none)]
35        pub unsafe fn isPrimary(&self) -> bool;
36
37        /// A list of included CBServices that have so far been discovered in this service.
38        #[unsafe(method(includedServices))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn includedServices(&self) -> Option<Retained<NSArray<CBService>>>;
41
42        #[cfg(feature = "CBCharacteristic")]
43        /// A list of CBCharacteristics that have so far been discovered in this service.
44        #[unsafe(method(characteristics))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn characteristics(&self) -> Option<Retained<NSArray<CBCharacteristic>>>;
47    );
48}
49
50/// Methods declared on superclass `CBAttribute`.
51#[cfg(feature = "CBAttribute")]
52impl CBService {
53    extern_methods!(
54        #[unsafe(method(init))]
55        #[unsafe(method_family = init)]
56        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
57    );
58}
59
60/// Methods declared on superclass `NSObject`.
61#[cfg(feature = "CBAttribute")]
62impl CBService {
63    extern_methods!(
64        #[unsafe(method(new))]
65        #[unsafe(method_family = new)]
66        pub unsafe fn new() -> Retained<Self>;
67    );
68}
69
70extern_class!(
71    /// Used to create a local service or included service, which can be added to the local database via
72    /// <code>
73    /// CBPeripheralManager
74    /// </code>
75    /// .
76    /// Once a service is published, it is cached and can no longer be changed. This class adds write access to all properties in the
77    ///
78    /// ```text
79    ///  CBService
80    /// ```
81    ///
82    /// class.
83    ///
84    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbmutableservice?language=objc)
85    #[unsafe(super(CBService, CBAttribute, NSObject))]
86    #[derive(Debug, PartialEq, Eq, Hash)]
87    #[cfg(feature = "CBAttribute")]
88    pub struct CBMutableService;
89);
90
91#[cfg(feature = "CBAttribute")]
92unsafe impl NSObjectProtocol for CBMutableService {}
93
94#[cfg(feature = "CBAttribute")]
95impl CBMutableService {
96    extern_methods!(
97        #[unsafe(method(includedServices))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn includedServices(&self) -> Option<Retained<NSArray<CBService>>>;
100
101        /// Setter for [`includedServices`][Self::includedServices].
102        #[unsafe(method(setIncludedServices:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setIncludedServices(&self, included_services: Option<&NSArray<CBService>>);
105
106        #[cfg(feature = "CBCharacteristic")]
107        #[unsafe(method(characteristics))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn characteristics(&self) -> Option<Retained<NSArray<CBCharacteristic>>>;
110
111        #[cfg(feature = "CBCharacteristic")]
112        /// Setter for [`characteristics`][Self::characteristics].
113        #[unsafe(method(setCharacteristics:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setCharacteristics(
116            &self,
117            characteristics: Option<&NSArray<CBCharacteristic>>,
118        );
119
120        #[cfg(feature = "CBUUID")]
121        /// Parameter `UUID`: The Bluetooth UUID of the service.
122        ///
123        /// Parameter `isPrimary`: The type of the service (primary or secondary).
124        ///
125        ///
126        /// Returns a service, initialized with a service type and UUID.
127        #[unsafe(method(initWithType:primary:))]
128        #[unsafe(method_family = init)]
129        pub unsafe fn initWithType_primary(
130            this: Allocated<Self>,
131            uuid: &CBUUID,
132            is_primary: bool,
133        ) -> Retained<Self>;
134    );
135}
136
137/// Methods declared on superclass `CBAttribute`.
138#[cfg(feature = "CBAttribute")]
139impl CBMutableService {
140    extern_methods!(
141        #[unsafe(method(init))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
144    );
145}
146
147/// Methods declared on superclass `NSObject`.
148#[cfg(feature = "CBAttribute")]
149impl CBMutableService {
150    extern_methods!(
151        #[unsafe(method(new))]
152        #[unsafe(method_family = new)]
153        pub unsafe fn new() -> Retained<Self>;
154    );
155}