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