objc2_safety_kit/generated/
SAEmergencyResponseManager.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
10/// This enumeration defines the status of requested voice call
11///
12/// See also: SAEmergencyResponseManagerVoiceCallStatus
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/safetykit/saemergencyresponsemanagervoicecallstatus?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct SAEmergencyResponseManagerVoiceCallStatus(pub NSInteger);
19impl SAEmergencyResponseManagerVoiceCallStatus {
20    #[doc(alias = "SAEmergencyResponseManagerVoiceCallStatusDialing")]
21    pub const Dialing: Self = Self(0);
22    /// <
23    /// the system is dialing the voice call
24    #[doc(alias = "SAEmergencyResponseManagerVoiceCallStatusActive")]
25    pub const Active: Self = Self(1);
26    /// the system dialed voice call is disconnected after being active
27    #[doc(alias = "SAEmergencyResponseManagerVoiceCallStatusDisconnected")]
28    pub const Disconnected: Self = Self(2);
29    /// the system dialed voice call failed to connect
30    #[doc(alias = "SAEmergencyResponseManagerVoiceCallStatusFailed")]
31    pub const Failed: Self = Self(3);
32}
33
34unsafe impl Encode for SAEmergencyResponseManagerVoiceCallStatus {
35    const ENCODING: Encoding = NSInteger::ENCODING;
36}
37
38unsafe impl RefEncode for SAEmergencyResponseManagerVoiceCallStatus {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43    /// SAEmergencyResponseManager
44    ///
45    ///
46    /// Use SAEmergencyResponseManager to request actions in response to an emergency event.
47    /// Set the delegate to monitor the progress of requested emergency response actions.
48    /// SAEmergencyResponseManager requires user authorization for at least one of the emergency event detections e.g. SACrashDetectionEvent
49    ///
50    /// SAEmergencyResponseManager requires an entitlement from Apple to at least one of the emergency event detections. To apply for the entitlement, see respective detection mechanisms
51    ///
52    /// See also [Apple's documentation](https://developer.apple.com/documentation/safetykit/saemergencyresponsemanager?language=objc)
53    #[unsafe(super(NSObject))]
54    #[derive(Debug, PartialEq, Eq, Hash)]
55    pub struct SAEmergencyResponseManager;
56);
57
58extern_conformance!(
59    unsafe impl NSObjectProtocol for SAEmergencyResponseManager {}
60);
61
62impl SAEmergencyResponseManager {
63    extern_methods!(
64        /// delegate
65        ///
66        ///
67        /// The delegate object to receive updates about requested emergency response action.
68        #[unsafe(method(delegate))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn delegate(
71            &self,
72        ) -> Option<Retained<ProtocolObject<dyn SAEmergencyResponseDelegate>>>;
73
74        /// Setter for [`delegate`][Self::delegate].
75        ///
76        /// This is a [weak property][objc2::topics::weak_property].
77        #[unsafe(method(setDelegate:))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn setDelegate(
80            &self,
81            delegate: Option<&ProtocolObject<dyn SAEmergencyResponseDelegate>>,
82        );
83
84        #[cfg(feature = "block2")]
85        /// Requests the system to dial a voice call on behalf of the user.
86        /// Apps running in the background / foreground can request to dial a voice call without user confirmation. Emergency numbers are not allowed.
87        /// Requests are accepted only if user has authorized the app to receive and handle emergency detection events and only for a limited time after an emergency event is detected.
88        ///
89        ///
90        /// See also: SAEmergencyResponseDelegate
91        ///
92        ///
93        /// Parameter `phoneNumber`: Apps can request the system to dial a voice call by providing a phone number. Emergency numbers are not allowed.
94        ///
95        ///
96        /// Parameter `handler`: Completion handler invoked with the status of the voice call request.
97        /// If requested is accepted, the handler is invoked with a nil error. Interpret the error returned using SAErrorDomain.
98        /// Requests will fail with SAErrorNotAuthorized if user has not authorized the app to receive and handle any emergency events.
99        /// Requests will fail with SAErrorNotAvailable if invoked outside of the limited time window after an emergency event is detected.
100        /// Use the SAEmergencyResponseDelegate to monitor the progress of the voice call.
101        #[unsafe(method(dialVoiceCallToPhoneNumber:completionHandler:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn dialVoiceCallToPhoneNumber_completionHandler(
104            &self,
105            phone_number: &NSString,
106            handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
107        );
108    );
109}
110
111/// Methods declared on superclass `NSObject`.
112impl SAEmergencyResponseManager {
113    extern_methods!(
114        #[unsafe(method(init))]
115        #[unsafe(method_family = init)]
116        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
117
118        #[unsafe(method(new))]
119        #[unsafe(method_family = new)]
120        pub unsafe fn new() -> Retained<Self>;
121    );
122}
123
124extern_protocol!(
125    /// SAEmergencyResponseDelegate
126    ///
127    ///
128    /// SAEmergencyResponseManager notifies its delegate about status of the requested emergency response action
129    ///
130    ///
131    /// See also: SAEmergencyResponseManager
132    ///
133    /// See also [Apple's documentation](https://developer.apple.com/documentation/safetykit/saemergencyresponsedelegate?language=objc)
134    pub unsafe trait SAEmergencyResponseDelegate: NSObjectProtocol {
135        /// Voice call can be requested when running in the foreground or background within a limited time window of a detected emergency event,
136        /// Use this delegate to monitor the status of the requested voice call.
137        #[optional]
138        #[unsafe(method(emergencyResponseManager:didUpdateVoiceCallStatus:))]
139        #[unsafe(method_family = none)]
140        unsafe fn emergencyResponseManager_didUpdateVoiceCallStatus(
141            &self,
142            emergency_response_manager: &SAEmergencyResponseManager,
143            voice_call_status: SAEmergencyResponseManagerVoiceCallStatus,
144        );
145    }
146);