objc2_metric_kit/generated/
MXHistogram.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// A class that represents a bucket within an MXHistogram
11    ///
12    /// Histogram buckets are sorted in ascending order.
13    ///
14    /// Histogram bucket start and end values are exclusive.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/metrickit/mxhistogrambucket?language=objc)
17    #[unsafe(super(NSObject))]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct MXHistogramBucket<UnitType: ?Sized = AnyObject>;
20);
21
22impl<UnitType: ?Sized + Message + AsRef<NSUnit>> MXHistogramBucket<UnitType> {
23    /// Unchecked conversion of the generic parameter.
24    ///
25    /// # Safety
26    ///
27    /// The generic must be valid to reinterpret as the given type.
28    #[inline]
29    pub unsafe fn cast_unchecked<NewUnitType: ?Sized + Message + AsRef<NSUnit>>(
30        &self,
31    ) -> &MXHistogramBucket<NewUnitType> {
32        unsafe { &*((self as *const Self).cast()) }
33    }
34}
35
36extern_conformance!(
37    unsafe impl<UnitType: ?Sized + NSCoding + AsRef<NSUnit>> NSCoding for MXHistogramBucket<UnitType> {}
38);
39
40extern_conformance!(
41    unsafe impl<UnitType: ?Sized + AsRef<NSUnit>> NSObjectProtocol for MXHistogramBucket<UnitType> {}
42);
43
44extern_conformance!(
45    unsafe impl<UnitType: ?Sized + NSSecureCoding + AsRef<NSUnit>> NSSecureCoding
46        for MXHistogramBucket<UnitType>
47    {
48    }
49);
50
51impl<UnitType: Message + AsRef<NSUnit>> MXHistogramBucket<UnitType> {
52    extern_methods!(
53        /// An NSMeasurement representing the start of a histogram bucket.
54        #[unsafe(method(bucketStart))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn bucketStart(&self) -> Retained<NSMeasurement<UnitType>>;
57
58        /// An NSMeasurement representing the end of a histogram bucket.
59        #[unsafe(method(bucketEnd))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn bucketEnd(&self) -> Retained<NSMeasurement<UnitType>>;
62
63        /// An NSUInteger representing the number of samples in this histogram bucket.
64        #[unsafe(method(bucketCount))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn bucketCount(&self) -> NSUInteger;
67    );
68}
69
70/// Methods declared on superclass `NSObject`.
71impl<UnitType: Message + AsRef<NSUnit>> MXHistogramBucket<UnitType> {
72    extern_methods!(
73        #[unsafe(method(init))]
74        #[unsafe(method_family = init)]
75        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
76
77        #[unsafe(method(new))]
78        #[unsafe(method_family = new)]
79        pub unsafe fn new() -> Retained<Self>;
80    );
81}
82
83extern_class!(
84    /// A class representing bucketized histogram data.
85    ///
86    /// See also [Apple's documentation](https://developer.apple.com/documentation/metrickit/mxhistogram?language=objc)
87    #[unsafe(super(NSObject))]
88    #[derive(Debug, PartialEq, Eq, Hash)]
89    pub struct MXHistogram<UnitType: ?Sized = AnyObject>;
90);
91
92impl<UnitType: ?Sized + Message + AsRef<NSUnit>> MXHistogram<UnitType> {
93    /// Unchecked conversion of the generic parameter.
94    ///
95    /// # Safety
96    ///
97    /// The generic must be valid to reinterpret as the given type.
98    #[inline]
99    pub unsafe fn cast_unchecked<NewUnitType: ?Sized + Message + AsRef<NSUnit>>(
100        &self,
101    ) -> &MXHistogram<NewUnitType> {
102        unsafe { &*((self as *const Self).cast()) }
103    }
104}
105
106extern_conformance!(
107    unsafe impl<UnitType: ?Sized + NSCoding + AsRef<NSUnit>> NSCoding for MXHistogram<UnitType> {}
108);
109
110extern_conformance!(
111    unsafe impl<UnitType: ?Sized + AsRef<NSUnit>> NSObjectProtocol for MXHistogram<UnitType> {}
112);
113
114extern_conformance!(
115    unsafe impl<UnitType: ?Sized + NSSecureCoding + AsRef<NSUnit>> NSSecureCoding
116        for MXHistogram<UnitType>
117    {
118    }
119);
120
121impl<UnitType: Message + AsRef<NSUnit>> MXHistogram<UnitType> {
122    extern_methods!(
123        /// The number of buckets contained within this histogram.
124        ///
125        /// This value can never be negative.
126        #[unsafe(method(totalBucketCount))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn totalBucketCount(&self) -> NSUInteger;
129
130        /// An NSEnumerator that can be used to enumerate the buckets of this histogram.
131        ///
132        /// # Safety
133        ///
134        /// The returned enumerator's underlying collection should not be mutated while in use.
135        #[unsafe(method(bucketEnumerator))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn bucketEnumerator(
138            &self,
139        ) -> Retained<NSEnumerator<MXHistogramBucket<UnitType>>>;
140    );
141}
142
143/// Methods declared on superclass `NSObject`.
144impl<UnitType: Message + AsRef<NSUnit>> MXHistogram<UnitType> {
145    extern_methods!(
146        #[unsafe(method(init))]
147        #[unsafe(method_family = init)]
148        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
149
150        #[unsafe(method(new))]
151        #[unsafe(method_family = new)]
152        pub unsafe fn new() -> Retained<Self>;
153    );
154}