objc2-core-ml 0.3.2

Bindings to the CoreML framework
Documentation
//! 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>;
    );
}