objc2-fs-kit 0.3.2

Bindings to the FSKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// A value that indicates a set of item attributes to get or set.
///
/// This type is an option set in Swift.
/// In Objective-C, you use the cases of this enumeration to create a bit field.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemattribute?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FSItemAttribute(pub NSInteger);
bitflags::bitflags! {
    impl FSItemAttribute: NSInteger {
/// The type attribute.
        #[doc(alias = "FSItemAttributeType")]
        const Type = 1<<0;
/// The mode attribute.
        #[doc(alias = "FSItemAttributeMode")]
        const Mode = 1<<1;
/// The link count attribute.
        #[doc(alias = "FSItemAttributeLinkCount")]
        const LinkCount = 1<<2;
/// The user ID (uid) attribute.
        #[doc(alias = "FSItemAttributeUID")]
        const UID = 1<<3;
/// The group ID (gid) attribute.
        #[doc(alias = "FSItemAttributeGID")]
        const GID = 1<<4;
/// The flags attribute.
        #[doc(alias = "FSItemAttributeFlags")]
        const Flags = 1<<5;
/// The size attribute.
        #[doc(alias = "FSItemAttributeSize")]
        const Size = 1<<6;
/// The allocated size attribute.
        #[doc(alias = "FSItemAttributeAllocSize")]
        const AllocSize = 1<<7;
/// The file ID attribute.
        #[doc(alias = "FSItemAttributeFileID")]
        const FileID = 1<<8;
/// The parent ID attribute.
        #[doc(alias = "FSItemAttributeParentID")]
        const ParentID = 1<<9;
/// The last-accessed time attribute.
        #[doc(alias = "FSItemAttributeAccessTime")]
        const AccessTime = 1<<10;
/// The last-modified time attribute.
        #[doc(alias = "FSItemAttributeModifyTime")]
        const ModifyTime = 1<<11;
/// The last-changed time attribute.
        #[doc(alias = "FSItemAttributeChangeTime")]
        const ChangeTime = 1<<12;
/// The creation time attribute.
        #[doc(alias = "FSItemAttributeBirthTime")]
        const BirthTime = 1<<13;
/// The backup time attribute.
        #[doc(alias = "FSItemAttributeBackupTime")]
        const BackupTime = 1<<14;
/// The time added attribute.
        #[doc(alias = "FSItemAttributeAddedTime")]
        const AddedTime = 1<<15;
/// The supports limited extended attributes attribute.
        #[doc(alias = "FSItemAttributeSupportsLimitedXAttrs")]
        const SupportsLimitedXAttrs = 1<<16;
/// The inhibit kernel offloaded I/O attribute.
        #[doc(alias = "FSItemAttributeInhibitKernelOffloadedIO")]
        const InhibitKernelOffloadedIO = 1<<17;
    }
}

