objc2_core_ml/generated/
MLTask.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// All possible states an MLTask can be in.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mltaskstate?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct MLTaskState(pub NSInteger);
17impl MLTaskState {
18    #[doc(alias = "MLTaskStateSuspended")]
19    pub const Suspended: Self = Self(1);
20    #[doc(alias = "MLTaskStateRunning")]
21    pub const Running: Self = Self(2);
22    #[doc(alias = "MLTaskStateCancelling")]
23    pub const Cancelling: Self = Self(3);
24    #[doc(alias = "MLTaskStateCompleted")]
25    pub const Completed: Self = Self(4);
26    #[doc(alias = "MLTaskStateFailed")]
27    pub const Failed: Self = Self(5);
28}
29
30unsafe impl Encode for MLTaskState {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for MLTaskState {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_class!(
39    /// Class that abstracts state transitions and basic task controls.
40    ///
41    /// See also [Apple's documentation](https://developer.apple.com/documentation/coreml/mltask?language=objc)
42    #[unsafe(super(NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    pub struct MLTask;
45);
46
47extern_conformance!(
48    unsafe impl NSObjectProtocol for MLTask {}
49);
50
51impl MLTask {
52    extern_methods!(
53        #[unsafe(method(taskIdentifier))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn taskIdentifier(&self) -> Retained<NSString>;
56
57        #[unsafe(method(state))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn state(&self) -> MLTaskState;
60
61        #[unsafe(method(error))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
64
65        #[unsafe(method(resume))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn resume(&self);
68
69        #[unsafe(method(cancel))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn cancel(&self);
72
73        #[unsafe(method(init))]
74        #[unsafe(method_family = init)]
75        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
76
77        #[unsafe(method(new))]
78        #[unsafe(method_family = new)]
79        pub unsafe fn new() -> Retained<Self>;
80    );
81}