1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! 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 that enables a file system module to pass log messages and completion notifications to clients.
///
/// FSKit creates an instance of this class for each long-running operations.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fstask?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct FSTask;
);
extern_conformance!(
unsafe impl NSObjectProtocol for FSTask {}
);
impl FSTask {
extern_methods!(
/// Logs the given string to the initiating client.
///
/// - Parameter str: The string to log.
#[unsafe(method(logMessage:))]
#[unsafe(method_family = none)]
pub unsafe fn logMessage(&self, str: &NSString);
/// Informs the client that the task completed.
///
/// - Parameter error: `nil` if the task completed successfully; otherwise, an error that caused the task to fail.
#[unsafe(method(didCompleteWithError:))]
#[unsafe(method_family = none)]
pub unsafe fn didCompleteWithError(&self, error: Option<&NSError>);
#[cfg(feature = "block2")]
/// ```obj-c
/// {
/// NSProgress *progress = [[NSProgress alloc] init];
/// yourFileSystemChecker *checker= [[yourFileSystemChecker alloc] init];
/// checker.work_group = dispatch_group_create();
/// dispatch_group_enter(checker.work_group);
/// [task setCancellationHandler:^NSError * _Nullable{
/// checker.terminate = TRUE;
/// dispatch_group_wait(checker.work_group);
/// return nil;
/// }];
/// dispatch_async(someQueue, ^{[self performCheck:task progress:progress];});
/// return progress;
/// }
/// ```
///
/// > Note: this example did not account for errors while delivered code must. finally, the `performCheck`
/// code should perform the check operation. It should periodically update the progress object and check
/// its `interrupted` variable. The check can either complete successfully, complete with an error, or
/// be interrupted. It should then call `[task didCompleteWithError:...]` wtih the appropriate
/// error value or nil. Finally it should `dispatch_group_leave(self.work_group);`
///
/// - Returns: An error if the cancellation did not complete successfully. Any returned error will be logged, and FSKit will then terminate all activity in the container.
///
/// # Safety
///
/// The returned block must be sendable.
#[unsafe(method(cancellationHandler))]
#[unsafe(method_family = none)]
pub unsafe fn cancellationHandler(&self)
-> *mut block2::DynBlock<dyn Fn() -> *mut NSError>;
#[cfg(feature = "block2")]
/// Setter for [`cancellationHandler`][Self::cancellationHandler].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `cancellation_handler` block must be sendable.
#[unsafe(method(setCancellationHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setCancellationHandler(
&self,
cancellation_handler: Option<&block2::DynBlock<dyn Fn() -> *mut NSError>>,
);
);
}
/// Methods declared on superclass `NSObject`.
impl FSTask {
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>;
);
}