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

/// All possible states an MLTask can be in.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mltaskstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MLTaskState(pub NSInteger);
impl MLTaskState {
    #[doc(alias = "MLTaskStateSuspended")]
    pub const Suspended: Self = Self(1);
    #[doc(alias = "MLTaskStateRunning")]
    pub const Running: Self = Self(2);
    #[doc(alias = "MLTaskStateCancelling")]
    pub const Cancelling: Self = Self(3);
    #[doc(alias = "MLTaskStateCompleted")]
    pub const Completed: Self = Self(4);
    #[doc(alias = "MLTaskStateFailed")]
    pub const Failed: Self = Self(5);
}

unsafe impl Encode for MLTaskState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for MLTaskState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Class that abstracts state transitions and basic task controls.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mltask?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MLTask;
);

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

impl MLTask {
    extern_methods!(
        #[unsafe(method(taskIdentifier))]
        #[unsafe(method_family = none)]
        pub unsafe fn taskIdentifier(&self) -> Retained<NSString>;

        #[unsafe(method(state))]
        #[unsafe(method_family = none)]
        pub unsafe fn state(&self) -> MLTaskState;

        #[unsafe(method(error))]
        #[unsafe(method_family = none)]
        pub unsafe fn error(&self) -> Option<Retained<NSError>>;

        #[unsafe(method(resume))]
        #[unsafe(method_family = none)]
        pub unsafe fn resume(&self);

        #[unsafe(method(cancel))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancel(&self);

        #[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>;
    );
}