use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[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!(
#[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>;
);
}