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