objc2_metric_kit/generated/
MXMetricManager.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    /// An instance of this class can be used to retrieve periodic, aggregated power and performance metrics.
12    ///
13    /// To receive metrics, clients must acquire a reference to the shared instance of the metric manager and add an eligible MXMetricManagerSubscriber.
14    ///
15    /// Metrics are not guaranteed to be delivered, but can be expected atleast once per day when conditions permit.
16    ///
17    /// Subscribers to the metric manager can remove themselves using removeSubscriber:subscriber if they no longer wish to receive metrics.
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/metrickit/mxmetricmanager?language=objc)
20    #[unsafe(super(NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    pub struct MXMetricManager;
23);
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for MXMetricManager {}
27);
28
29impl MXMetricManager {
30    extern_methods!(
31        #[cfg(feature = "MXMetricPayload")]
32        /// A list of past metric payloads received.
33        #[unsafe(method(pastPayloads))]
34        #[unsafe(method_family = none)]
35        pub unsafe fn pastPayloads(&self) -> Retained<NSArray<MXMetricPayload>>;
36
37        #[cfg(feature = "MXDiagnosticPayload")]
38        /// A list of past diagnostic payloads received.
39        #[unsafe(method(pastDiagnosticPayloads))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn pastDiagnosticPayloads(&self) -> Retained<NSArray<MXDiagnosticPayload>>;
42
43        /// Singleton instance of MXMetricManager.
44        #[unsafe(method(sharedManager))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn sharedManager() -> Retained<MXMetricManager>;
47
48        /// Adds a subscriber to the metric manager.
49        ///
50        /// Parameter `subscriber`: An object that conforms to the MXMetricManagerSubscriber protocol.
51        ///
52        /// Subscribers can receive metric payloads by conforming to the MXMetricManagerSubscriber protocol.
53        #[unsafe(method(addSubscriber:))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn addSubscriber(
56            &self,
57            subscriber: &ProtocolObject<dyn MXMetricManagerSubscriber>,
58        );
59
60        /// Removes a subscriber from the metric manager.
61        ///
62        /// Parameter `subscriber`: An object that conforms to the MXMetricManagerSubscriber protocol.
63        ///
64        /// The subscriber indicated, if previously registered, will no longer receive metric payloads.
65        #[unsafe(method(removeSubscriber:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn removeSubscriber(
68            &self,
69            subscriber: &ProtocolObject<dyn MXMetricManagerSubscriber>,
70        );
71    );
72}
73
74/// Methods declared on superclass `NSObject`.
75impl MXMetricManager {
76    extern_methods!(
77        #[unsafe(method(init))]
78        #[unsafe(method_family = init)]
79        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
80
81        #[unsafe(method(new))]
82        #[unsafe(method_family = new)]
83        pub unsafe fn new() -> Retained<Self>;
84    );
85}
86
87extern_protocol!(
88    /// A protocol that allows the conforming object to receive metric payloads from the metric manager.
89    ///
90    /// In order to receive metric payloads, atleast one object must conform to this protocol and be subscribed   to the metric manager.
91    ///
92    /// Objects which conform to this protocol can be passed to addSubscriber:subscriber and removeSubscriber:subscriber to manage their subscription state.
93    ///
94    /// See also [Apple's documentation](https://developer.apple.com/documentation/metrickit/mxmetricmanagersubscriber?language=objc)
95    pub unsafe trait MXMetricManagerSubscriber: NSObjectProtocol {
96        #[cfg(feature = "MXMetricPayload")]
97        /// This method is invoked when a new MXMetricPayload has been received.
98        ///
99        /// Parameter `payloads`: An NSArray of MXMetricPayload objects. This array of payloads contains data from previous usage sessions.
100        ///
101        /// You can expect for this method to be invoked atleast once per day when the app is running and subscribers are available.
102        ///
103        /// If no subscribers are available, this method will not be invoked.
104        ///
105        /// Atleast one subscriber must be available to receive metrics.
106        ///
107        /// This method is invoked on a background queue.
108        #[optional]
109        #[unsafe(method(didReceiveMetricPayloads:))]
110        #[unsafe(method_family = none)]
111        unsafe fn didReceiveMetricPayloads(&self, payloads: &NSArray<MXMetricPayload>);
112
113        #[cfg(feature = "MXDiagnosticPayload")]
114        /// This method is invoked when a new MXDiagnosticPayload has been received.
115        ///
116        /// Parameter `payloads`: An NSArray of MXDiagnosticPayload objects. This array of payloads contains diagnostics from previous usage sessions.
117        ///
118        /// You can expect for this method to be invoked atleast once per day when the app is running and subscribers are available.
119        ///
120        /// If no subscribers are available, this method will not be invoked.
121        ///
122        /// Atleast one subscriber must be available to receive diagnostics.
123        ///
124        /// This method is invoked on a background queue.
125        #[optional]
126        #[unsafe(method(didReceiveDiagnosticPayloads:))]
127        #[unsafe(method_family = none)]
128        unsafe fn didReceiveDiagnosticPayloads(&self, payloads: &NSArray<MXDiagnosticPayload>);
129    }
130);