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        /// This is a [weak property][objc2::topics::weak_property].
75        /// Setter for [`delegate`][Self::delegate].
76        #[unsafe(method(setDelegate:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn setDelegate(
79            &self,
80            delegate: Option<&ProtocolObject<dyn SAEmergencyResponseDelegate>>,
81        );
82
83        #[cfg(feature = "block2")]
84        /// Requests the system to dial a voice call on behalf of the user.
85        /// Apps running in the background / foreground can request to dial a voice call without user confirmation. Emergency numbers are not allowed.
86        /// 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.
87        ///
88        ///
89        /// See also: SAEmergencyResponseDelegate
90        ///
91        ///
92        /// Parameter `phoneNumber`: Apps can request the system to dial a voice call by providing a phone number. Emergency numbers are not allowed.
93        ///
94        ///
95        /// Parameter `handler`: Completion handler invoked with the status of the voice call request.
96        /// If requested is accepted, the handler is invoked with a nil error. Interpret the error returned using SAErrorDomain.
97        /// Requests will fail with SAErrorNotAuthorized if user has not authorized the app to receive and handle any emergency events.
98        /// Requests will fail with SAErrorNotAvailable if invoked outside of the limited time window after an emergency event is detected.
99        /// Use the SAEmergencyResponseDelegate to monitor the progress of the voice call.
100        #[unsafe(method(dialVoiceCallToPhoneNumber:completionHandler:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn dialVoiceCallToPhoneNumber_completionHandler(
103            &self,
104            phone_number: &NSString,
105            handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
106        );
107    );
108}
109
110/// Methods declared on superclass `NSObject`.
111impl SAEmergencyResponseManager {
112    extern_methods!(
113        #[unsafe(method(init))]
114        #[unsafe(method_family = init)]
115        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
116
117        #[unsafe(method(new))]
118        #[unsafe(method_family = new)]
119        pub unsafe fn new() -> Retained<Self>;
120    );
121}
122
123extern_protocol!(
124    /// SAEmergencyResponseDelegate
125    ///
126    ///
127    /// SAEmergencyResponseManager notifies its delegate about status of the requested emergency response action
128    ///
129    ///
130    /// See also: SAEmergencyResponseManager
131    ///
132    /// See also [Apple's documentation](https://developer.apple.com/documentation/safetykit/saemergencyresponsedelegate?language=objc)
133    pub unsafe trait SAEmergencyResponseDelegate: NSObjectProtocol {
134        /// Voice call can be requested when running in the foreground or background within a limited time window of a detected emergency event,
135        /// Use this delegate to monitor the status of the requested voice call.
136        #[optional]
137        #[unsafe(method(emergencyResponseManager:didUpdateVoiceCallStatus:))]
138        #[unsafe(method_family = none)]
139        unsafe fn emergencyResponseManager_didUpdateVoiceCallStatus(
140            &self,
141            emergency_response_manager: &SAEmergencyResponseManager,
142            voice_call_status: SAEmergencyResponseManagerVoiceCallStatus,
143        );
144    }
145);