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