objc2_home_kit/generated/HMService.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 service provided by an accessory.
12 ///
13 ///
14 /// This class represents a service provided by an accessory in the home.
15 /// A service is composed of one or more characteristics that can be
16 /// modified.
17 ///
18 /// See also [Apple's documentation](https://developer.apple.com/documentation/homekit/hmservice?language=objc)
19 #[unsafe(super(NSObject))]
20 #[derive(Debug, PartialEq, Eq, Hash)]
21 pub struct HMService;
22);
23
24unsafe impl Send for HMService {}
25
26unsafe impl Sync for HMService {}
27
28extern_conformance!(
29 unsafe impl NSObjectProtocol for HMService {}
30);
31
32impl HMService {
33 extern_methods!(
34 #[cfg(feature = "HMAccessory")]
35 /// Accessory that provides this service.
36 #[unsafe(method(accessory))]
37 #[unsafe(method_family = none)]
38 pub unsafe fn accessory(&self) -> Option<Retained<HMAccessory>>;
39
40 /// The type of the service, e.g. HMServiceTypeLightbulb.
41 #[unsafe(method(serviceType))]
42 #[unsafe(method_family = none)]
43 pub unsafe fn serviceType(&self) -> Retained<NSString>;
44
45 /// The localized description of the service.
46 #[unsafe(method(localizedDescription))]
47 #[unsafe(method_family = none)]
48 pub unsafe fn localizedDescription(&self) -> Retained<NSString>;
49
50 /// Name for the service.
51 ///
52 ///
53 /// Returns the service's name that is associated with HomeKit. The initial value is the value of
54 /// the name characteristic of the service, if it has one.
55 #[unsafe(method(name))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn name(&self) -> Retained<NSString>;
58
59 /// For HMServiceTypeOutlet and HMServiceTypeSwitch, this is the type of the associated service.
60 ///
61 ///
62 /// This could be any of the HomeKit Accessory Profile defined services (except HMServiceTypeOutlet
63 /// or HMServiceTypeSwitch) that supports HMCharacteristicTypePowerState characteristic.
64 #[unsafe(method(associatedServiceType))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn associatedServiceType(&self) -> Option<Retained<NSString>>;
67
68 #[cfg(feature = "HMCharacteristic")]
69 /// Array of HMCharacteristic objects that represents all the characteristics
70 /// provided by the service.
71 #[unsafe(method(characteristics))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn characteristics(&self) -> Retained<NSArray<HMCharacteristic>>;
74
75 /// A unique identifier for the service.
76 #[unsafe(method(uniqueIdentifier))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn uniqueIdentifier(&self) -> Retained<NSUUID>;
79
80 /// Indicates if this service supports user interaction or not.
81 ///
82 ///
83 /// Applications should use this property to filter out services that the users
84 /// should not directly interact with, e.g. HMServiceTypeAccessoryInformation.
85 #[unsafe(method(isUserInteractive))]
86 #[unsafe(method_family = none)]
87 pub unsafe fn isUserInteractive(&self) -> bool;
88
89 /// Indicates if this services is the primary service.
90 ///
91 ///
92 /// Applications should use this property to show the primary service on the accessory.
93 #[unsafe(method(isPrimaryService))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn isPrimaryService(&self) -> bool;
96
97 /// Array of HMService objects that represents all the services that the service links to.
98 ///
99 ///
100 /// Applications should use this property to show logical grouping of services on the accessory.
101 /// linkedServices will be nil when the service does not link to any other services.
102 #[unsafe(method(linkedServices))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn linkedServices(&self) -> Option<Retained<NSArray<HMService>>>;
105
106 /// The Matter endpoint identifier that this service is mapped to.
107 ///
108 ///
109 /// This property is nil for HAP accessories, and set to a valid value for Matter devices.
110 #[unsafe(method(matterEndpointID))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn matterEndpointID(&self) -> Option<Retained<NSNumber>>;
113
114 #[cfg(feature = "block2")]
115 /// This method is used to change the name of the service.
116 ///
117 ///
118 /// Parameter `name`: New name for the service.
119 ///
120 ///
121 /// The new name is stored in HomeKit and not on the accessory.
122 ///
123 ///
124 /// Parameter `completion`: Block that is invoked once the request is processed.
125 /// The NSError provides more information on the status of the request, error
126 /// will be nil on success.
127 #[unsafe(method(updateName:completionHandler:))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn updateName_completionHandler(
130 &self,
131 name: &NSString,
132 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
133 );
134
135 #[cfg(feature = "block2")]
136 /// This method is used to set up the service type of the device connected to a contact sensor, switch or an outlet.
137 ///
138 ///
139 /// Parameter `serviceType`: Service type of the device connected to a contact sensor/switch/outlet service.
140 ///
141 ///
142 /// This method is only valid for the services of the following types:
143 /// HMServiceTypeOutlet, HMServiceTypeContactSensor and HMServiceTypeSwitch
144 ///
145 /// For services of type HMServiceTypeOutlet and HMServiceTypeSwitch, serviceType can be one of the
146 /// HomeKit Accessory Profile defined services (except HMServiceTypeOutlet or HMServiceTypeSwitch)
147 /// that supports HMCharacteristicTypePowerState characteristic.
148 ///
149 /// For services of type HMServiceTypeContactSensor, serviceType can be one of the following services:
150 /// HMServiceTypeDoor, HMServiceTypeGarageDoorOpener, HMServiceTypeWindow and HMServiceTypeWindowCovering
151 ///
152 ///
153 /// Parameter `completion`: Block that is invoked once the request is processed.
154 /// The NSError provides more information on the status of the request, error
155 /// will be nil on success.
156 #[unsafe(method(updateAssociatedServiceType:completionHandler:))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn updateAssociatedServiceType_completionHandler(
159 &self,
160 service_type: Option<&NSString>,
161 completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
162 );
163
164 #[deprecated = "HMService objects are created by their parent container objects. Directly creating them is not supported."]
165 #[unsafe(method(init))]
166 #[unsafe(method_family = init)]
167 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
168 );
169}
170
171/// Methods declared on superclass `NSObject`.
172impl HMService {
173 extern_methods!(
174 #[unsafe(method(new))]
175 #[unsafe(method_family = new)]
176 pub unsafe fn new() -> Retained<Self>;
177 );
178}