objc2_fs_kit/generated/
FSVolume.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/// A value that indicates a location in a directory from which to enumerate.
11///
12/// Your implementation of ``FSVolume/Operations/enumerateDirectory(_:startingAt:verifier:attributes:packer:replyHandler:)`` defines the semantics of this value; it's opaque to FSKit.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsdirectorycookie?language=objc)
15// NS_TYPED_EXTENSIBLE_ENUM
16pub type FSDirectoryCookie = u64;
17
18extern "C" {
19    /// The constant initial value for the directory-enumeration cookie.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsdirectorycookieinitial?language=objc)
22    pub static FSDirectoryCookieInitial: FSDirectoryCookie;
23}
24
25/// A tool to detect whether the directory contents changed since the last call to enumerate a directory.
26///
27/// Your implementation of ``FSVolume/Operations/enumerateDirectory(_:startingAt:verifier:attributes:packer:replyHandler:)`` defines the semantics of this value; it's opaque to FSKit.
28///
29/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsdirectoryverifier?language=objc)
30// NS_TYPED_EXTENSIBLE_ENUM
31pub type FSDirectoryVerifier = u64;
32
33extern "C" {
34    /// The constant initial value for the directory-enumeration verifier.
35    ///
36    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsdirectoryverifierinitial?language=objc)
37    pub static FSDirectoryVerifierInitial: FSDirectoryVerifier;
38}
39
40/// Options that affect the behavior of deactivate methods.
41///
42/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsdeactivateoptions?language=objc)
43// NS_OPTIONS
44#[repr(transparent)]
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
46pub struct FSDeactivateOptions(pub NSInteger);
47bitflags::bitflags! {
48    impl FSDeactivateOptions: NSInteger {
49/// An option to force deactivation.
50        #[doc(alias = "FSDeactivateOptionsForce")]
51        const Force = 1<<0;
52    }
53}
54
55unsafe impl Encode for FSDeactivateOptions {
56    const ENCODING: Encoding = NSInteger::ENCODING;
57}
58
59unsafe impl RefEncode for FSDeactivateOptions {
60    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63/// Behavior flags for use with synchronization calls.
64///
65/// These values are based on flags defined in `mount.h`. Since there are system-defined flags that are valid in the kernel but not in FSKit, this type defines its members as options rather than use an enumeration.
66///
67/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fssyncflags?language=objc)
68// NS_ENUM
69#[repr(transparent)]
70#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
71pub struct FSSyncFlags(pub NSInteger);
72impl FSSyncFlags {
73    /// A flag for synchronized I/O with file-integrity completion.
74    #[doc(alias = "FSSyncFlagsWait")]
75    pub const Wait: Self = Self(1);
76    /// A flag for synchronized I/O that starts I/O but doesn't wait for it.
77    #[doc(alias = "FSSyncFlagsNoWait")]
78    pub const NoWait: Self = Self(2);
79    /// A flag for synchronized I/O with data-integrity completion.
80    #[doc(alias = "FSSyncFlagsDWait")]
81    pub const DWait: Self = Self(4);
82}
83
84unsafe impl Encode for FSSyncFlags {
85    const ENCODING: Encoding = NSInteger::ENCODING;
86}
87
88unsafe impl RefEncode for FSSyncFlags {
89    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
90}
91
92extern_class!(
93    /// A type that identifies a volume.
94    ///
95    /// For most volumes, the volume identifier is the UUID identifying the volume.
96    ///
97    /// Network file systems may access the same underlying volume using different authentication credentials.
98    /// To handle this situation, add qualifying data to identify the specific container, as discussed in the superclass, ``FSEntityIdentifier``.
99    ///
100    /// > Important: Don't subclass this class.
101    ///
102    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumeidentifier?language=objc)
103    #[unsafe(super(FSEntityIdentifier, NSObject))]
104    #[derive(Debug, PartialEq, Eq, Hash)]
105    #[cfg(feature = "FSEntityIdentifier")]
106    pub struct FSVolumeIdentifier;
107);
108
109#[cfg(feature = "FSEntityIdentifier")]
110extern_conformance!(
111    unsafe impl NSCoding for FSVolumeIdentifier {}
112);
113
114#[cfg(feature = "FSEntityIdentifier")]
115extern_conformance!(
116    unsafe impl NSCopying for FSVolumeIdentifier {}
117);
118
119#[cfg(feature = "FSEntityIdentifier")]
120unsafe impl CopyingHelper for FSVolumeIdentifier {
121    type Result = Self;
122}
123
124#[cfg(feature = "FSEntityIdentifier")]
125extern_conformance!(
126    unsafe impl NSObjectProtocol for FSVolumeIdentifier {}
127);
128
129#[cfg(feature = "FSEntityIdentifier")]
130extern_conformance!(
131    unsafe impl NSSecureCoding for FSVolumeIdentifier {}
132);
133
134#[cfg(feature = "FSEntityIdentifier")]
135impl FSVolumeIdentifier {
136    extern_methods!();
137}
138
139/// Methods declared on superclass `FSEntityIdentifier`.
140#[cfg(feature = "FSEntityIdentifier")]
141impl FSVolumeIdentifier {
142    extern_methods!(
143        /// Creates an entity identifier with a random UUID.
144        #[unsafe(method(init))]
145        #[unsafe(method_family = init)]
146        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
147
148        /// Creates an entity identifier with the given UUID.
149        ///
150        /// - Parameter uuid: The UUID to use for this identifier.
151        #[unsafe(method(initWithUUID:))]
152        #[unsafe(method_family = init)]
153        pub unsafe fn initWithUUID(this: Allocated<Self>, uuid: &NSUUID) -> Retained<Self>;
154
155        /// Creates an entity identifier with the given UUID and qualifier data as a 64-bit unsigned integer.
156        /// - Parameters:
157        /// - uuid: The UUID to use for this identifier.
158        /// - qualifier: The data to distinguish entities that otherwise share the same UUID.
159        #[unsafe(method(initWithUUID:qualifier:))]
160        #[unsafe(method_family = init)]
161        pub unsafe fn initWithUUID_qualifier(
162            this: Allocated<Self>,
163            uuid: &NSUUID,
164            qualifier: u64,
165        ) -> Retained<Self>;
166
167        /// Creates an entity identifier with the given UUID and qualifier data.
168        ///
169        /// - Parameters:
170        /// - uuid: The UUID to use for this identifier.
171        /// - qualifierData: The data to distinguish entities that otherwise share the same UUID.
172        #[unsafe(method(initWithUUID:data:))]
173        #[unsafe(method_family = init)]
174        pub unsafe fn initWithUUID_data(
175            this: Allocated<Self>,
176            uuid: &NSUUID,
177            qualifier_data: &NSData,
178        ) -> Retained<Self>;
179    );
180}
181
182/// Methods declared on superclass `NSObject`.
183#[cfg(feature = "FSEntityIdentifier")]
184impl FSVolumeIdentifier {
185    extern_methods!(
186        #[unsafe(method(new))]
187        #[unsafe(method_family = new)]
188        pub unsafe fn new() -> Retained<Self>;
189    );
190}
191
192extern_class!(
193    /// An object used to provide items during a directory enumeration.
194    ///
195    /// You use this type in your implementation of ``FSVolume/Operations/enumerateDirectory(_:startingAt:verifier:attributes:packer:replyHandler:)``.
196    ///
197    /// Packing allows your implementation to provide information FSKit needs, including each item's name, type, and identifier (such as an inode number).
198    /// Some directory enumerations require other attributes, as indicated by the ``FSItemGetAttributesRequest`` sent to the enumerate method.
199    ///
200    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsdirectoryentrypacker?language=objc)
201    #[unsafe(super(NSObject))]
202    #[derive(Debug, PartialEq, Eq, Hash)]
203    pub struct FSDirectoryEntryPacker;
204);
205
206extern_conformance!(
207    unsafe impl NSObjectProtocol for FSDirectoryEntryPacker {}
208);
209
210impl FSDirectoryEntryPacker {
211    extern_methods!(
212        #[unsafe(method(init))]
213        #[unsafe(method_family = init)]
214        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
215
216        #[cfg(all(feature = "FSFileName", feature = "FSItem"))]
217        /// Provides a directory entry during enumeration.
218        ///
219        /// You call this method in your implementation of ``FSVolume/Operations/enumerateDirectory(_:startingAt:verifier:attributes:packer:replyHandler:)``, for each directory entry you want to provide to the enumeration.
220        ///
221        /// - Parameters:
222        /// - name: The item's name.
223        /// - itemType: The type of the item.
224        /// - itemID: The item's identifier.
225        /// - nextCookie: A value to indicate the next entry in the directory to enumerate. FSKit passes this value as the `cookie` parameter on the next call to ``FSVolume/Operations/enumerateDirectory(_:startingAt:verifier:attributes:packer:replyHandler:)``. Use whatever value is appropriate for your implementation; the value is opaque to FSKit.
226        /// - attributes: The item's attributes. Pass `nil` if the enumeration call didn't request attributes.
227        /// - Returns: `true` (Swift) or `YES` (Objective-C) if packing was successful and enumeration can continue with the next directory entry. If the value is `false` (Swift) or `NO` (Objective-C), stop enumerating. This result can happen when the entry is too big for the remaining space in the buffer.
228        #[unsafe(method(packEntryWithName:itemType:itemID:nextCookie:attributes:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn packEntryWithName_itemType_itemID_nextCookie_attributes(
231            &self,
232            name: &FSFileName,
233            item_type: FSItemType,
234            item_id: FSItemID,
235            next_cookie: FSDirectoryCookie,
236            attributes: Option<&FSItemAttributes>,
237        ) -> bool;
238    );
239}
240
241/// Methods declared on superclass `NSObject`.
242impl FSDirectoryEntryPacker {
243    extern_methods!(
244        #[unsafe(method(new))]
245        #[unsafe(method_family = new)]
246        pub unsafe fn new() -> Retained<Self>;
247    );
248}
249
250/// An enumeration of case-sensitivity support types.
251///
252/// A case-sensitive volume is a volume that treats upper and lower case characters in file and directory names as being distinct from each other. For example, `FILE.TXT` and `file.TXT` are different names in a case-sensitive volume, and the same name in a case-insensitive volume.
253///
254/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumecaseformat?language=objc)
255// NS_ENUM
256#[repr(transparent)]
257#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
258pub struct FSVolumeCaseFormat(pub NSInteger);
259impl FSVolumeCaseFormat {
260    /// The volume is case sensitive.
261    #[doc(alias = "FSVolumeCaseFormatSensitive")]
262    pub const Sensitive: Self = Self(0);
263    /// The volume isn't case sensitive.
264    #[doc(alias = "FSVolumeCaseFormatInsensitive")]
265    pub const Insensitive: Self = Self(1);
266    /// The volume isn't case sensitive, but supports preserving the case of file and directory names.
267    #[doc(alias = "FSVolumeCaseFormatInsensitiveCasePreserving")]
268    pub const InsensitiveCasePreserving: Self = Self(2);
269}
270
271unsafe impl Encode for FSVolumeCaseFormat {
272    const ENCODING: Encoding = NSInteger::ENCODING;
273}
274
275unsafe impl RefEncode for FSVolumeCaseFormat {
276    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
277}
278
279extern_class!(
280    /// A type that represents capabillities supported by a volume, such as hard and symbolic links, journaling, and large file sizes.
281    ///
282    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumesupportedcapabilities?language=objc)
283    #[unsafe(super(NSObject))]
284    #[derive(Debug, PartialEq, Eq, Hash)]
285    pub struct FSVolumeSupportedCapabilities;
286);
287
288extern_conformance!(
289    unsafe impl NSCoding for FSVolumeSupportedCapabilities {}
290);
291
292extern_conformance!(
293    unsafe impl NSObjectProtocol for FSVolumeSupportedCapabilities {}
294);
295
296extern_conformance!(
297    unsafe impl NSSecureCoding for FSVolumeSupportedCapabilities {}
298);
299
300impl FSVolumeSupportedCapabilities {
301    extern_methods!(
302        /// A Boolean property that indicates whether the volume supports persistent object identifiers and can look up file system objects by their IDs.
303        #[unsafe(method(supportsPersistentObjectIDs))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn supportsPersistentObjectIDs(&self) -> bool;
306
307        /// Setter for [`supportsPersistentObjectIDs`][Self::supportsPersistentObjectIDs].
308        #[unsafe(method(setSupportsPersistentObjectIDs:))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn setSupportsPersistentObjectIDs(&self, supports_persistent_object_i_ds: bool);
311
312        /// A Boolean property that indicates whether the volume supports symbolic links.
313        #[unsafe(method(supportsSymbolicLinks))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn supportsSymbolicLinks(&self) -> bool;
316
317        /// Setter for [`supportsSymbolicLinks`][Self::supportsSymbolicLinks].
318        #[unsafe(method(setSupportsSymbolicLinks:))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn setSupportsSymbolicLinks(&self, supports_symbolic_links: bool);
321
322        /// A Boolean property that indicates whether the volume supports hard links.
323        #[unsafe(method(supportsHardLinks))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn supportsHardLinks(&self) -> bool;
326
327        /// Setter for [`supportsHardLinks`][Self::supportsHardLinks].
328        #[unsafe(method(setSupportsHardLinks:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn setSupportsHardLinks(&self, supports_hard_links: bool);
331
332        /// A Boolean property that indicates whether the volume supports a journal used to speed recovery in case of unplanned restart, such as a power outage or crash.
333        ///
334        /// This property doesn't necessarily mean the volume is actively using a journal.
335        #[unsafe(method(supportsJournal))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn supportsJournal(&self) -> bool;
338
339        /// Setter for [`supportsJournal`][Self::supportsJournal].
340        #[unsafe(method(setSupportsJournal:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn setSupportsJournal(&self, supports_journal: bool);
343
344        /// A Boolean property that indicates whether the volume currently uses a journal for speeding recovery after an unplanned shutdown.
345        #[unsafe(method(supportsActiveJournal))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn supportsActiveJournal(&self) -> bool;
348
349        /// Setter for [`supportsActiveJournal`][Self::supportsActiveJournal].
350        #[unsafe(method(setSupportsActiveJournal:))]
351        #[unsafe(method_family = none)]
352        pub unsafe fn setSupportsActiveJournal(&self, supports_active_journal: bool);
353
354        /// A Boolan property that indicates the volume doesn't store reliable times for the root directory.
355        ///
356        /// If this value is `true` (Swift) or `YES` (Objective-C), the volume doesn't store reliable times for the root directory.
357        #[unsafe(method(doesNotSupportRootTimes))]
358        #[unsafe(method_family = none)]
359        pub unsafe fn doesNotSupportRootTimes(&self) -> bool;
360
361        /// Setter for [`doesNotSupportRootTimes`][Self::doesNotSupportRootTimes].
362        #[unsafe(method(setDoesNotSupportRootTimes:))]
363        #[unsafe(method_family = none)]
364        pub unsafe fn setDoesNotSupportRootTimes(&self, does_not_support_root_times: bool);
365
366        /// A Boolean property that indicates whether the volume supports sparse files.
367        ///
368        /// A sparse file is a file that can have "holes" that the file system has never written to, and as a result don't consume space on disk.
369        #[unsafe(method(supportsSparseFiles))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn supportsSparseFiles(&self) -> bool;
372
373        /// Setter for [`supportsSparseFiles`][Self::supportsSparseFiles].
374        #[unsafe(method(setSupportsSparseFiles:))]
375        #[unsafe(method_family = none)]
376        pub unsafe fn setSupportsSparseFiles(&self, supports_sparse_files: bool);
377
378        /// A Boolean property that indicates whether the volume supports zero runs
379        ///
380        /// If this value is true, the volume keeps track of allocated but unwritten runs of a file so that it can substitute zeroes without actually writing zeroes to the media.
381        #[unsafe(method(supportsZeroRuns))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn supportsZeroRuns(&self) -> bool;
384
385        /// Setter for [`supportsZeroRuns`][Self::supportsZeroRuns].
386        #[unsafe(method(setSupportsZeroRuns:))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn setSupportsZeroRuns(&self, supports_zero_runs: bool);
389
390        /// A Boolean property that indicates whether the volume supports fast results when fetching file system statistics.
391        ///
392        /// A true value means this volume hints to upper layers to indicate that `statfs(2)` is fast enough that its results need not be cached by the caller.
393        #[unsafe(method(supportsFastStatFS))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn supportsFastStatFS(&self) -> bool;
396
397        /// Setter for [`supportsFastStatFS`][Self::supportsFastStatFS].
398        #[unsafe(method(setSupportsFastStatFS:))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn setSupportsFastStatFS(&self, supports_fast_stat_fs: bool);
401
402        /// A Boolean property that indicates whether the volume supports file sizes larger than 4GB, and potentially up to 2TB.
403        #[unsafe(method(supports2TBFiles))]
404        #[unsafe(method_family = none)]
405        pub unsafe fn supports2TBFiles(&self) -> bool;
406
407        /// Setter for [`supports2TBFiles`][Self::supports2TBFiles].
408        #[unsafe(method(setSupports2TBFiles:))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn setSupports2TBFiles(&self, supports2_tb_files: bool);
411
412        /// A Boolean property that indicates whether the volume supports open deny modes.
413        ///
414        /// These are modes such as "open for read write, deny write".
415        #[unsafe(method(supportsOpenDenyModes))]
416        #[unsafe(method_family = none)]
417        pub unsafe fn supportsOpenDenyModes(&self) -> bool;
418
419        /// Setter for [`supportsOpenDenyModes`][Self::supportsOpenDenyModes].
420        #[unsafe(method(setSupportsOpenDenyModes:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn setSupportsOpenDenyModes(&self, supports_open_deny_modes: bool);
423
424        /// A Boolean property that indicates whether the volume supports hidden files.
425        ///
426        /// A `true` value means the volume supports the `UF_HIDDEN` file flag.
427        #[unsafe(method(supportsHiddenFiles))]
428        #[unsafe(method_family = none)]
429        pub unsafe fn supportsHiddenFiles(&self) -> bool;
430
431        /// Setter for [`supportsHiddenFiles`][Self::supportsHiddenFiles].
432        #[unsafe(method(setSupportsHiddenFiles:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn setSupportsHiddenFiles(&self, supports_hidden_files: bool);
435
436        /// A Boolean property that indicates the volume doesn't support certain volume size reports.
437        ///
438        /// A true value means the volume doesn't support determining values for total data blocks, available blocks, or free blocks, as in `f_blocks`, `f_bavail`, and `f_bfree` in the struct `statFS` returned by `statfs(2)`.
439        #[unsafe(method(doesNotSupportVolumeSizes))]
440        #[unsafe(method_family = none)]
441        pub unsafe fn doesNotSupportVolumeSizes(&self) -> bool;
442
443        /// Setter for [`doesNotSupportVolumeSizes`][Self::doesNotSupportVolumeSizes].
444        #[unsafe(method(setDoesNotSupportVolumeSizes:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn setDoesNotSupportVolumeSizes(&self, does_not_support_volume_sizes: bool);
447
448        /// A Boolean property that indicates whether the volume supports 64-bit object IDs.
449        #[unsafe(method(supports64BitObjectIDs))]
450        #[unsafe(method_family = none)]
451        pub unsafe fn supports64BitObjectIDs(&self) -> bool;
452
453        /// Setter for [`supports64BitObjectIDs`][Self::supports64BitObjectIDs].
454        #[unsafe(method(setSupports64BitObjectIDs:))]
455        #[unsafe(method_family = none)]
456        pub unsafe fn setSupports64BitObjectIDs(&self, supports64_bit_object_i_ds: bool);
457
458        /// A Boolean property that indicates whether the volume supports document IDs for document revisions.
459        ///
460        /// A document ID is an identifier that persists across object ID changes.
461        #[unsafe(method(supportsDocumentID))]
462        #[unsafe(method_family = none)]
463        pub unsafe fn supportsDocumentID(&self) -> bool;
464
465        /// Setter for [`supportsDocumentID`][Self::supportsDocumentID].
466        #[unsafe(method(setSupportsDocumentID:))]
467        #[unsafe(method_family = none)]
468        pub unsafe fn setSupportsDocumentID(&self, supports_document_id: bool);
469
470        /// A Boolean property that indicates the volume doesn't support immutable files.
471        ///
472        /// A `true` value means this volume doesn't support setting the `UF_IMMUTABLE` flag.
473        #[unsafe(method(doesNotSupportImmutableFiles))]
474        #[unsafe(method_family = none)]
475        pub unsafe fn doesNotSupportImmutableFiles(&self) -> bool;
476
477        /// Setter for [`doesNotSupportImmutableFiles`][Self::doesNotSupportImmutableFiles].
478        #[unsafe(method(setDoesNotSupportImmutableFiles:))]
479        #[unsafe(method_family = none)]
480        pub unsafe fn setDoesNotSupportImmutableFiles(
481            &self,
482            does_not_support_immutable_files: bool,
483        );
484
485        /// A Boolean property that indicates the volume doesn't set file permissions.
486        ///
487        /// If this value is `true` (Swift) or `YES` (Objective-C), the volume doesn't support setting file permissions.
488        #[unsafe(method(doesNotSupportSettingFilePermissions))]
489        #[unsafe(method_family = none)]
490        pub unsafe fn doesNotSupportSettingFilePermissions(&self) -> bool;
491
492        /// Setter for [`doesNotSupportSettingFilePermissions`][Self::doesNotSupportSettingFilePermissions].
493        #[unsafe(method(setDoesNotSupportSettingFilePermissions:))]
494        #[unsafe(method_family = none)]
495        pub unsafe fn setDoesNotSupportSettingFilePermissions(
496            &self,
497            does_not_support_setting_file_permissions: bool,
498        );
499
500        /// A Boolean property that indicates whether the volume supports multiple logical file systems that share space in a single "partition."
501        #[unsafe(method(supportsSharedSpace))]
502        #[unsafe(method_family = none)]
503        pub unsafe fn supportsSharedSpace(&self) -> bool;
504
505        /// Setter for [`supportsSharedSpace`][Self::supportsSharedSpace].
506        #[unsafe(method(setSupportsSharedSpace:))]
507        #[unsafe(method_family = none)]
508        pub unsafe fn setSupportsSharedSpace(&self, supports_shared_space: bool);
509
510        /// A Boolean property that indicates whether the volume supports volume groups.
511        ///
512        /// Volume groups involve multiple logical file systems that the system can mount and unmount together, and for which the system can present common file system identifier information.
513        #[unsafe(method(supportsVolumeGroups))]
514        #[unsafe(method_family = none)]
515        pub unsafe fn supportsVolumeGroups(&self) -> bool;
516
517        /// Setter for [`supportsVolumeGroups`][Self::supportsVolumeGroups].
518        #[unsafe(method(setSupportsVolumeGroups:))]
519        #[unsafe(method_family = none)]
520        pub unsafe fn setSupportsVolumeGroups(&self, supports_volume_groups: bool);
521
522        /// A value that indicates the volume's support for case sensitivity.
523        #[unsafe(method(caseFormat))]
524        #[unsafe(method_family = none)]
525        pub unsafe fn caseFormat(&self) -> FSVolumeCaseFormat;
526
527        /// Setter for [`caseFormat`][Self::caseFormat].
528        #[unsafe(method(setCaseFormat:))]
529        #[unsafe(method_family = none)]
530        pub unsafe fn setCaseFormat(&self, case_format: FSVolumeCaseFormat);
531    );
532}
533
534/// Methods declared on superclass `NSObject`.
535impl FSVolumeSupportedCapabilities {
536    extern_methods!(
537        #[unsafe(method(init))]
538        #[unsafe(method_family = init)]
539        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
540
541        #[unsafe(method(new))]
542        #[unsafe(method_family = new)]
543        pub unsafe fn new() -> Retained<Self>;
544    );
545}
546
547extern_class!(
548    /// A directory structure for files and folders.
549    ///
550    /// A file system, depending on its type, provides one or more volumes to clients.
551    /// The ``FSUnaryFileSystem`` by definition provides only one volume, while an ``FSFileSystem`` supports multiple volumes.
552    ///
553    /// You implement a volume for your file system type by subclassing this class, and also conforming to the ``FSVolume/Operations`` and ``FSVolume/PathConfOperations`` protocols.
554    /// This protocol defines the minimum set of operations supported by a volume, such as mounting, activating, creating and removing items, and more.
555    ///
556    /// Your volume can provide additional functionality by conforming to other volume operations protocols.
557    /// These protocols add support for operations like open and close, read and write, extended attribute (Xattr) manipulation, and more.
558    ///
559    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolume?language=objc)
560    #[unsafe(super(NSObject))]
561    #[derive(Debug, PartialEq, Eq, Hash)]
562    pub struct FSVolume;
563);
564
565extern_conformance!(
566    unsafe impl NSObjectProtocol for FSVolume {}
567);
568
569impl FSVolume {
570    extern_methods!(
571        #[cfg(feature = "FSEntityIdentifier")]
572        /// An identifier that uniquely identifies the volume.
573        #[unsafe(method(volumeID))]
574        #[unsafe(method_family = none)]
575        pub unsafe fn volumeID(&self) -> Retained<FSVolumeIdentifier>;
576
577        #[cfg(feature = "FSFileName")]
578        /// The name of the volume.
579        #[unsafe(method(name))]
580        #[unsafe(method_family = none)]
581        pub unsafe fn name(&self) -> Retained<FSFileName>;
582
583        #[cfg(feature = "FSFileName")]
584        /// Setter for [`name`][Self::name].
585        ///
586        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
587        #[unsafe(method(setName:))]
588        #[unsafe(method_family = none)]
589        pub unsafe fn setName(&self, name: &FSFileName);
590
591        #[unsafe(method(init))]
592        #[unsafe(method_family = init)]
593        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
594
595        #[cfg(all(feature = "FSEntityIdentifier", feature = "FSFileName"))]
596        /// Creates a volume with the given identifier and name.
597        /// - Parameters:
598        /// - volumeID: An ``FSVolumeIdentifier`` to uniquely identify the volume. For a network file system that supports multiple authenticated users, disambiguate the users by using qualifying data in the identifier.
599        /// - volumeName: A name for the volume.
600        #[unsafe(method(initWithVolumeID:volumeName:))]
601        #[unsafe(method_family = init)]
602        pub unsafe fn initWithVolumeID_volumeName(
603            this: Allocated<Self>,
604            volume_id: &FSVolumeIdentifier,
605            volume_name: &FSFileName,
606        ) -> Retained<Self>;
607    );
608}
609
610/// Methods declared on superclass `NSObject`.
611impl FSVolume {
612    extern_methods!(
613        #[unsafe(method(new))]
614        #[unsafe(method_family = new)]
615        pub unsafe fn new() -> Retained<Self>;
616    );
617}
618
619extern_protocol!(
620    /// Properties implemented by volumes that support providing the values of system limits or options.
621    ///
622    /// This protocol gathers properties related to the `pathconf` and `fpathconf` system calls.
623    ///
624    /// For a file, the value of a property applies to just that file; for a directory, the value applies to all items in the directory.
625    ///
626    /// Properties that represent limits and have a numeric type use `-1` to represent no limit.
627    ///
628    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumepathconfoperations?language=objc)
629    pub unsafe trait FSVolumePathConfOperations: NSObjectProtocol {
630        /// A property that represents the maximum number of hard links to the object.
631        #[unsafe(method(maximumLinkCount))]
632        #[unsafe(method_family = none)]
633        unsafe fn maximumLinkCount(&self) -> NSInteger;
634
635        /// A property that represents the maximum length of a component of a filename.
636        #[unsafe(method(maximumNameLength))]
637        #[unsafe(method_family = none)]
638        unsafe fn maximumNameLength(&self) -> NSInteger;
639
640        /// A Boolean property that indicates whether the volume restricts ownership changes based on authorization.
641        ///
642        /// If this value is true, the volume rejects a `chown(2)` from anyone other than the superuser.
643        #[unsafe(method(restrictsOwnershipChanges))]
644        #[unsafe(method_family = none)]
645        unsafe fn restrictsOwnershipChanges(&self) -> bool;
646
647        /// A property that indicates whether the volume truncates files longer than its maximum supported length.
648        ///
649        /// If this value is `true`, the volume truncates the filename to ``maximumNameLength`` if the filename is longer than that.
650        /// If this value is false, the file system responds with the error code `ENAMETOOLONG` if the filename is longer than ``maximumNameLength``.
651        #[unsafe(method(truncatesLongNames))]
652        #[unsafe(method_family = none)]
653        unsafe fn truncatesLongNames(&self) -> bool;
654
655        /// The maximum extended attribute size in bytes.
656        ///
657        /// Implement at least one of `maximumXattrSize` or ``maximumXattrSizeInBits``.
658        /// FSKit automatically converts from one to another if needed.
659        /// If you implement both, FSKit uses only the `maximumXattrSizeInBits` implementation.
660        #[optional]
661        #[unsafe(method(maximumXattrSize))]
662        #[unsafe(method_family = none)]
663        unsafe fn maximumXattrSize(&self) -> NSInteger;
664
665        /// The maximum extended attribute size in bits.
666        ///
667        /// Implement at least one of ``maximumXattrSize`` or `maximumXattrSizeInBits`.
668        /// FSKit automatically converts from one to another if needed.
669        /// If you implement both, FSKit uses only the `maximumXattrSizeInBits` implementation.
670        #[optional]
671        #[unsafe(method(maximumXattrSizeInBits))]
672        #[unsafe(method_family = none)]
673        unsafe fn maximumXattrSizeInBits(&self) -> NSInteger;
674
675        /// The maximum size of a regular file allowed in the volume.
676        ///
677        /// Implement at least one of `maximumFileSize` or ``maximumFileSizeInBits``.
678        /// FSKit automatically converts from one to another if needed.
679        /// If you implement both, FSKit uses only the `maximumFileSizeInBits` implementation.
680        #[optional]
681        #[unsafe(method(maximumFileSize))]
682        #[unsafe(method_family = none)]
683        unsafe fn maximumFileSize(&self) -> u64;
684
685        /// The minimum number of bits needed to represent, as a signed integer value, the maximum size of a regular file allowed in the volume.
686        ///
687        /// The maximum file size is `2^(maximumFileSizeInBits - 1)`.
688        ///
689        /// | Maximum file size (bytes)  | Maximum (in hex)     | Unsigned bits | Signed bits |
690        /// | -------------------------: | -------------------: | ------------: | ----------: |
691        /// |                     65,535 |             `0xFFFF` |            16 |          17 |
692        /// |              2,147,483,647 |         `0x7FFFFFFF` |            31 |          32 |
693        /// |              4,294,967,295 |         `0xFFFFFFFF` |            32 |          33 |
694        /// | 18,446,744,073,709,551,615 | `0xFFFFFFFFFFFFFFFF` |            64 |          65 |
695        ///
696        /// Implement at least one of ``maximumFileSize`` or `maximumFileSizeInBits`.
697        /// FSKit automatically converts from one to another if needed.
698        /// If you implement both, FSKit uses only the `maximumFileSizeInBits` implementation.
699        #[optional]
700        #[unsafe(method(maximumFileSizeInBits))]
701        #[unsafe(method_family = none)]
702        unsafe fn maximumFileSizeInBits(&self) -> NSInteger;
703    }
704);
705
706extern_class!(
707    /// A type used to report a volume's statistics.
708    ///
709    /// The names of this type's properties match those in the `statfs` structure in `statfs(2)`, which reports these values for an FSKit file system.
710    /// All numeric properties default to `0`.
711    /// Override these values, unless a given property has no meaningful value to provide.
712    ///
713    /// > Note: Available space, free space, total space, and used space have properties to express their values either as a number of blocks or a number of bytes.
714    /// Your module may supply both of these values by setting both the relevant block or byte property.
715    /// Alternatively, a module may set only one of the two properties.
716    /// When you do this, FSKit calculates the matching value based on ``blockSize``.
717    ///
718    /// For the read-only ``fileSystemTypeName``, set this value with the designated initializer.
719    ///
720    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsstatfsresult?language=objc)
721    #[unsafe(super(NSObject))]
722    #[derive(Debug, PartialEq, Eq, Hash)]
723    pub struct FSStatFSResult;
724);
725
726extern_conformance!(
727    unsafe impl NSCoding for FSStatFSResult {}
728);
729
730extern_conformance!(
731    unsafe impl NSObjectProtocol for FSStatFSResult {}
732);
733
734extern_conformance!(
735    unsafe impl NSSecureCoding for FSStatFSResult {}
736);
737
738impl FSStatFSResult {
739    extern_methods!(
740        /// A property for the volume's block size, in bytes.
741        ///
742        /// This value defaults to `4096`. Zero isn't a valid block size.
743        #[unsafe(method(blockSize))]
744        #[unsafe(method_family = none)]
745        pub unsafe fn blockSize(&self) -> NSInteger;
746
747        /// Setter for [`blockSize`][Self::blockSize].
748        #[unsafe(method(setBlockSize:))]
749        #[unsafe(method_family = none)]
750        pub unsafe fn setBlockSize(&self, block_size: NSInteger);
751
752        /// A property for the optimal block size with which to perform I/O.
753        ///
754        /// For best performance, specify an `ioSize` that's an even multiple of ``blockSize``.
755        #[unsafe(method(ioSize))]
756        #[unsafe(method_family = none)]
757        pub unsafe fn ioSize(&self) -> NSInteger;
758
759        /// Setter for [`ioSize`][Self::ioSize].
760        #[unsafe(method(setIoSize:))]
761        #[unsafe(method_family = none)]
762        pub unsafe fn setIoSize(&self, io_size: NSInteger);
763
764        /// A property for the volume's total data block count.
765        #[unsafe(method(totalBlocks))]
766        #[unsafe(method_family = none)]
767        pub unsafe fn totalBlocks(&self) -> u64;
768
769        /// Setter for [`totalBlocks`][Self::totalBlocks].
770        #[unsafe(method(setTotalBlocks:))]
771        #[unsafe(method_family = none)]
772        pub unsafe fn setTotalBlocks(&self, total_blocks: u64);
773
774        /// A property for the number of free blocks available to a non-superuser on the volume.
775        #[unsafe(method(availableBlocks))]
776        #[unsafe(method_family = none)]
777        pub unsafe fn availableBlocks(&self) -> u64;
778
779        /// Setter for [`availableBlocks`][Self::availableBlocks].
780        #[unsafe(method(setAvailableBlocks:))]
781        #[unsafe(method_family = none)]
782        pub unsafe fn setAvailableBlocks(&self, available_blocks: u64);
783
784        /// A property for the number of free blocks in the volume.
785        #[unsafe(method(freeBlocks))]
786        #[unsafe(method_family = none)]
787        pub unsafe fn freeBlocks(&self) -> u64;
788
789        /// Setter for [`freeBlocks`][Self::freeBlocks].
790        #[unsafe(method(setFreeBlocks:))]
791        #[unsafe(method_family = none)]
792        pub unsafe fn setFreeBlocks(&self, free_blocks: u64);
793
794        /// A property for the number of used blocks in the volume.
795        #[unsafe(method(usedBlocks))]
796        #[unsafe(method_family = none)]
797        pub unsafe fn usedBlocks(&self) -> u64;
798
799        /// Setter for [`usedBlocks`][Self::usedBlocks].
800        #[unsafe(method(setUsedBlocks:))]
801        #[unsafe(method_family = none)]
802        pub unsafe fn setUsedBlocks(&self, used_blocks: u64);
803
804        /// A property for the total size, in bytes, of the volume.
805        #[unsafe(method(totalBytes))]
806        #[unsafe(method_family = none)]
807        pub unsafe fn totalBytes(&self) -> u64;
808
809        /// Setter for [`totalBytes`][Self::totalBytes].
810        #[unsafe(method(setTotalBytes:))]
811        #[unsafe(method_family = none)]
812        pub unsafe fn setTotalBytes(&self, total_bytes: u64);
813
814        /// A property for the amount of space available to users, in bytes, in the volume.
815        #[unsafe(method(availableBytes))]
816        #[unsafe(method_family = none)]
817        pub unsafe fn availableBytes(&self) -> u64;
818
819        /// Setter for [`availableBytes`][Self::availableBytes].
820        #[unsafe(method(setAvailableBytes:))]
821        #[unsafe(method_family = none)]
822        pub unsafe fn setAvailableBytes(&self, available_bytes: u64);
823
824        /// A property for the amount of free space, in bytes, in the volume.
825        #[unsafe(method(freeBytes))]
826        #[unsafe(method_family = none)]
827        pub unsafe fn freeBytes(&self) -> u64;
828
829        /// Setter for [`freeBytes`][Self::freeBytes].
830        #[unsafe(method(setFreeBytes:))]
831        #[unsafe(method_family = none)]
832        pub unsafe fn setFreeBytes(&self, free_bytes: u64);
833
834        /// A property for the amount of used space, in bytes, in the volume.
835        #[unsafe(method(usedBytes))]
836        #[unsafe(method_family = none)]
837        pub unsafe fn usedBytes(&self) -> u64;
838
839        /// Setter for [`usedBytes`][Self::usedBytes].
840        #[unsafe(method(setUsedBytes:))]
841        #[unsafe(method_family = none)]
842        pub unsafe fn setUsedBytes(&self, used_bytes: u64);
843
844        /// A property for the total number of file slots in the volume,
845        #[unsafe(method(totalFiles))]
846        #[unsafe(method_family = none)]
847        pub unsafe fn totalFiles(&self) -> u64;
848
849        /// Setter for [`totalFiles`][Self::totalFiles].
850        #[unsafe(method(setTotalFiles:))]
851        #[unsafe(method_family = none)]
852        pub unsafe fn setTotalFiles(&self, total_files: u64);
853
854        /// A property for the total number of free file slots in the volume.
855        #[unsafe(method(freeFiles))]
856        #[unsafe(method_family = none)]
857        pub unsafe fn freeFiles(&self) -> u64;
858
859        /// Setter for [`freeFiles`][Self::freeFiles].
860        #[unsafe(method(setFreeFiles:))]
861        #[unsafe(method_family = none)]
862        pub unsafe fn setFreeFiles(&self, free_files: u64);
863
864        /// A property for the file system's subtype or flavor.
865        ///
866        /// Match this value to the `FSPersonalities`'s `FSSubType` attribute, if it exists within the `EXAppExtensionAttributes` dictionary of the module's `Info.plist`.
867        #[unsafe(method(fileSystemSubType))]
868        #[unsafe(method_family = none)]
869        pub unsafe fn fileSystemSubType(&self) -> NSInteger;
870
871        /// Setter for [`fileSystemSubType`][Self::fileSystemSubType].
872        #[unsafe(method(setFileSystemSubType:))]
873        #[unsafe(method_family = none)]
874        pub unsafe fn setFileSystemSubType(&self, file_system_sub_type: NSInteger);
875
876        /// A property for the file system type name.
877        ///
878        /// Match this value to the `FSShortName` attribute within the `EXAppExtensionAttributes` dictionary of the module's `Info.plist`.
879        /// The maximum allowed length is `MFSTYPENAMELEN`, including the terminating `NUL` character.
880        #[unsafe(method(fileSystemTypeName))]
881        #[unsafe(method_family = none)]
882        pub unsafe fn fileSystemTypeName(&self) -> Retained<NSString>;
883
884        /// Creates an statistics result instance, using the given file system type name.
885        ///
886        /// - Parameters fileSystemTypeName: A type name for the file system. The maximum allowed length is `MFSTYPENAMELEN`, including the terminating `NUL` character.
887        #[unsafe(method(initWithFileSystemTypeName:))]
888        #[unsafe(method_family = init)]
889        pub unsafe fn initWithFileSystemTypeName(
890            this: Allocated<Self>,
891            file_system_type_name: &NSString,
892        ) -> Retained<Self>;
893
894        #[unsafe(method(init))]
895        #[unsafe(method_family = init)]
896        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
897    );
898}
899
900/// Methods declared on superclass `NSObject`.
901impl FSStatFSResult {
902    extern_methods!(
903        #[unsafe(method(new))]
904        #[unsafe(method_family = new)]
905        pub unsafe fn new() -> Retained<Self>;
906    );
907}
908
909extern_protocol!(
910    /// Methods that all volumes implement to provide required capabilities.
911    ///
912    /// Conform to this protocol in your subclass of ``FSVolume``.
913    /// To provide additional capabilities, conform to the other `FSVolume` operations protocols, like ``FSVolumeOpenCloseOperations`` and ``FSVolumeReadWriteOperations``.
914    ///
915    /// > Note: This protocol extends ``FSVolumePathConfOperations``, so your volume implementation must also conform to that protocol.
916    ///
917    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumeoperations?language=objc)
918    pub unsafe trait FSVolumeOperations:
919        NSObjectProtocol + FSVolumePathConfOperations
920    {
921        /// A property that provides the supported capabilities of the volume.
922        #[unsafe(method(supportedVolumeCapabilities))]
923        #[unsafe(method_family = none)]
924        unsafe fn supportedVolumeCapabilities(&self) -> Retained<FSVolumeSupportedCapabilities>;
925
926        /// A property that provides up-to-date statistics of the volume.
927        #[unsafe(method(volumeStatistics))]
928        #[unsafe(method_family = none)]
929        unsafe fn volumeStatistics(&self) -> Retained<FSStatFSResult>;
930
931        /// A property that allows the file system to use open-unlink emulation.
932        ///
933        /// _Open-unlink_ functionality refers to a file system's ability to support an open file being fully unlinked from the file system namespace.
934        /// If a file system doesn't support this functionality, FSKit can emulate it instead; this is called "open-unlink emulation".
935        ///
936        /// Implement this property to return `true` (Swift) or `YES` (Objective-C) to allow FSKit to perform open-unlink emulation.
937        /// If you don't implement this property at all, FSKit doesn't perform open-unlink emulation for this volume.
938        ///
939        /// FSKit reads this value after the file system replies to the `loadResource` message.
940        /// Changing the returned value during the runtime of the volume has no effect.
941        #[optional]
942        #[unsafe(method(enableOpenUnlinkEmulation))]
943        #[unsafe(method_family = none)]
944        unsafe fn enableOpenUnlinkEmulation(&self) -> bool;
945
946        /// Setter for [`enableOpenUnlinkEmulation`][Self::enableOpenUnlinkEmulation].
947        #[optional]
948        #[unsafe(method(setEnableOpenUnlinkEmulation:))]
949        #[unsafe(method_family = none)]
950        unsafe fn setEnableOpenUnlinkEmulation(&self, enable_open_unlink_emulation: bool);
951
952        #[cfg(all(feature = "FSTaskOptions", feature = "block2"))]
953        /// Mounts this volume, using the specified options.
954        ///
955        /// FSKit calls this method as a signal that some process is trying to mount this volume.
956        /// Your file system receives a call to ``activate(options:replyHandler:)`` prior to receiving any mount calls.
957        ///
958        /// - Parameters:
959        /// - options: Options to apply to the mount. These can include security-scoped file paths. There are no defined options currently.
960        /// - reply: A block or closure to indicate success or failure. If mounting fails, pass an error as the one parameter to the reply handler. If mounting succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply return normally.
961        #[unsafe(method(mountWithOptions:replyHandler:))]
962        #[unsafe(method_family = none)]
963        unsafe fn mountWithOptions_replyHandler(
964            &self,
965            options: &FSTaskOptions,
966            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
967        );
968
969        #[cfg(feature = "block2")]
970        /// Unmounts this volume.
971        ///
972        /// Clear and flush all cached state in your implementation of this method.
973        ///
974        /// - Parameters:
975        /// - reply: A block or closure to indicate success or failure. If unmounting fails, pass an error as the one parameter to the reply handler. If unmounting succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply return normally.
976        #[unsafe(method(unmountWithReplyHandler:))]
977        #[unsafe(method_family = none)]
978        unsafe fn unmountWithReplyHandler(&self, reply: &block2::DynBlock<dyn Fn()>);
979
980        #[cfg(feature = "block2")]
981        /// Synchronizes the volume with its underlying resource.
982        ///
983        /// After calling this method, FSKit assumes that the volume has sent all pending I/O or metadata to its resource.
984        ///
985        /// - Parameters:
986        /// - flags: Timing flags, as defined in `mount.h.` These flags let the file system know whether to run the operation in a blocking or nonblocking fashion.
987        /// - reply: A block or closure to indicate success or failure. If synchronization fails, pass an error as the one parameter to the reply handler. If synchronization succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
988        #[unsafe(method(synchronizeWithFlags:replyHandler:))]
989        #[unsafe(method_family = none)]
990        unsafe fn synchronizeWithFlags_replyHandler(
991            &self,
992            flags: FSSyncFlags,
993            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
994        );
995
996        #[cfg(all(feature = "FSItem", feature = "block2"))]
997        /// Fetches attributes for the given item.
998        ///
999        /// For file systems that don't support hard links, set ``FSItemAttributes/linkCount`` to `1` for regular files and symbolic links.
1000        ///
1001        /// If the item's `bsdFlags` contain the `UF_COMPRESSED` flag, your file system returns the uncompressed size of the file.
1002        ///
1003        /// - Parameters:
1004        /// - desiredAttributes: A requested set of attributes to get. The implementation inspects the request's ``FSItemGetAttributesRequest/wantedAttributes`` to determine which attributes to populate.
1005        /// - item: The item to get attributes for.
1006        /// - reply: A block or closure to indicate success or failure. If getting attributes succeeds, pass an ``FSItemAttributes`` with the requested attributes populated and a `nil` error. If getting attributes fails, pass the relevant error as the second parameter; FSKit ignores any ``FSItemAttributes`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSItemAttributes`` or throw an error.
1007        #[unsafe(method(getAttributes:ofItem:replyHandler:))]
1008        #[unsafe(method_family = none)]
1009        unsafe fn getAttributes_ofItem_replyHandler(
1010            &self,
1011            desired_attributes: &FSItemGetAttributesRequest,
1012            item: &FSItem,
1013            reply: &block2::DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>,
1014        );
1015
1016        #[cfg(all(feature = "FSItem", feature = "block2"))]
1017        /// Sets the given attributes on an item.
1018        ///
1019        /// Several attributes are considered "read-only", and an attempt to set these attributes results in an error with the code `EINVAL`.
1020        ///
1021        /// A request may set ``FSItem/Attributes/size`` beyond the end of the file.
1022        /// If the underlying file system doesn't support sparse files, allocate space to fill the new file size.
1023        /// Either fill this space with zeroes, or configure it to read as zeroes.
1024        ///
1025        /// If a request sets the file size below the current end-of-file, truncate the file and return any unused space to the file system as free space.
1026        ///
1027        /// Ignore attempts to set the size of directories or symbolic links; don't produce an error.
1028        ///
1029        /// If the caller attepts to sest an attribute not supported by the on-disk file system format, don't produce an error.
1030        /// The upper layers of the framework will detect this situation.
1031        ///
1032        /// - Parameters:
1033        /// - newAttributes: A request containing the attributes to set.
1034        /// - item: The item on which to set the attributes.
1035        /// - reply: A block or closure to indicate success or failure. If setting attributes succeeds, pass an ``FSItemAttributes`` with the item's updated attributes and a `nil` error. If setting attributes fails, pass the relevant error as the second parameter; FSKit ignores any ``FSItemAttributes`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSItemAttributes`` or throw an error.
1036        #[unsafe(method(setAttributes:onItem:replyHandler:))]
1037        #[unsafe(method_family = none)]
1038        unsafe fn setAttributes_onItem_replyHandler(
1039            &self,
1040            new_attributes: &FSItemSetAttributesRequest,
1041            item: &FSItem,
1042            reply: &block2::DynBlock<dyn Fn(*mut FSItemAttributes, *mut NSError)>,
1043        );
1044
1045        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1046        /// Looks up an item within a directory.
1047        ///
1048        /// If no item matching `name` exists in the directory indicated by `directory`, complete the request with an error with a domain of
1049        /// <doc
1050        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of `ENOENT`.
1051        ///
1052        /// > Tip: The ``FSFileName`` sent back to the caller may differ from the `name` parameter. This flexibility allows your implementation to handle case-insensitive and case-sensitive file systems. It might also be the case that `name` uses a composed Unicode string, but the name maintained by the file system and provided to the caller is uncomposed Unicode.
1053        ///
1054        /// - Parameters:
1055        /// - name: The name of the item to look up.
1056        /// - directory: The directory in which to look up the item.
1057        /// - reply: A block or closure to indicate success or failure. If lookup succeeds, pass the found ``FSItem`` and its ``FSFileName`` (as saved within the file system), along with a `nil` error. If lookup fails, pass the relevant error as the third parameter; any ``FSItem`` or ``FSFileName`` are ignored in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSItem`` and ``FSFileName`` as a tuple or throw an error.
1058        #[unsafe(method(lookupItemNamed:inDirectory:replyHandler:))]
1059        #[unsafe(method_family = none)]
1060        unsafe fn lookupItemNamed_inDirectory_replyHandler(
1061            &self,
1062            name: &FSFileName,
1063            directory: &FSItem,
1064            reply: &block2::DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
1065        );
1066
1067        #[cfg(all(feature = "FSItem", feature = "block2"))]
1068        /// Reclaims an item, releasing any resources allocated for the item.
1069        ///
1070        /// FSKit guarantees that for every ``FSItem`` returned by the volume, a corresponding reclaim operation occurs after the upper layers no longer reference that item.
1071        ///
1072        /// > Note: Block device file systems may assess whether an underyling resource terminates before processing reclaim operations. On unary file systems, for example, the associated volumes unmount when such resources disconnect from the system. The unmount triggers a reclaiming of all items. Some implementations benefit greatly from short-circuiting in such cases. With a terminated resource, all I/O results in an error, making short-circuiting the most efficient response.
1073        ///
1074        /// - Parameters:
1075        /// - item: The item to reclaim.
1076        /// - reply: A block or closure to indicate success or failure. If removal fails, pass an error as the one parameter to the reply handler. If removal succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1077        #[unsafe(method(reclaimItem:replyHandler:))]
1078        #[unsafe(method_family = none)]
1079        unsafe fn reclaimItem_replyHandler(
1080            &self,
1081            item: &FSItem,
1082            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1083        );
1084
1085        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1086        /// Reads a symbolic link.
1087        ///
1088        /// - Parameters:
1089        /// - item: The symbolic link to read from. FSKit guarantees this item is of type ``FSItem/ItemType/symlink``.
1090        /// - reply: A block or closure to indicate success or failure. If reading succeeds, pass the link's contents as an ``FSFileName`` and a `nil` error. If reading fails, pass the relevant error as the second parameter; FSKit ignores any ``FSFileName`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSFileName`` or throw an error.
1091        #[unsafe(method(readSymbolicLink:replyHandler:))]
1092        #[unsafe(method_family = none)]
1093        unsafe fn readSymbolicLink_replyHandler(
1094            &self,
1095            item: &FSItem,
1096            reply: &block2::DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
1097        );
1098
1099        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1100        /// Creates a new file or directory item.
1101        ///
1102        /// If an item named `name` already exists in the directory indicated by `directory`, complete the request with an error with a domain of
1103        /// <doc
1104        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of `EEXIST`.
1105        ///
1106        /// - Parameters:
1107        /// - name: The new item's name.
1108        /// - type: The new item's type.  Valid values are ``FSItem/ItemType/file`` or ``FSItem/ItemType/directory``.
1109        /// - directory: The directory in which to create the item.
1110        /// - newAttributes: Attributes to apply to the new item.
1111        /// - reply: A block or closure to indicate success or failure. If creation succeeds, pass the newly-created ``FSItem`` and its ``FSFileName``, along with a `nil` error. If creation fails, pass the relevant error as the third parameter; FSKit ignores any ``FSItem`` or ``FSFileName`` in this case. For an `async` Swift implementation, there's no reply handler; simply return a tuple of the ``FSItem`` and its ``FSFileName`` or throw an error.
1112        #[unsafe(method(createItemNamed:type:inDirectory:attributes:replyHandler:))]
1113        #[unsafe(method_family = none)]
1114        unsafe fn createItemNamed_type_inDirectory_attributes_replyHandler(
1115            &self,
1116            name: &FSFileName,
1117            r#type: FSItemType,
1118            directory: &FSItem,
1119            new_attributes: &FSItemSetAttributesRequest,
1120            reply: &block2::DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
1121        );
1122
1123        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1124        /// Creates a new symbolic link.
1125        ///
1126        /// If an item named `name` already exists in the directory indicated by `directory`, complete the request with an error with a domain of
1127        /// <doc
1128        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of `EEXIST`.
1129        ///
1130        /// - Parameters:
1131        /// - name: The new item's name.
1132        /// - directory: The directory in which to create the item.
1133        /// - newAttributes: Attributes to apply to the new item.
1134        /// - contents: The contents of the new symbolic link.
1135        /// - reply: A block or closure to indicate success or failure. If creation succeeds, pass the newly-created ``FSItem`` and a `nil` error. If creation fails, pass the relevant error as the second parameter; FSKit ignores any ``FSItem`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSItem`` or throw an error.
1136        #[unsafe(method(createSymbolicLinkNamed:inDirectory:attributes:linkContents:replyHandler:))]
1137        #[unsafe(method_family = none)]
1138        unsafe fn createSymbolicLinkNamed_inDirectory_attributes_linkContents_replyHandler(
1139            &self,
1140            name: &FSFileName,
1141            directory: &FSItem,
1142            new_attributes: &FSItemSetAttributesRequest,
1143            contents: &FSFileName,
1144            reply: &block2::DynBlock<dyn Fn(*mut FSItem, *mut FSFileName, *mut NSError)>,
1145        );
1146
1147        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1148        /// Creates a new hard link.
1149        ///
1150        /// If creating the link fails, complete the request with an error with a domain of
1151        /// <doc
1152        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and the following error codes:
1153        ///
1154        /// * `EEXIST` if there's already an item named `name` in the directory.
1155        /// * `EMLINK` if creating the link would exceed the maximum number of hard links supported on `item`.
1156        /// * `ENOTSUP` if the file system doesn't support creating hard links to the type of file system object that `item` represents.
1157        ///
1158        /// - Parameters:
1159        /// - item: The existing item to which to link.
1160        /// - name: The name for the new link.
1161        /// - directory: The directory in which to create the link.
1162        /// - reply: A block or closure to indicate success or failure. If creation succeeds, pass an ``FSFileName`` of the newly-created link and a `nil` error. If creation fails, pass the relevant error as the second parameter; FSKit ignores any ``FSFileName`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSFileName`` or throw an error.
1163        #[unsafe(method(createLinkToItem:named:inDirectory:replyHandler:))]
1164        #[unsafe(method_family = none)]
1165        unsafe fn createLinkToItem_named_inDirectory_replyHandler(
1166            &self,
1167            item: &FSItem,
1168            name: &FSFileName,
1169            directory: &FSItem,
1170            reply: &block2::DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
1171        );
1172
1173        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1174        /// Removes an existing item from a given directory.
1175        ///
1176        /// Don't actually remove the item object itself in your implementation; instead, only remove the given item name from the given directory.
1177        /// Remove and deallocate the item in ``reclaimItem(_:replyHandler:)``.
1178        ///
1179        /// - Parameters:
1180        /// - item: The item to remove.
1181        /// - name: The name of the item to remove.
1182        /// - directory: The directory from which to remove the item.
1183        /// - reply: A block or closure to indicate success or failure. If removal fails, pass an error as the one parameter to the reply handler. If removal succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1184        #[unsafe(method(removeItem:named:fromDirectory:replyHandler:))]
1185        #[unsafe(method_family = none)]
1186        unsafe fn removeItem_named_fromDirectory_replyHandler(
1187            &self,
1188            item: &FSItem,
1189            name: &FSFileName,
1190            directory: &FSItem,
1191            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1192        );
1193
1194        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1195        /// Renames an item from one path in the file system to another.
1196        ///
1197        /// Implement renaming along the lines of this algorithm:
1198        ///
1199        /// - If `item` is a file:
1200        /// - If the destination file exists:
1201        /// - Remove the destination file.
1202        /// - If the source and destination directories are the same:
1203        /// - Rewrite the name in the existing directory.
1204        /// - Else:
1205        /// - Write the new entry in the destination directory.
1206        /// - Clear the old directory entry.
1207        /// - If `item` is a directory:
1208        /// - If the destination directory exists:
1209        /// - If the destination directory isn't empty:
1210        /// - Fail the operation with an error of
1211        /// <doc
1212        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of `ENOTEMPTY`.
1213        /// - Else:
1214        /// - Remove the destination directory.
1215        /// - If the source and destination directories are the same:
1216        /// - Rewrite the name in the existing directory.
1217        /// - Else:
1218        /// - If the destination is a child of the source directory:
1219        /// - Fail the operation with an error.
1220        /// - Else:
1221        /// - Write the new entry in the destination directory.
1222        /// - Update `"."` and `".."` in the moved directory.
1223        /// - Clear the old directory entry.
1224        ///
1225        /// - Parameters:
1226        /// - item: The file system object being renamed.
1227        /// - sourceDirectory: The directory that currently contains the item to rename.
1228        /// - sourceName: The name of the item within the source directory.
1229        /// - destinationName: The new name of the item as it appears in `destinationDirectory`.
1230        /// - destinationDirectory: The directory to contain the renamed object, which may be the same as `sourceDirectory`.
1231        /// - overItem: The file system object if the destination exists, as discovered in a prior lookup. If this parameter is non-`nil`, mark `overItem` as deleted, so the file system can free its allocated space on the next call to ``reclaimItem(_:replyHandler:)``. After doing so, ensure the operation finishes without errors.
1232        /// - reply: A block or closure to indicate success or failure. If renaming succeeds, pass the ``FSFileName`` as it exists within `destinationDirectory` and a `nil` error. If renaming fails, pass the relevant error as the second parameter; FSKit ignores any ``FSFileName`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSFileName`` or throw an error.
1233        #[unsafe(method(renameItem:inDirectory:named:toNewName:inDirectory:overItem:replyHandler:))]
1234        #[unsafe(method_family = none)]
1235        unsafe fn renameItem_inDirectory_named_toNewName_inDirectory_overItem_replyHandler(
1236            &self,
1237            item: &FSItem,
1238            source_directory: &FSItem,
1239            source_name: &FSFileName,
1240            destination_name: &FSFileName,
1241            destination_directory: &FSItem,
1242            over_item: Option<&FSItem>,
1243            reply: &block2::DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
1244        );
1245
1246        #[cfg(all(feature = "FSItem", feature = "block2"))]
1247        /// Enumerates the contents of the given directory.
1248        ///
1249        /// This method uses the ``FSDirectoryEntryPacker/packEntry(name:itemType:itemID:nextCookie:attributes:)`` method of the `packer` parameter to deliver the enumerated items to the caller.
1250        /// The general flow of an enumeration implementation follows these steps:
1251        ///
1252        /// 1. Enumeration starts with a call to `enumerateDirectory` using the initial next-cookie and verifier values ``FSDirectoryCookieInitial`` and ``FSDirectoryVerifierInitial``, respectively.
1253        /// 2. The implementation uses `packer` to pack the initial set of directory entries. Packing also sets a `nextCookie` to use on the next call.
1254        /// 3. The implementation replies with a new verifier value, a nonzero value that reflects the directory's current version.
1255        /// 4. On the next call the implementation packs the next set of entries, starting with the item indicated by `cookie`. If `cookie` doesn't resolve to a valid directory entry, complete the request with an error of domain
1256        /// <doc
1257        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and code ``FSError/Code/invalidDirectoryCookie``.
1258        ///
1259        /// When packing, make sure to use acceptable directory entry names and unambiguous input to all file operations that take names without additional normalization, such as`lookupName`.
1260        ///
1261        /// > Tip: If the `attributes` parameter is `nil`, include at least two entries in a directory: `"."` and `".."`, which represent the current and parent directories, respectively. Both of these items have type ``FSItem/ItemType/directory``. For the root directory, `"."` and `".."` have identical contents. Don't pack  `"."` and `".."` if `attributes` isn't `nil`.
1262        ///
1263        /// - Parameters:
1264        /// - directory: The item to enumerate. FSKit guarantees this item is of type ``FSItem/ItemType/directory``.
1265        /// - cookie: A value that indicates the location within the directory from which to enumerate. Your implementation defines the semantics of the cookie values; they're opaque to FSKit. The first call to the enumerate method passes ``FSDirectoryCookieInitial`` for this parameter. Subsequent calls pass whatever cookie value you previously passed to the packer's `nextCookie` parmeter.
1266        /// - verifier: A tool to detect whether the directory contents changed since the last call to `enumerateDirectory`. Your implementation defines the semantics of the verifier values; they're opaque to FSKit. The first call to the enumerate method passes ``FSDirectoryVerifierInitial`` for this parameter. Subsequent calls pass whatever cookie value you previously passed to the packer's `currentVerifier` parmeter.
1267        /// - attributes: The desired attributes to provide, or `nil` if the caller doesn't require attributes.
1268        /// - packer: An object that your implementation uses to enumerate directory items, packing one item per callback to `enumerateDirectory`.
1269        /// - reply: A block or closure to indicate success or failure. If enumeration succeeds, pass the current verifier and a `nil` error. If enumeration fails, pass the relevant error as the second parameter; FSKit ignores any verifier in this case. For an `async` Swift implementation, there's no reply handler; simply return the current verifier or throw an error.
1270        #[unsafe(method(enumerateDirectory:startingAtCookie:verifier:providingAttributes:usingPacker:replyHandler:))]
1271        #[unsafe(method_family = none)]
1272        unsafe fn enumerateDirectory_startingAtCookie_verifier_providingAttributes_usingPacker_replyHandler(
1273            &self,
1274            directory: &FSItem,
1275            cookie: FSDirectoryCookie,
1276            verifier: FSDirectoryVerifier,
1277            attributes: Option<&FSItemGetAttributesRequest>,
1278            packer: &FSDirectoryEntryPacker,
1279            reply: &block2::DynBlock<dyn Fn(FSDirectoryVerifier, *mut NSError)>,
1280        );
1281
1282        #[cfg(all(feature = "FSItem", feature = "FSTaskOptions", feature = "block2"))]
1283        /// Activates the volume using the specified options.
1284        ///
1285        /// When FSKit calls this method, allocate any in-memory state required to represent the file system.
1286        /// Also allocate an ``FSItem`` for the root directory of the file system, and pass it to the reply block.
1287        /// FSKit caches this root item for the lifetime of the volume, and uses it as a starting point for all file look-ups.
1288        ///
1289        /// Volume activation occurs prior to any call to mount the volume.
1290        ///
1291        /// - Parameters:
1292        /// - options: Options to apply to the activation. These can include security-scoped file paths. There are no defined options currently.
1293        /// - reply: A block or closure to indicate success or failure. If activation succeeds, pass the root ``FSItem`` and a `nil` error. If activation fails, pass the relevant error as the second parameter; FSKit ignores any ``FSItem`` in this case. In Swift, `reply` takes only the ``FSItem`` as the parameter; you signal any error with a `throw`. For an `async` Swift implementation, there's no reply handler; simply return the ``FSItem`` or throw an error.
1294        #[unsafe(method(activateWithOptions:replyHandler:))]
1295        #[unsafe(method_family = none)]
1296        unsafe fn activateWithOptions_replyHandler(
1297            &self,
1298            options: &FSTaskOptions,
1299            reply: &block2::DynBlock<dyn Fn(*mut FSItem, *mut NSError)>,
1300        );
1301
1302        #[cfg(feature = "block2")]
1303        /// Tears down a previously initialized volume instance.
1304        ///
1305        /// Set up your implementation to release any resources allocated for the volume instance.
1306        /// By the time you receive this callback, FSKit has already performed a reclaim call to release all other file nodes associated with this file system instance.
1307        ///
1308        /// Avoid performing any I/O in this method.
1309        /// Prior to calling this method, FSKit has already issued a sync call to perform any
1310        /// cleanup-related I/O.
1311        ///
1312        /// FSKit unmounts any mounted volume with a call to ``unmount(replyHandler:)`` prior to the deactivate callback.
1313        ///
1314        /// - Parameters:
1315        /// - options: Options to apply to the deactivation.
1316        /// - reply: A block or closure to indicate success or failure. If activation fails, pass an error as the one parameter to the reply handler. If activation succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1317        #[unsafe(method(deactivateWithOptions:replyHandler:))]
1318        #[unsafe(method_family = none)]
1319        unsafe fn deactivateWithOptions_replyHandler(
1320            &self,
1321            options: FSDeactivateOptions,
1322            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1323        );
1324    }
1325);
1326
1327/// Flags to specify the policy when setting extended file attributes.
1328///
1329/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fssetxattrpolicy?language=objc)
1330// NS_ENUM
1331#[repr(transparent)]
1332#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1333pub struct FSSetXattrPolicy(pub NSUInteger);
1334impl FSSetXattrPolicy {
1335    /// Set the value, regardless of previous state.
1336    #[doc(alias = "FSSetXattrPolicyAlwaysSet")]
1337    pub const AlwaysSet: Self = Self(0);
1338    /// Set the value, but fail if the extended attribute already exists.
1339    #[doc(alias = "FSSetXattrPolicyMustCreate")]
1340    pub const MustCreate: Self = Self(1);
1341    /// Set the value, but fail if the extended attribute doesn't already exist.
1342    #[doc(alias = "FSSetXattrPolicyMustReplace")]
1343    pub const MustReplace: Self = Self(2);
1344    /// Delete the value, failing if the extended attribute doesn't exist.
1345    #[doc(alias = "FSSetXattrPolicyDelete")]
1346    pub const Delete: Self = Self(3);
1347}
1348
1349unsafe impl Encode for FSSetXattrPolicy {
1350    const ENCODING: Encoding = NSUInteger::ENCODING;
1351}
1352
1353unsafe impl RefEncode for FSSetXattrPolicy {
1354    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1355}
1356
1357extern_protocol!(
1358    /// Methods and properties implemented by volumes that natively or partially support extended attributes.
1359    ///
1360    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumexattroperations?language=objc)
1361    pub unsafe trait FSVolumeXattrOperations: NSObjectProtocol {
1362        /// A Boolean value that instructs FSKit not to call this protocol's methods, even if the volume conforms to it.
1363        ///
1364        /// FSKit reads this value after the file system replies to the `loadResource` message.
1365        /// Changing the returned value during the runtime of the volume has no effect.
1366        #[optional]
1367        #[unsafe(method(xattrOperationsInhibited))]
1368        #[unsafe(method_family = none)]
1369        unsafe fn xattrOperationsInhibited(&self) -> bool;
1370
1371        /// Setter for [`xattrOperationsInhibited`][Self::xattrOperationsInhibited].
1372        #[optional]
1373        #[unsafe(method(setXattrOperationsInhibited:))]
1374        #[unsafe(method_family = none)]
1375        unsafe fn setXattrOperationsInhibited(&self, xattr_operations_inhibited: bool);
1376
1377        #[cfg(all(feature = "FSFileName", feature = "FSItem"))]
1378        /// Returns an array that specifies the extended attribute names the given item supports.
1379        ///
1380        /// If `item` supports no extended attributes, this method returns `nil`.
1381        ///
1382        /// Only implement this method if your volume works with "limited" extended attributes.
1383        /// For purposes of this protocol, "limited" support means the volume doesn't support extended attributes generally, but uses these APIs to expose specific file system data.
1384        ///
1385        /// > Note: If a file system implements this method, FSKit assumes limited support for extended attributes exists. In this mode, FSkit only calls this protocol's methods for the extended attribute names this method returns.
1386        ///
1387        /// - Parameter item: The item for which to get information.
1388        #[optional]
1389        #[unsafe(method(supportedXattrNamesForItem:))]
1390        #[unsafe(method_family = none)]
1391        unsafe fn supportedXattrNamesForItem(&self, item: &FSItem)
1392            -> Retained<NSArray<FSFileName>>;
1393
1394        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1395        /// Gets the specified extended attribute of the given item.
1396        ///
1397        /// - Parameters:
1398        /// - name: The extended attribute name.
1399        /// - item: The item for which to get the extended attribute.
1400        /// - reply: A block or closure to indicate success or failure. If getting the attribute succeeds, pass an data instance containing the extended attribute data and a `nil` error. If getting the attribute fails, pass the relevant error as the second parameter; FSKit ignores any data in this case. For an `async` Swift implementation, there's no reply handler; simply return the data or throw an error.
1401        #[unsafe(method(getXattrNamed:ofItem:replyHandler:))]
1402        #[unsafe(method_family = none)]
1403        unsafe fn getXattrNamed_ofItem_replyHandler(
1404            &self,
1405            name: &FSFileName,
1406            item: &FSItem,
1407            reply: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
1408        );
1409
1410        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1411        /// Sets the specified extended attribute data on the given item.
1412        ///
1413        /// - Parameters:
1414        /// - name: The extended attribute name.
1415        /// - value: The extended attribute value to set. This can't be `nil`, unless the policy is ``FSVolume/SetXattrPolicy/delete``.
1416        /// - item: The item on which to set the extended attribute.
1417        /// - policy: The policy to apply when setting the attribute. See ``FSSetXattrPolicy`` for possible values.
1418        /// - reply: A block or closure to indicate success or failure. If setting the attribute fails, pass an error as the one parameter to the reply handler. If setting the attribute succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1419        #[unsafe(method(setXattrNamed:toData:onItem:policy:replyHandler:))]
1420        #[unsafe(method_family = none)]
1421        unsafe fn setXattrNamed_toData_onItem_policy_replyHandler(
1422            &self,
1423            name: &FSFileName,
1424            value: Option<&NSData>,
1425            item: &FSItem,
1426            policy: FSSetXattrPolicy,
1427            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1428        );
1429
1430        #[cfg(all(feature = "FSFileName", feature = "FSItem", feature = "block2"))]
1431        /// Gets the list of extended attributes currently set on the given item.
1432        ///
1433        /// - Parameters:
1434        /// - item: The item from which to get extended attributes.
1435        /// - reply: A block or closure to indicate success or failure. If getting the list of extended attributes succeeds, pass the xattrs as an array of ``FSFileName`` instances and a `nil` error. If getting the attriubtes fails, pass `nil` along with the relevant error. For an `async` Swift implementation, there's no reply handler; simply return the byte count or throw an error.
1436        #[unsafe(method(listXattrsOfItem:replyHandler:))]
1437        #[unsafe(method_family = none)]
1438        unsafe fn listXattrsOfItem_replyHandler(
1439            &self,
1440            item: &FSItem,
1441            reply: &block2::DynBlock<dyn Fn(*mut NSArray<FSFileName>, *mut NSError)>,
1442        );
1443    }
1444);
1445
1446/// Defined modes for opening a file.
1447///
1448/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumeopenmodes?language=objc)
1449// NS_OPTIONS
1450#[repr(transparent)]
1451#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1452pub struct FSVolumeOpenModes(pub NSUInteger);
1453bitflags::bitflags! {
1454    impl FSVolumeOpenModes: NSUInteger {
1455/// The read mode.
1456///
1457/// This mode is equivalent to POSIX `FREAD`.
1458        #[doc(alias = "FSVolumeOpenModesRead")]
1459        const Read = 1;
1460/// The write mode.
1461///
1462/// This mode is equivalent to POSIX `FRWITE`.
1463        #[doc(alias = "FSVolumeOpenModesWrite")]
1464        const Write = 2;
1465    }
1466}
1467
1468unsafe impl Encode for FSVolumeOpenModes {
1469    const ENCODING: Encoding = NSUInteger::ENCODING;
1470}
1471
1472unsafe impl RefEncode for FSVolumeOpenModes {
1473    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1474}
1475
1476extern_protocol!(
1477    /// Methods and properties implemented by volumes that want to receive open and close calls for each item.
1478    ///
1479    /// When a file system volume conforms to this protocol, the kernel layer issues an open call to indicate desired access, and a close call to indicate what access to retain.
1480    /// A file is fully closed when the kernel layer issues a close call with no retained open nodes.
1481    /// When a file system receives the close call, it removes all access to the item.
1482    /// When all memory mappings to the item release, the kernel layer issues a final close.
1483    ///
1484    /// If a file system volume doesn't conform to this protocol, the kernel layer can skip making such calls to the volume.
1485    ///
1486    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumeopencloseoperations?language=objc)
1487    pub unsafe trait FSVolumeOpenCloseOperations: NSObjectProtocol {
1488        /// A Boolean value that instructs FSKit not to call this protocol's methods, even if the volume conforms to it.
1489        ///
1490        /// FSKit reads this value after the file system replies to the `loadResource` message.
1491        /// Changing the returned value during the runtime of the volume has no effect.
1492        #[optional]
1493        #[unsafe(method(isOpenCloseInhibited))]
1494        #[unsafe(method_family = none)]
1495        unsafe fn isOpenCloseInhibited(&self) -> bool;
1496
1497        /// Setter for [`isOpenCloseInhibited`][Self::isOpenCloseInhibited].
1498        #[optional]
1499        #[unsafe(method(setOpenCloseInhibited:))]
1500        #[unsafe(method_family = none)]
1501        unsafe fn setOpenCloseInhibited(&self, open_close_inhibited: bool);
1502
1503        #[cfg(all(feature = "FSItem", feature = "block2"))]
1504        /// Opens a file for access.
1505        ///
1506        /// - Parameters:
1507        /// - item: The item to open.
1508        /// - modes: The set of mode flags to open the item with.
1509        /// - reply: A block or closure to indicate success or failure. If opening fails, pass an error as the one parameter to the reply handler. If opening succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1510        #[unsafe(method(openItem:withModes:replyHandler:))]
1511        #[unsafe(method_family = none)]
1512        unsafe fn openItem_withModes_replyHandler(
1513            &self,
1514            item: &FSItem,
1515            modes: FSVolumeOpenModes,
1516            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1517        );
1518
1519        #[cfg(all(feature = "FSItem", feature = "block2"))]
1520        /// Closes a file from further access.
1521        ///
1522        /// - Parameters:
1523        /// - item: The item to close.
1524        /// - modes: The set of mode flags to keep after this close.
1525        /// - reply: A block or closure to indicate success or failure. If closing fails, pass an error as the one parameter to the reply handler. If closing succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1526        #[unsafe(method(closeItem:keepingModes:replyHandler:))]
1527        #[unsafe(method_family = none)]
1528        unsafe fn closeItem_keepingModes_replyHandler(
1529            &self,
1530            item: &FSItem,
1531            modes: FSVolumeOpenModes,
1532            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1533        );
1534    }
1535);
1536
1537extern_protocol!(
1538    /// Methods implemented for read and write operations that deliver data to and from the extension.
1539    ///
1540    /// Most volumes conform to either this protocol or ``FSVolumeKernelOffloadedIOOperations``.
1541    /// You can conform to both if you need to provide kernel-offloaded I/O only for certain files.
1542    /// In that case, files with the ``FSItem/Attribute/inhibitKernelOffloadedIO`` attribute set use this protocol, and those without it use ``FSVolumeKernelOffloadedIOOperations``.
1543    /// A volume that doesn't conform to either protocol can't support any I/O operation.
1544    ///
1545    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumereadwriteoperations?language=objc)
1546    pub unsafe trait FSVolumeReadWriteOperations: NSObjectProtocol {
1547        #[cfg(all(
1548            feature = "FSItem",
1549            feature = "FSMutableFileDataBuffer",
1550            feature = "block2",
1551            feature = "libc"
1552        ))]
1553        /// Reads the contents of the given file item.
1554        ///
1555        /// If the number of bytes requested exceeds the number of bytes available before the end of the file, then the call copies only those bytes to `buffer`.
1556        /// If `offset` points past the last valid byte of the file, don't reply with an error but set `actuallyRead` to `0`.
1557        ///
1558        /// - Parameters:
1559        /// - item: The item from which to read. FSKit guarantees this item will be of type ``FSItem/ItemType/file``.
1560        /// - offset: The offset in the file from which to start reading.
1561        /// - length: The number of bytes to read.
1562        /// - buffer: A buffer to receive the bytes read from the file.
1563        /// - reply: A block or closure to indicate success or failure. If reading succeeds, pass the number of bytes read and a `nil` error. If reading fails, pass the number of bytes read prior to the error along with the relevant error. For an `async` Swift implementation, there's no reply handler; simply return the byte count or throw an error.
1564        #[unsafe(method(readFromFile:offset:length:intoBuffer:replyHandler:))]
1565        #[unsafe(method_family = none)]
1566        unsafe fn readFromFile_offset_length_intoBuffer_replyHandler(
1567            &self,
1568            item: &FSItem,
1569            offset: libc::off_t,
1570            length: usize,
1571            buffer: &FSMutableFileDataBuffer,
1572            reply: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
1573        );
1574
1575        #[cfg(all(feature = "FSItem", feature = "block2", feature = "libc"))]
1576        /// Writes contents to the given file item.
1577        ///
1578        /// FSKit expects this routine to allocate space in the file system to extend the file as necessary.
1579        ///
1580        /// If the volume experiences an out-of-space condition, reply with an error of domain
1581        /// <doc
1582        /// ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and code `ENOSPC`.
1583        ///
1584        /// - Parameters:
1585        /// - contents: A buffer containing the data to write to the file.
1586        /// - item: The item to which to write. FSKit guarantees this item will be of type ``FSItem/ItemType/file``.
1587        /// - offset: The offset in the file from which to start writing.
1588        /// - reply: A block or closure to indicate success or failure. If writing succeeds, pass the number of bytes written and a `nil` error. If writing fails, pass the number of bytes written prior to the error along with the relevant error. For an `async` Swift implementation, there's no reply handler; simply return the byte count or throw an error.
1589        #[unsafe(method(writeContents:toFile:atOffset:replyHandler:))]
1590        #[unsafe(method_family = none)]
1591        unsafe fn writeContents_toFile_atOffset_replyHandler(
1592            &self,
1593            contents: &NSData,
1594            item: &FSItem,
1595            offset: libc::off_t,
1596            reply: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
1597        );
1598    }
1599);
1600
1601/// A bitmask of access rights.
1602///
1603/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsaccessmask?language=objc)
1604// NS_OPTIONS
1605#[repr(transparent)]
1606#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1607pub struct FSAccessMask(pub NSUInteger);
1608bitflags::bitflags! {
1609    impl FSAccessMask: NSUInteger {
1610/// The file system allows reading data.
1611        #[doc(alias = "FSAccessReadData")]
1612        const ReadData = 1<<1;
1613/// The file system allows listing directory contents.
1614        #[doc(alias = "FSAccessListDirectory")]
1615        const ListDirectory = FSAccessMask::ReadData.0;
1616/// The file system allows writing data.
1617        #[doc(alias = "FSAccessWriteData")]
1618        const WriteData = 1<<2;
1619/// The file system allows adding files.
1620        #[doc(alias = "FSAccessAddFile")]
1621        const AddFile = FSAccessMask::WriteData.0;
1622/// The file system allows file executuion.
1623        #[doc(alias = "FSAccessExecute")]
1624        const Execute = 1<<3;
1625/// The file system allows searching files.
1626        #[doc(alias = "FSAccessSearch")]
1627        const Search = FSAccessMask::Execute.0;
1628/// The file system allows deleting a file.
1629        #[doc(alias = "FSAccessDelete")]
1630        const Delete = 1<<4;
1631/// The file system allows appending data to a file.
1632        #[doc(alias = "FSAccessAppendData")]
1633        const AppendData = 1<<5;
1634/// The file system allows adding subdirectories.
1635        #[doc(alias = "FSAccessAddSubdirectory")]
1636        const AddSubdirectory = FSAccessMask::AppendData.0;
1637/// The file system allows deleting subdirectories.
1638        #[doc(alias = "FSAccessDeleteChild")]
1639        const DeleteChild = 1<<6;
1640/// The file system allows reading file attributes.
1641        #[doc(alias = "FSAccessReadAttributes")]
1642        const ReadAttributes = 1<<7;
1643/// The file system allows writing file attributes.
1644        #[doc(alias = "FSAccessWriteAttributes")]
1645        const WriteAttributes = 1<<8;
1646/// The file system allows reading extended file attributes.
1647        #[doc(alias = "FSAccessReadXattr")]
1648        const ReadXattr = 1<<9;
1649/// The file system allows writing extended file attributes.
1650        #[doc(alias = "FSAccessWriteXattr")]
1651        const WriteXattr = 1<<10;
1652/// The file system allows reading a file's security descriptors.
1653        #[doc(alias = "FSAccessReadSecurity")]
1654        const ReadSecurity = 1<<11;
1655/// The file system allows writing a file's security descriptors.
1656        #[doc(alias = "FSAccessWriteSecurity")]
1657        const WriteSecurity = 1<<12;
1658/// The file system allows taking ownership of a file.
1659        #[doc(alias = "FSAccessTakeOwnership")]
1660        const TakeOwnership = 1<<13;
1661    }
1662}
1663
1664unsafe impl Encode for FSAccessMask {
1665    const ENCODING: Encoding = NSUInteger::ENCODING;
1666}
1667
1668unsafe impl RefEncode for FSAccessMask {
1669    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1670}
1671
1672extern_protocol!(
1673    /// Methods and properties implemented by volumes that want to enforce access check operations.
1674    ///
1675    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumeaccesscheckoperations?language=objc)
1676    pub unsafe trait FSVolumeAccessCheckOperations: NSObjectProtocol {
1677        /// A Boolean value that instructs FSKit not to call this protocol's methods, even if the volume conforms to it.
1678        ///
1679        /// FSKit reads this value after the file system replies to the `loadResource` message.
1680        /// Changing the returned value during the runtime of the volume has no effect.
1681        #[optional]
1682        #[unsafe(method(isAccessCheckInhibited))]
1683        #[unsafe(method_family = none)]
1684        unsafe fn isAccessCheckInhibited(&self) -> bool;
1685
1686        /// Setter for [`isAccessCheckInhibited`][Self::isAccessCheckInhibited].
1687        #[optional]
1688        #[unsafe(method(setAccessCheckInhibited:))]
1689        #[unsafe(method_family = none)]
1690        unsafe fn setAccessCheckInhibited(&self, access_check_inhibited: bool);
1691
1692        #[cfg(all(feature = "FSItem", feature = "block2"))]
1693        /// Checks whether the file system allows access to the given item.
1694        ///
1695        /// - Parameters:
1696        /// - theItem: The item for which to check access.
1697        /// - access: A mask indicating a set of access types for which to check.
1698        /// - reply: A block or closure to indicate success or failure. If the access check succeeds, pass a Boolean value to indicate whether the file system grants access, followed by a `nil` error. If the access check fails, pass the relevant error as the second parameter; FSKit ignores the Boolean parameter in this case. For an `async` Swift implementation, there's no reply handler; simply return the `Bool` or throw an error.
1699        #[unsafe(method(checkAccessToItem:requestedAccess:replyHandler:))]
1700        #[unsafe(method_family = none)]
1701        unsafe fn checkAccessToItem_requestedAccess_replyHandler(
1702            &self,
1703            the_item: &FSItem,
1704            access: FSAccessMask,
1705            reply: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
1706        );
1707    }
1708);
1709
1710extern_protocol!(
1711    /// Methods and properties implemented by volumes that support renaming the volume.
1712    ///
1713    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumerenameoperations?language=objc)
1714    pub unsafe trait FSVolumeRenameOperations: NSObjectProtocol {
1715        /// A Boolean value that instructs FSKit not to call this protocol's methods, even if the volume conforms to it.
1716        ///
1717        /// FSKit reads this value after the file system replies to the `loadResource` message.
1718        /// Changing the returned value during the runtime of the volume has no effect.
1719        #[optional]
1720        #[unsafe(method(isVolumeRenameInhibited))]
1721        #[unsafe(method_family = none)]
1722        unsafe fn isVolumeRenameInhibited(&self) -> bool;
1723
1724        /// Setter for [`isVolumeRenameInhibited`][Self::isVolumeRenameInhibited].
1725        #[optional]
1726        #[unsafe(method(setVolumeRenameInhibited:))]
1727        #[unsafe(method_family = none)]
1728        unsafe fn setVolumeRenameInhibited(&self, volume_rename_inhibited: bool);
1729
1730        #[cfg(all(feature = "FSFileName", feature = "block2"))]
1731        /// Sets a new name for the volume.
1732        ///
1733        /// - Parameters:
1734        /// - name: The new volume name.
1735        /// - reply: A block or closure to indicate success or failure. If renaming succeeds, pass an ``FSFileName`` of the new volume name and a `nil` error. If renaming fails, pass the relevant error as the second parameter; FSKit ignores any ``FSFileName`` in this case. For an `async` Swift implementation, there's no reply handler; simply return the ``FSFileName`` or throw an error.
1736        #[unsafe(method(setVolumeName:replyHandler:))]
1737        #[unsafe(method_family = none)]
1738        unsafe fn setVolumeName_replyHandler(
1739            &self,
1740            name: &FSFileName,
1741            reply: &block2::DynBlock<dyn Fn(*mut FSFileName, *mut NSError)>,
1742        );
1743    }
1744);
1745
1746/// Behavior flags for preallocation operations.
1747///
1748/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fspreallocateflags?language=objc)
1749// NS_OPTIONS
1750#[repr(transparent)]
1751#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1752pub struct FSPreallocateFlags(pub NSUInteger);
1753bitflags::bitflags! {
1754    impl FSPreallocateFlags: NSUInteger {
1755/// Allocates contiguous space.
1756        #[doc(alias = "FSPreallocateFlagsContiguous")]
1757        const Contiguous = 0x00000002;
1758/// Allocates all requested space or no space at all.
1759        #[doc(alias = "FSPreallocateFlagsAll")]
1760        const All = 0x00000004;
1761/// Allocates space that isn't freed when deleting the descriptor.
1762///
1763/// This space remains allocated even after calling `close(2)`.
1764        #[doc(alias = "FSPreallocateFlagsPersist")]
1765        const Persist = 0x00000008;
1766/// Allocates space from the physical end of file.
1767///
1768/// When implementing this behavior, ignore any offset in the preallocate call.
1769/// This flag is currently set for all ``FSVolume/PreallocateOperations/preallocateSpace(for:at:length:flags:replyHandler:)`` calls.
1770        #[doc(alias = "FSPreallocateFlagsFromEOF")]
1771        const FromEOF = 0x00000010;
1772    }
1773}
1774
1775unsafe impl Encode for FSPreallocateFlags {
1776    const ENCODING: Encoding = NSUInteger::ENCODING;
1777}
1778
1779unsafe impl RefEncode for FSPreallocateFlags {
1780    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1781}
1782
1783extern_protocol!(
1784    /// Methods and properties implemented by volumes that want to offer preallocation functions.
1785    ///
1786    /// A preallocation operation allocates space for a file without writing to it yet.
1787    /// A file system may use reallocation to avoid performing space allocation while in the midst of I/O; this strategy improves performance.
1788    /// Also, if the expected I/O pattern is many small writes, preallocating contiguous chunks may prevent fragmenting the file system.
1789    /// This process can improve performance later.
1790    ///
1791    /// In a kernel-based file system, you typically preallocate space with the `VNOP_ALLOCATE` operation, called from `fcntl(F_PREALLOCATE)`.
1792    ///
1793    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumepreallocateoperations?language=objc)
1794    pub unsafe trait FSVolumePreallocateOperations: NSObjectProtocol {
1795        /// A Boolean value that instructs FSKit not to call this protocol's methods, even if the volume conforms to it.
1796        ///
1797        /// FSKit reads this value after the file system replies to the `loadResource` message.
1798        /// Changing the returned value during the runtime of the volume has no effect.
1799        #[optional]
1800        #[unsafe(method(isPreallocateInhibited))]
1801        #[unsafe(method_family = none)]
1802        unsafe fn isPreallocateInhibited(&self) -> bool;
1803
1804        /// Setter for [`isPreallocateInhibited`][Self::isPreallocateInhibited].
1805        #[optional]
1806        #[unsafe(method(setPreallocateInhibited:))]
1807        #[unsafe(method_family = none)]
1808        unsafe fn setPreallocateInhibited(&self, preallocate_inhibited: bool);
1809
1810        #[cfg(all(feature = "FSItem", feature = "block2", feature = "libc"))]
1811        /// Prealocates disk space for the given item.
1812        ///
1813        /// - Parameters:
1814        /// - item: The item for which to preallocate space.
1815        /// - offset: The offset from which to allocate.
1816        /// - length: The length of the space in bytes.
1817        /// - flags: Flags that affect the preallocation behavior.
1818        /// - reply: A block or closure to indicate success or failure. If preallocation succeeds, pass the amount of bytes allocated and a `nil` error. If preallocation fails, pass the relevant error as the second parameter; FSKit ignores any byte count in this case. For an `async` Swift implementation, there's no reply handler; simply return the allocated byte count or throw an error.
1819        #[unsafe(method(preallocateSpaceForItem:atOffset:length:flags:replyHandler:))]
1820        #[unsafe(method_family = none)]
1821        unsafe fn preallocateSpaceForItem_atOffset_length_flags_replyHandler(
1822            &self,
1823            item: &FSItem,
1824            offset: libc::off_t,
1825            length: usize,
1826            flags: FSPreallocateFlags,
1827            reply: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
1828        );
1829    }
1830);
1831
1832/// Options to specify the item deactivation policy.
1833///
1834/// Callers may want to set a deactivation policy because ``FSVolume/ItemDeactivation/deactivateItem(_:replyHandler:)`` processing blocks the kernel.
1835/// Setting a deactivation policy allows the file system to take action at a definitive point in the item's life cycle.
1836/// These options allow the file system to instruct the FSKit kernel of which circumstances require the expense of a round-trip call to the module.
1837///
1838/// > Note: To avoid performing deactivation calls, Objective-C developers use the value `FSItemDeactivationNever`. In Swift, use an empty option set (`[]`).
1839///
1840/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemdeactivationoptions?language=objc)
1841// NS_OPTIONS
1842#[repr(transparent)]
1843#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1844pub struct FSItemDeactivationOptions(pub NSUInteger);
1845bitflags::bitflags! {
1846    impl FSItemDeactivationOptions: NSUInteger {
1847/// An option to never perform deactivation.
1848///
1849/// With this deactivation option, FSKit never issues `deactivateItem` calls, even though the volume conforms to ``FSVolume/ItemDeactivation``.
1850        #[doc(alias = "FSItemDeactivationNever")]
1851        const Never = 0;
1852/// An option to always perform deactivation calls.
1853///
1854/// Use this option if the file system needs `deactivateItem` calls in circumstances beyond those covered by ``forRemovedItems`` and ``forPreallocatedItems``.
1855        #[doc(alias = "FSItemDeactivationAlways")]
1856        const Always = NSUIntegerMax as _;
1857/// An option to process deactivation for open-unlinked items at the moment of last close.
1858        #[doc(alias = "FSItemDeactivationForRemovedItems")]
1859        const ForRemovedItems = 1<<0;
1860/// An option to process deactivation for for files with preallocated space.
1861///
1862/// This option facilitates a sort of trim-on-close behavior.
1863/// It is only meaningful for volumes that conform to ``FSVolume/PreallocateOperations``.
1864        #[doc(alias = "FSItemDeactivationForPreallocatedItems")]
1865        const ForPreallocatedItems = 1<<1;
1866    }
1867}
1868
1869unsafe impl Encode for FSItemDeactivationOptions {
1870    const ENCODING: Encoding = NSUInteger::ENCODING;
1871}
1872
1873unsafe impl RefEncode for FSItemDeactivationOptions {
1874    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1875}
1876
1877extern_protocol!(
1878    /// Methods and properties implemented by volumes that support deactivating items.
1879    ///
1880    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsvolumeitemdeactivation?language=objc)
1881    pub unsafe trait FSVolumeItemDeactivation: NSObjectProtocol {
1882        /// A property that tells FSKit to which types of items the deactivation applies, if any.
1883        ///
1884        /// FSKit reads this value after the file system replies to the `loadResource` message.
1885        /// Changing the returned value during the runtime of the volume has no effect.
1886        #[unsafe(method(itemDeactivationPolicy))]
1887        #[unsafe(method_family = none)]
1888        unsafe fn itemDeactivationPolicy(&self) -> FSItemDeactivationOptions;
1889
1890        #[cfg(all(feature = "FSItem", feature = "block2"))]
1891        /// Notifies the file system that the kernel is no longer making immediate use of the given item.
1892        ///
1893        /// This method gives a file system a chance to release resources associated wtih an item.
1894        /// However, this method prescribes no specific action; it's acceptable to defer all reclamation until ``FSVolume/Operations/reclaimItem(_:replyHandler:)``.
1895        /// This method is the equivalent of VFS's `VNOP_INACTIVE`.
1896        ///
1897        /// FSKit restricts calls to this method based on the current value of ``FSVolume/ItemDeactivation/itemDeactivationPolicy``.
1898        ///
1899        /// - Parameters:
1900        /// - item: The item to deactivate.
1901        /// - reply: A block or closure to indicate success or failure. If deactivation fails, pass an error as the one parameter to the reply handler. If deactivation succeeds, pass `nil`. For an `async` Swift implementation, there's no reply handler; simply throw an error or return normally.
1902        #[unsafe(method(deactivateItem:replyHandler:))]
1903        #[unsafe(method_family = none)]
1904        unsafe fn deactivateItem_replyHandler(
1905            &self,
1906            item: &FSItem,
1907            reply: &block2::DynBlock<dyn Fn(*mut NSError)>,
1908        );
1909    }
1910);