unsafe impl Encode for FSItemAttribute {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for FSItemAttribute {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// An enumeration of item types, such as file, directory, or symbolic link.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FSItemType(pub NSInteger);
impl FSItemType {
    #[doc(alias = "FSItemTypeUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "FSItemTypeFile")]
    pub const File: Self = Self(1);
    #[doc(alias = "FSItemTypeDirectory")]
    pub const Directory: Self = Self(2);
    #[doc(alias = "FSItemTypeSymlink")]
    pub const Symlink: Self = Self(3);
    #[doc(alias = "FSItemTypeFIFO")]
    pub const FIFO: Self = Self(4);
    #[doc(alias = "FSItemTypeCharDevice")]
    pub const CharDevice: Self = Self(5);
    #[doc(alias = "FSItemTypeBlockDevice")]
    pub const BlockDevice: Self = Self(6);
    #[doc(alias = "FSItemTypeSocket")]
    pub const Socket: Self = Self(7);
}

unsafe impl Encode for FSItemType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for FSItemType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemid?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct FSItemID(pub u64);
impl FSItemID {
    #[doc(alias = "FSItemIDInvalid")]
    pub const Invalid: Self = Self(0);
    #[doc(alias = "FSItemIDParentOfRoot")]
    pub const ParentOfRoot: Self = Self(1);
    #[doc(alias = "FSItemIDRootDirectory")]
    pub const RootDirectory: Self = Self(2);
}

unsafe impl Encode for FSItemID {
    const ENCODING: Encoding = u64::ENCODING;
}

unsafe impl RefEncode for FSItemID {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A distinct object in a file hierarchy, such as a file, directory, symlink, socket, and more.
    ///
    /// An `FSItem` is a mostly opaque object, which your file system implementation defines as needed.
    ///
    /// The ``FSItemAttributes`` class defines nonatomic properties to support `FSItem` instances.
    /// An ``FSItemAttributes`` instance contains a snapshot of the attributes of an `FSItem` at one point in time.
    /// The ``FSItemAttributes`` properties have no explicit thread safety provisions, since the operations that either get or set these properties enforce thread safety.
    ///
    /// You test an attribute's validity with the the method ``FSItem/Attributes/isValid(_:)``.
    /// If the value is `true` (Swift) or `YES` (Objective-C), it's safe to use the attribute.
    ///
    /// Methods that get or set an item's attribute use ``FSItemGetAttributesRequest`` or ``FSItemSetAttributesRequest``, respectively.
    /// Both are subclasses of ``FSItemAttributes``.
    /// An ``FSItemGetAttributesRequest`` contains a ``FSItemGetAttributesRequest/wantedAttributes`` property to indicate the attributes a file system provides for the request.
    /// Similarly, ``FSItemSetAttributesRequest`` uses the property ``FSItemSetAttributesRequest/consumedAttributes`` for a file system to signal back which attributes it successfully used.
    ///
    /// `FSItem` is the FSKit equivelant of a vnode in the kernel.
    /// For every FSKit vnode in the kernel, the `FSModule` hosting the volume has an instantiated `FSItem`.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitem?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct FSItem;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for FSItem {}
);

impl FSItem {
    extern_methods!();
}

/// Methods declared on superclass `NSObject`.
impl FSItem {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Attributes of an item, such as size, creation and modification times, and user and group identifiers.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemattributes?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct FSItemAttributes;
);

extern_conformance!(
    unsafe impl NSCoding for FSItemAttributes {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for FSItemAttributes {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for FSItemAttributes {}
);

impl FSItemAttributes {
    extern_methods!(
        /// Marks all attributes inactive.
        #[unsafe(method(invalidateAllProperties))]
        #[unsafe(method_family = none)]
        pub unsafe fn invalidateAllProperties(&self);

        /// The user identifier.
        #[unsafe(method(uid))]
        #[unsafe(method_family = none)]
        pub unsafe fn uid(&self) -> u32;

        /// Setter for [`uid`][Self::uid].
        #[unsafe(method(setUid:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUid(&self, uid: u32);

        /// The group identifier.
        #[unsafe(method(gid))]
        #[unsafe(method_family = none)]
        pub unsafe fn gid(&self) -> u32;

        /// Setter for [`gid`][Self::gid].
        #[unsafe(method(setGid:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGid(&self, gid: u32);

        /// The mode of the item.
        ///
        /// The mode is often used for `setuid`, `setgid`, and `sticky` bits.
        #[unsafe(method(mode))]
        #[unsafe(method_family = none)]
        pub unsafe fn mode(&self) -> u32;

        /// Setter for [`mode`][Self::mode].
        #[unsafe(method(setMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMode(&self, mode: u32);

        /// The item type, such as a regular file, directory, or symbolic link.
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub unsafe fn r#type(&self) -> FSItemType;

        /// Setter for [`type`][Self::type].
        #[unsafe(method(setType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setType(&self, r#type: FSItemType);

        /// The number of hard links to the item.
        #[unsafe(method(linkCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn linkCount(&self) -> u32;

        /// Setter for [`linkCount`][Self::linkCount].
        #[unsafe(method(setLinkCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLinkCount(&self, link_count: u32);

        /// The item's behavior flags.
        ///
        /// See `st_flags` in `stat.h` for flag definitions.
        #[unsafe(method(flags))]
        #[unsafe(method_family = none)]
        pub unsafe fn flags(&self) -> u32;

        /// Setter for [`flags`][Self::flags].
        #[unsafe(method(setFlags:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFlags(&self, flags: u32);

        /// The item's size.
        #[unsafe(method(size))]
        #[unsafe(method_family = none)]
        pub unsafe fn size(&self) -> u64;

        /// Setter for [`size`][Self::size].
        #[unsafe(method(setSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSize(&self, size: u64);

        /// The item's allocated size.
        #[unsafe(method(allocSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn allocSize(&self) -> u64;

        /// Setter for [`allocSize`][Self::allocSize].
        #[unsafe(method(setAllocSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAllocSize(&self, alloc_size: u64);

        /// The item's file identifier.
        #[unsafe(method(fileID))]
        #[unsafe(method_family = none)]
        pub unsafe fn fileID(&self) -> FSItemID;

        /// Setter for [`fileID`][Self::fileID].
        #[unsafe(method(setFileID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFileID(&self, file_id: FSItemID);

        /// The identifier of the item's parent.
        #[unsafe(method(parentID))]
        #[unsafe(method_family = none)]
        pub unsafe fn parentID(&self) -> FSItemID;

        /// Setter for [`parentID`][Self::parentID].
        #[unsafe(method(setParentID:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setParentID(&self, parent_id: FSItemID);

        /// A Boolean value that indicates whether the item supports a limited set of extended attributes.
        #[unsafe(method(supportsLimitedXAttrs))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportsLimitedXAttrs(&self) -> bool;

        /// Setter for [`supportsLimitedXAttrs`][Self::supportsLimitedXAttrs].
        #[unsafe(method(setSupportsLimitedXAttrs:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSupportsLimitedXAttrs(&self, supports_limited_x_attrs: bool);

        /// A Boolean value that indicates whether the file system overrides the per-volume settings for kernel offloaded I/O for a specific file.
        ///
        /// This property has no meaning if the volume doesn't conform to ``FSVolumeKernelOffloadedIOOperations``.
        #[unsafe(method(inhibitKernelOffloadedIO))]
        #[unsafe(method_family = none)]
        pub unsafe fn inhibitKernelOffloadedIO(&self) -> bool;

        /// Setter for [`inhibitKernelOffloadedIO`][Self::inhibitKernelOffloadedIO].
        #[unsafe(method(setInhibitKernelOffloadedIO:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInhibitKernelOffloadedIO(&self, inhibit_kernel_offloaded_io: bool);

        /// Returns a Boolean value that indicates whether the attribute is valid.
        ///
        /// If the value returned by this method is `YES` (Objective-C) or `true` (Swift), a caller can safely use the given attribute.
        #[unsafe(method(isValid:))]
        #[unsafe(method_family = none)]
        pub unsafe fn isValid(&self, attribute: FSItemAttribute) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl FSItemAttributes {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// A request to set attributes on an item.
    ///
    /// Methods that take attributes use this type to receive attribute values and to indicate which attributes they support.
    /// The various members of the parent type, ``FSItemAttributes``, contain the values of the attributes to set.
    ///
    /// Modify the ``consumedAttributes`` property to indicate which attributes your file system successfully used.
    /// FSKit calls the ``wasAttributeConsumed(_:)`` method to determine whether the file system successfully used a given attribute.
    /// Only set the attributes that your file system supports.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemsetattributesrequest?language=objc)
    #[unsafe(super(FSItemAttributes, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct FSItemSetAttributesRequest;
);

extern_conformance!(
    unsafe impl NSCoding for FSItemSetAttributesRequest {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for FSItemSetAttributesRequest {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for FSItemSetAttributesRequest {}
);

impl FSItemSetAttributesRequest {
    extern_methods!(
        /// The attributes successfully used by the file system.
        ///
        /// This property is a bit field in Objective-C and an
        /// <doc
        /// ://com.apple.documentation/documentation/Swift/OptionSet> in Swift.
        #[unsafe(method(consumedAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn consumedAttributes(&self) -> FSItemAttribute;

        /// Setter for [`consumedAttributes`][Self::consumedAttributes].
        #[unsafe(method(setConsumedAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setConsumedAttributes(&self, consumed_attributes: FSItemAttribute);

        /// A method that indicates whether the file system used the given attribute.
        ///
        /// - Parameter attribute: The ``FSItemAttribute`` to check.
        #[unsafe(method(wasAttributeConsumed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn wasAttributeConsumed(&self, attribute: FSItemAttribute) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl FSItemSetAttributesRequest {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// A request to get attributes from an item.
    ///
    /// 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.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsitemgetattributesrequest?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct FSItemGetAttributesRequest;
);

extern_conformance!(
    unsafe impl NSCoding for FSItemGetAttributesRequest {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for FSItemGetAttributesRequest {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for FSItemGetAttributesRequest {}
);

impl FSItemGetAttributesRequest {
    extern_methods!(
        /// The attributes requested by the request.
        ///
        /// This property is a bit field in Objective-C and an
        /// <doc
        /// ://com.apple.documentation/documentation/Swift/OptionSet> in Swift.
        #[unsafe(method(wantedAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn wantedAttributes(&self) -> FSItemAttribute;

        /// Setter for [`wantedAttributes`][Self::wantedAttributes].
        #[unsafe(method(setWantedAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setWantedAttributes(&self, wanted_attributes: FSItemAttribute);

        /// A method that indicates whether the request wants given attribute.
        ///
        /// - Parameter attribute: The ``FSItemAttribute`` to check.
        #[unsafe(method(isAttributeWanted:))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAttributeWanted(&self, attribute: FSItemAttribute) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl FSItemGetAttributesRequest {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}