objc2_fs_kit/generated/
FSItem.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 set of item attributes to get or set.
11///
12/// This type is an option set in Swift.
13/// In Objective-C, you use the cases of this enumeration to create a bit field.
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemattribute?language=objc)
16// NS_OPTIONS
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct FSItemAttribute(pub NSInteger);
20bitflags::bitflags! {
21    impl FSItemAttribute: NSInteger {
22/// The type attribute.
23        #[doc(alias = "FSItemAttributeType")]
24        const Type = 1<<0;
25/// The mode attribute.
26        #[doc(alias = "FSItemAttributeMode")]
27        const Mode = 1<<1;
28/// The link count attribute.
29        #[doc(alias = "FSItemAttributeLinkCount")]
30        const LinkCount = 1<<2;
31/// The user ID (uid) attribute.
32        #[doc(alias = "FSItemAttributeUID")]
33        const UID = 1<<3;
34/// The group ID (gid) attribute.
35        #[doc(alias = "FSItemAttributeGID")]
36        const GID = 1<<4;
37/// The flags attribute.
38        #[doc(alias = "FSItemAttributeFlags")]
39        const Flags = 1<<5;
40/// The size attribute.
41        #[doc(alias = "FSItemAttributeSize")]
42        const Size = 1<<6;
43/// The allocated size attribute.
44        #[doc(alias = "FSItemAttributeAllocSize")]
45        const AllocSize = 1<<7;
46/// The file ID attribute.
47        #[doc(alias = "FSItemAttributeFileID")]
48        const FileID = 1<<8;
49/// The parent ID attribute.
50        #[doc(alias = "FSItemAttributeParentID")]
51        const ParentID = 1<<9;
52/// The last-accessed time attribute.
53        #[doc(alias = "FSItemAttributeAccessTime")]
54        const AccessTime = 1<<10;
55/// The last-modified time attribute.
56        #[doc(alias = "FSItemAttributeModifyTime")]
57        const ModifyTime = 1<<11;
58/// The last-changed time attribute.
59        #[doc(alias = "FSItemAttributeChangeTime")]
60        const ChangeTime = 1<<12;
61/// The creation time attribute.
62        #[doc(alias = "FSItemAttributeBirthTime")]
63        const BirthTime = 1<<13;
64/// The backup time attribute.
65        #[doc(alias = "FSItemAttributeBackupTime")]
66        const BackupTime = 1<<14;
67/// The time added attribute.
68        #[doc(alias = "FSItemAttributeAddedTime")]
69        const AddedTime = 1<<15;
70/// The supports limited extended attributes attribute.
71        #[doc(alias = "FSItemAttributeSupportsLimitedXAttrs")]
72        const SupportsLimitedXAttrs = 1<<16;
73/// The inhibit kernel offloaded I/O attribute.
74        #[doc(alias = "FSItemAttributeInhibitKernelOffloadedIO")]
75        const InhibitKernelOffloadedIO = 1<<17;
76    }
77}
78
79unsafe impl Encode for FSItemAttribute {
80    const ENCODING: Encoding = NSInteger::ENCODING;
81}
82
83unsafe impl RefEncode for FSItemAttribute {
84    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
85}
86
87/// An enumeration of item types, such as file, directory, or symbolic link.
88///
89/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemtype?language=objc)
90// NS_ENUM
91#[repr(transparent)]
92#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
93pub struct FSItemType(pub NSInteger);
94impl FSItemType {
95    #[doc(alias = "FSItemTypeUnknown")]
96    pub const Unknown: Self = Self(0);
97    #[doc(alias = "FSItemTypeFile")]
98    pub const File: Self = Self(1);
99    #[doc(alias = "FSItemTypeDirectory")]
100    pub const Directory: Self = Self(2);
101    #[doc(alias = "FSItemTypeSymlink")]
102    pub const Symlink: Self = Self(3);
103    #[doc(alias = "FSItemTypeFIFO")]
104    pub const FIFO: Self = Self(4);
105    #[doc(alias = "FSItemTypeCharDevice")]
106    pub const CharDevice: Self = Self(5);
107    #[doc(alias = "FSItemTypeBlockDevice")]
108    pub const BlockDevice: Self = Self(6);
109    #[doc(alias = "FSItemTypeSocket")]
110    pub const Socket: Self = Self(7);
111}
112
113unsafe impl Encode for FSItemType {
114    const ENCODING: Encoding = NSInteger::ENCODING;
115}
116
117unsafe impl RefEncode for FSItemType {
118    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
119}
120
121/// [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemid?language=objc)
122// NS_ENUM
123#[repr(transparent)]
124#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
125pub struct FSItemID(pub u64);
126impl FSItemID {
127    #[doc(alias = "FSItemIDInvalid")]
128    pub const Invalid: Self = Self(0);
129    #[doc(alias = "FSItemIDParentOfRoot")]
130    pub const ParentOfRoot: Self = Self(1);
131    #[doc(alias = "FSItemIDRootDirectory")]
132    pub const RootDirectory: Self = Self(2);
133}
134
135unsafe impl Encode for FSItemID {
136    const ENCODING: Encoding = u64::ENCODING;
137}
138
139unsafe impl RefEncode for FSItemID {
140    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
141}
142
143extern_class!(
144    /// A distinct object in a file hierarchy, such as a file, directory, symlink, socket, and more.
145    ///
146    /// An `FSItem` is a mostly opaque object, which your file system implementation defines as needed.
147    ///
148    /// The ``FSItemAttributes`` class defines nonatomic properties to support `FSItem` instances.
149    /// An ``FSItemAttributes`` instance contains a snapshot of the attributes of an `FSItem` at one point in time.
150    /// The ``FSItemAttributes`` properties have no explicit thread safety provisions, since the operations that either get or set these properties enforce thread safety.
151    ///
152    /// You test an attribute's validity with the the method ``FSItem/Attributes/isValid(_:)``.
153    /// If the value is `true` (Swift) or `YES` (Objective-C), it's safe to use the attribute.
154    ///
155    /// Methods that get or set an item's attribute use ``FSItemGetAttributesRequest`` or ``FSItemSetAttributesRequest``, respectively.
156    /// Both are subclasses of ``FSItemAttributes``.
157    /// An ``FSItemGetAttributesRequest`` contains a ``FSItemGetAttributesRequest/wantedAttributes`` property to indicate the attributes a file system provides for the request.
158    /// Similarly, ``FSItemSetAttributesRequest`` uses the property ``FSItemSetAttributesRequest/consumedAttributes`` for a file system to signal back which attributes it successfully used.
159    ///
160    /// `FSItem` is the FSKit equivelant of a vnode in the kernel.
161    /// For every FSKit vnode in the kernel, the `FSModule` hosting the volume has an instantiated `FSItem`.
162    ///
163    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitem?language=objc)
164    #[unsafe(super(NSObject))]
165    #[derive(Debug, PartialEq, Eq, Hash)]
166    pub struct FSItem;
167);
168
169extern_conformance!(
170    unsafe impl NSObjectProtocol for FSItem {}
171);
172
173impl FSItem {
174    extern_methods!();
175}
176
177/// Methods declared on superclass `NSObject`.
178impl FSItem {
179    extern_methods!(
180        #[unsafe(method(init))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
183
184        #[unsafe(method(new))]
185        #[unsafe(method_family = new)]
186        pub unsafe fn new() -> Retained<Self>;
187    );
188}
189
190extern_class!(
191    /// Attributes of an item, such as size, creation and modification times, and user and group identifiers.
192    ///
193    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemattributes?language=objc)
194    #[unsafe(super(NSObject))]
195    #[derive(Debug, PartialEq, Eq, Hash)]
196    pub struct FSItemAttributes;
197);
198
199extern_conformance!(
200    unsafe impl NSCoding for FSItemAttributes {}
201);
202
203extern_conformance!(
204    unsafe impl NSObjectProtocol for FSItemAttributes {}
205);
206
207extern_conformance!(
208    unsafe impl NSSecureCoding for FSItemAttributes {}
209);
210
211impl FSItemAttributes {
212    extern_methods!(
213        /// Marks all attributes inactive.
214        #[unsafe(method(invalidateAllProperties))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn invalidateAllProperties(&self);
217
218        /// The user identifier.
219        #[unsafe(method(uid))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn uid(&self) -> u32;
222
223        /// Setter for [`uid`][Self::uid].
224        #[unsafe(method(setUid:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn setUid(&self, uid: u32);
227
228        /// The group identifier.
229        #[unsafe(method(gid))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn gid(&self) -> u32;
232
233        /// Setter for [`gid`][Self::gid].
234        #[unsafe(method(setGid:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn setGid(&self, gid: u32);
237
238        /// The mode of the item.
239        ///
240        /// The mode is often used for `setuid`, `setgid`, and `sticky` bits.
241        #[unsafe(method(mode))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn mode(&self) -> u32;
244
245        /// Setter for [`mode`][Self::mode].
246        #[unsafe(method(setMode:))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn setMode(&self, mode: u32);
249
250        /// The item type, such as a regular file, directory, or symbolic link.
251        #[unsafe(method(type))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn r#type(&self) -> FSItemType;
254
255        /// Setter for [`type`][Self::type].
256        #[unsafe(method(setType:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn setType(&self, r#type: FSItemType);
259
260        /// The number of hard links to the item.
261        #[unsafe(method(linkCount))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn linkCount(&self) -> u32;
264
265        /// Setter for [`linkCount`][Self::linkCount].
266        #[unsafe(method(setLinkCount:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn setLinkCount(&self, link_count: u32);
269
270        /// The item's behavior flags.
271        ///
272        /// See `st_flags` in `stat.h` for flag definitions.
273        #[unsafe(method(flags))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn flags(&self) -> u32;
276
277        /// Setter for [`flags`][Self::flags].
278        #[unsafe(method(setFlags:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn setFlags(&self, flags: u32);
281
282        /// The item's size.
283        #[unsafe(method(size))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn size(&self) -> u64;
286
287        /// Setter for [`size`][Self::size].
288        #[unsafe(method(setSize:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setSize(&self, size: u64);
291
292        /// The item's allocated size.
293        #[unsafe(method(allocSize))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn allocSize(&self) -> u64;
296
297        /// Setter for [`allocSize`][Self::allocSize].
298        #[unsafe(method(setAllocSize:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn setAllocSize(&self, alloc_size: u64);
301
302        /// The item's file identifier.
303        #[unsafe(method(fileID))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn fileID(&self) -> FSItemID;
306
307        /// Setter for [`fileID`][Self::fileID].
308        #[unsafe(method(setFileID:))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn setFileID(&self, file_id: FSItemID);
311
312        /// The identifier of the item's parent.
313        #[unsafe(method(parentID))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn parentID(&self) -> FSItemID;
316
317        /// Setter for [`parentID`][Self::parentID].
318        #[unsafe(method(setParentID:))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn setParentID(&self, parent_id: FSItemID);
321
322        /// A Boolean value that indicates whether the item supports a limited set of extended attributes.
323        #[unsafe(method(supportsLimitedXAttrs))]
324        #[unsafe(method_family = none)]
325        pub unsafe fn supportsLimitedXAttrs(&self) -> bool;
326
327        /// Setter for [`supportsLimitedXAttrs`][Self::supportsLimitedXAttrs].
328        #[unsafe(method(setSupportsLimitedXAttrs:))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn setSupportsLimitedXAttrs(&self, supports_limited_x_attrs: bool);
331
332        /// A Boolean value that indicates whether the file system overrides the per-volume settings for kernel offloaded I/O for a specific file.
333        ///
334        /// This property has no meaning if the volume doesn't conform to ``FSVolumeKernelOffloadedIOOperations``.
335        #[unsafe(method(inhibitKernelOffloadedIO))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn inhibitKernelOffloadedIO(&self) -> bool;
338
339        /// Setter for [`inhibitKernelOffloadedIO`][Self::inhibitKernelOffloadedIO].
340        #[unsafe(method(setInhibitKernelOffloadedIO:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn setInhibitKernelOffloadedIO(&self, inhibit_kernel_offloaded_io: bool);
343
344        /// Returns a Boolean value that indicates whether the attribute is valid.
345        ///
346        /// If the value returned by this method is `YES` (Objective-C) or `true` (Swift), a caller can safely use the given attribute.
347        #[unsafe(method(isValid:))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn isValid(&self, attribute: FSItemAttribute) -> bool;
350    );
351}
352
353/// Methods declared on superclass `NSObject`.
354impl FSItemAttributes {
355    extern_methods!(
356        #[unsafe(method(init))]
357        #[unsafe(method_family = init)]
358        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
359
360        #[unsafe(method(new))]
361        #[unsafe(method_family = new)]
362        pub unsafe fn new() -> Retained<Self>;
363    );
364}
365
366extern_class!(
367    /// A request to set attributes on an item.
368    ///
369    /// Methods that take attributes use this type to receive attribute values and to indicate which attributes they support.
370    /// The various members of the parent type, ``FSItemAttributes``, contain the values of the attributes to set.
371    ///
372    /// Modify the ``consumedAttributes`` property to indicate which attributes your file system successfully used.
373    /// FSKit calls the ``wasAttributeConsumed(_:)`` method to determine whether the file system successfully used a given attribute.
374    /// Only set the attributes that your file system supports.
375    ///
376    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemsetattributesrequest?language=objc)
377    #[unsafe(super(FSItemAttributes, NSObject))]
378    #[derive(Debug, PartialEq, Eq, Hash)]
379    pub struct FSItemSetAttributesRequest;
380);
381
382extern_conformance!(
383    unsafe impl NSCoding for FSItemSetAttributesRequest {}
384);
385
386extern_conformance!(
387    unsafe impl NSObjectProtocol for FSItemSetAttributesRequest {}
388);
389
390extern_conformance!(
391    unsafe impl NSSecureCoding for FSItemSetAttributesRequest {}
392);
393
394impl FSItemSetAttributesRequest {
395    extern_methods!(
396        /// The attributes successfully used by the file system.
397        ///
398        /// This property is a bit field in Objective-C and an
399        /// <doc
400        /// ://com.apple.documentation/documentation/Swift/OptionSet> in Swift.
401        #[unsafe(method(consumedAttributes))]
402        #[unsafe(method_family = none)]
403        pub unsafe fn consumedAttributes(&self) -> FSItemAttribute;
404
405        /// Setter for [`consumedAttributes`][Self::consumedAttributes].
406        #[unsafe(method(setConsumedAttributes:))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn setConsumedAttributes(&self, consumed_attributes: FSItemAttribute);
409
410        /// A method that indicates whether the file system used the given attribute.
411        ///
412        /// - Parameter attribute: The ``FSItemAttribute`` to check.
413        #[unsafe(method(wasAttributeConsumed:))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn wasAttributeConsumed(&self, attribute: FSItemAttribute) -> bool;
416    );
417}
418
419/// Methods declared on superclass `NSObject`.
420impl FSItemSetAttributesRequest {
421    extern_methods!(
422        #[unsafe(method(init))]
423        #[unsafe(method_family = init)]
424        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
425
426        #[unsafe(method(new))]
427        #[unsafe(method_family = new)]
428        pub unsafe fn new() -> Retained<Self>;
429    );
430}
431
432extern_class!(
433    /// A request to get attributes from an item.
434    ///
435    /// Methods that retrieve attributes use this type and inspect the ``wantedAttributes`` property to determine which attributes to provide. FSKit calls the ``isAttributeWanted(_:)`` method to determine whether the request requires a given attribute.
436    ///
437    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemgetattributesrequest?language=objc)
438    #[unsafe(super(NSObject))]
439    #[derive(Debug, PartialEq, Eq, Hash)]
440    pub struct FSItemGetAttributesRequest;
441);
442
443extern_conformance!(
444    unsafe impl NSCoding for FSItemGetAttributesRequest {}
445);
446
447extern_conformance!(
448    unsafe impl NSObjectProtocol for FSItemGetAttributesRequest {}
449);
450
451extern_conformance!(
452    unsafe impl NSSecureCoding for FSItemGetAttributesRequest {}
453);
454
455impl FSItemGetAttributesRequest {
456    extern_methods!(
457        /// The attributes requested by the request.
458        ///
459        /// This property is a bit field in Objective-C and an
460        /// <doc
461        /// ://com.apple.documentation/documentation/Swift/OptionSet> in Swift.
462        #[unsafe(method(wantedAttributes))]
463        #[unsafe(method_family = none)]
464        pub unsafe fn wantedAttributes(&self) -> FSItemAttribute;
465
466        /// Setter for [`wantedAttributes`][Self::wantedAttributes].
467        #[unsafe(method(setWantedAttributes:))]
468        #[unsafe(method_family = none)]
469        pub unsafe fn setWantedAttributes(&self, wanted_attributes: FSItemAttribute);
470
471        /// A method that indicates whether the request wants given attribute.
472        ///
473        /// - Parameter attribute: The ``FSItemAttribute`` to check.
474        #[unsafe(method(isAttributeWanted:))]
475        #[unsafe(method_family = none)]
476        pub unsafe fn isAttributeWanted(&self, attribute: FSItemAttribute) -> bool;
477    );
478}
479
480/// Methods declared on superclass `NSObject`.
481impl FSItemGetAttributesRequest {
482    extern_methods!(
483        #[unsafe(method(init))]
484        #[unsafe(method_family = init)]
485        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
486
487        #[unsafe(method(new))]
488        #[unsafe(method_family = new)]
489        pub unsafe fn new() -> Retained<Self>;
490    );
491}