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::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// A class representing the structure of a model.
    ///
    /// ```text
    /// // Load the model structure.
    /// [MLModelStructure loadContentsOfURL:modelURL completionHandler:^(MLModelStructure * _Nullable modelStructure, NSError * _Nullable error) {
    /// if (!modelStructure) {
    /// // Handle error.
    /// return;
    /// }
    /// if (modelStructure.neuralNetwork) {
    /// // Examine Neural network model.
    /// } else if (modelStructure.program) {
    /// // Examine ML Program model.
    /// } else if (modelStructure.pipeline) {
    /// // Examine Pipeline model.
    /// } else {
    /// // The model type is something else.
    /// }
    /// }];
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mlmodelstructure?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MLModelStructure;
);

unsafe impl Send for MLModelStructure {}

unsafe impl Sync for MLModelStructure {}

extern_conformance!(
    unsafe impl NSObjectProtocol for MLModelStructure {}
);

impl MLModelStructure {
    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>;

        #[cfg(feature = "block2")]
        /// Construct the model structure asynchronously given the location of its on-disk representation.
        ///
        ///
        /// Parameter `url`: The location of its on-disk representation (.mlmodelc directory).
        ///
        /// Parameter `handler`: When the model structure is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLModelStructure instance or NSError object.
        #[unsafe(method(loadContentsOfURL:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadContentsOfURL_completionHandler(
            url: &NSURL,
            handler: &block2::DynBlock<dyn Fn(*mut MLModelStructure, *mut NSError)>,
        );

        #[cfg(all(feature = "MLModelAsset", feature = "block2"))]
        /// Construct the model structure asynchronously  given the model asset.
        ///
        ///
        /// Parameter `asset`: The model asset.
        ///
        /// Parameter `handler`: When the model structure is constructed successfully or unsuccessfully, the completion handler is invoked with a valid MLModelStructure instance or NSError object.
        #[unsafe(method(loadModelAsset:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadModelAsset_completionHandler(
            asset: &MLModelAsset,
            handler: &block2::DynBlock<dyn Fn(*mut MLModelStructure, *mut NSError)>,
        );

        #[cfg(feature = "MLModelStructureNeuralNetwork")]
        /// If the model is of NeuralNetwork type then it is the structure of the NeuralNetwork otherwise `nil`.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(neuralNetwork))]
        #[unsafe(method_family = none)]
        pub unsafe fn neuralNetwork(&self) -> Option<Retained<MLModelStructureNeuralNetwork>>;

        #[cfg(feature = "MLModelStructureProgram")]
        /// If the model is of ML Program type then it is the structure of the ML Program otherwise `nil`.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(program))]
        #[unsafe(method_family = none)]
        pub unsafe fn program(&self) -> Option<Retained<MLModelStructureProgram>>;

        #[cfg(feature = "MLModelStructurePipeline")]
        /// If the model is of Pipeline type then it is the structure of the Pipeline otherwise `nil`.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(pipeline))]
        #[unsafe(method_family = none)]
        pub unsafe fn pipeline(&self) -> Option<Retained<MLModelStructurePipeline>>;
    );
}