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