objc2_core_ml/generated/
MLFeatureValue.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::*;
6#[cfg(feature = "objc2-core-video")]
7use objc2_core_video::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// An immutable variant holding a data value of a supported MLFeatureType
14    ///
15    /// MLFeatureValue does not support type conversion in its accessor properties. It
16    /// can also have a missing or undefined value of a well defined type.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mlfeaturevalue?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct MLFeatureValue;
22);
23
24extern_conformance!(
25    unsafe impl NSCoding for MLFeatureValue {}
26);
27
28extern_conformance!(
29    unsafe impl NSCopying for MLFeatureValue {}
30);
31
32unsafe impl CopyingHelper for MLFeatureValue {
33    type Result = Self;
34}
35
36extern_conformance!(
37    unsafe impl NSObjectProtocol for MLFeatureValue {}
38);
39
40extern_conformance!(
41    unsafe impl NSSecureCoding for MLFeatureValue {}
42);
43
44impl MLFeatureValue {
45    extern_methods!(
46        #[cfg(feature = "MLFeatureType")]
47        /// Type of the value for which the corresponding property below is held
48        #[unsafe(method(type))]
49        #[unsafe(method_family = none)]
50        pub unsafe fn r#type(&self) -> MLFeatureType;
51
52        /// True if the value represents a missing or undefined value
53        #[unsafe(method(isUndefined))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn isUndefined(&self) -> bool;
56
57        /// Populated value if the type is MLFeatureTypeInt64
58        #[unsafe(method(int64Value))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn int64Value(&self) -> i64;
61
62        /// Populated value if the type is MLFeatureTypeDouble
63        #[unsafe(method(doubleValue))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn doubleValue(&self) -> c_double;
66
67        /// Populated value if the type is MLFeatureTypeString
68        #[unsafe(method(stringValue))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn stringValue(&self) -> Retained<NSString>;
71
72        #[cfg(feature = "MLMultiArray")]
73        /// Populated value if the type is MLFeatureTypeMultiArray
74        #[unsafe(method(multiArrayValue))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn multiArrayValue(&self) -> Option<Retained<MLMultiArray>>;
77
78        /// Populated value if the type is MLFeatureTypeDictionary
79        #[unsafe(method(dictionaryValue))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn dictionaryValue(&self) -> Retained<NSDictionary<AnyObject, NSNumber>>;
82
83        #[cfg(feature = "objc2-core-video")]
84        /// Populated value if the type is MLFeatureTypeImage
85        #[unsafe(method(imageBufferValue))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn imageBufferValue(&self) -> Option<Retained<CVPixelBuffer>>;
88
89        #[cfg(feature = "MLSequence")]
90        /// Populated value if the type is MLFeatureTypeSequence
91        #[unsafe(method(sequenceValue))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn sequenceValue(&self) -> Option<Retained<MLSequence>>;
94
95        /// Hold an object with the specified value
96        #[unsafe(method(featureValueWithInt64:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn featureValueWithInt64(value: i64) -> Retained<Self>;
99
100        #[unsafe(method(featureValueWithDouble:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn featureValueWithDouble(value: c_double) -> Retained<Self>;
103
104        #[unsafe(method(featureValueWithString:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn featureValueWithString(value: &NSString) -> Retained<Self>;
107
108        #[cfg(feature = "MLMultiArray")]
109        #[unsafe(method(featureValueWithMultiArray:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn featureValueWithMultiArray(value: &MLMultiArray) -> Retained<Self>;
112
113        #[cfg(feature = "objc2-core-video")]
114        #[unsafe(method(featureValueWithPixelBuffer:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn featureValueWithPixelBuffer(value: &CVPixelBuffer) -> Retained<Self>;
117
118        #[cfg(feature = "MLSequence")]
119        #[unsafe(method(featureValueWithSequence:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn featureValueWithSequence(sequence: &MLSequence) -> Retained<Self>;
122
123        #[cfg(feature = "MLFeatureType")]
124        /// Represent an undefined value of a specified type
125        #[unsafe(method(undefinedFeatureValueWithType:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn undefinedFeatureValueWithType(r#type: MLFeatureType) -> Retained<Self>;
128
129        /// For encoding a sparse feature set or for encoding probabilities. Input keys that are not
130        /// NSNumber * or NSString * are rejected on construction and return a MLModelErrorFeatureTypeMismatch
131        /// error. Further validation for consistency occurs on evaluation
132        #[unsafe(method(featureValueWithDictionary:error:_))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn featureValueWithDictionary_error(
135            value: &NSDictionary<AnyObject, NSNumber>,
136        ) -> Result<Retained<Self>, Retained<NSError>>;
137
138        /// Returns a Boolean value that indicates whether a feature value is equal to another.
139        ///
140        ///
141        /// If the types of the MLFeatureValue objects "self" and "value"  are integer in one case and
142        /// double in the other (in either order) then those mixed mode numeric values are compared as NSNumbers.
143        /// Otherwise if the types of the MLFeatureValue objects are different NO is returned.
144        /// When "self" and "value" are both PixelBuffer MLFeatureValue types, only their CVPixelBufferRef values are compared for equality,
145        /// the underlying arrays of pixelValues are not examined.
146        /// [So, distinct PixelBuffer MLFeatureValue objects with distinct CVPixelBufferRef values which encapsulate the same array of pixels will compare *not* equal.]
147        /// For all other (matching) MLFeatureValue types, the BOOL value returned is the result of comparing "self" with "value" via
148        /// isEqualToNumber:, isEqualToString:, isEqualtoDictionary:, isEqualToMultiArray:, isEqualToArray: as chosen by the MLFeatureValue types.
149        #[unsafe(method(isEqualToFeatureValue:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn isEqualToFeatureValue(&self, value: &MLFeatureValue) -> bool;
152    );
153}
154
155/// Methods declared on superclass `NSObject`.
156impl MLFeatureValue {
157    extern_methods!(
158        #[unsafe(method(init))]
159        #[unsafe(method_family = init)]
160        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
161
162        #[unsafe(method(new))]
163        #[unsafe(method_family = new)]
164        pub unsafe fn new() -> Retained<Self>;
165    );
166}