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