objc2_fs_kit/generated/FSResource.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 type that represents the recognition and usability of a probed resource.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsmatchresult?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct FSMatchResult(pub NSInteger);
17impl FSMatchResult {
18 /// The probe doesn't recognize the resource.
19 ///
20 /// This match result is appropriate when the file system module determines that the resource uses a completely different format.
21 #[doc(alias = "FSMatchResultNotRecognized")]
22 pub const NotRecognized: Self = Self(0);
23 /// The probe recognizes the resource but can't use it.
24 ///
25 /// This match result is appropriate when the file system module identifies the resource's format but can't use it. For example, if the resource uses a newer version than the module supports, the module can name the resource but can't safely do anything with it.
26 #[doc(alias = "FSMatchResultRecognized")]
27 pub const Recognized: Self = Self(1);
28 /// The probe recognizes the resource and is ready to use it, but only in a limited capacity.
29 ///
30 /// This match result is appropriate when the file system module identifies the resource's format but also identifies incompatibilities. For example, if the module determines the resource uses new features that the module doesn't support, the module may only offer read-only access.
31 #[doc(alias = "FSMatchResultUsableButLimited")]
32 pub const UsableButLimited: Self = Self(2);
33 /// The probe recognizes the resource and is ready to use it.
34 #[doc(alias = "FSMatchResultUsable")]
35 pub const Usable: Self = Self(3);
36}
37
38unsafe impl Encode for FSMatchResult {
39 const ENCODING: Encoding = NSInteger::ENCODING;
40}
41
42unsafe impl RefEncode for FSMatchResult {
43 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46extern_class!(
47 /// An abstract resource a file system uses to provide data for a volume.
48 ///
49 /// `FSResource` is a base class to represent the various possible sources of data for a file system.
50 /// These range from dedicated storage devices like hard drives and flash storage to network connections, and beyond.
51 /// Subclasses define behavior specific to a given kind of resource, such as ``FSBlockDeviceResource-c.class`` for disk partition (IOMedia) file systems.
52 /// These file systems are typical disk file systems such as HFS, APFS, ExFAT, ext2fs, or NTFS.
53 ///
54 /// A resource's type also determines its life cycle.
55 /// Resources based on block storage devices come into being when the system probes the media underlying the volumes and container.
56 /// Other kinds of resources, like those based on URLs, might have different life cycles.
57 /// For example, a resource based on a `file://` URL might iniitalize when a person uses the "Connect to server" command in the macOS Finder.
58 ///
59 /// ### Proxying resources
60 ///
61 /// Some resources, like ``FSBlockDeviceResource``, come in proxy and non-proxy variants.
62 /// This addresses the issue that opening an external device like `/dev/disk2s1` requires an entitlement.
63 /// Proxy resources allow unentitled clients of FSKit to describe which disk an ``FSBlockDeviceResource`` should represent.
64 /// This allows, for example, the `mount(8)` tool to mount FSKit file systems on block devices when run as root.
65 /// The tool uses a proxy when executing a command like `mount -t ffs /dev/disk2s1 /some/path`, which prevents leaking privileged resource access.
66 ///
67 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsresource?language=objc)
68 #[unsafe(super(NSObject))]
69 #[derive(Debug, PartialEq, Eq, Hash)]
70 pub struct FSResource;
71);
72
73extern_conformance!(
74 unsafe impl NSCoding for FSResource {}
75);
76
77extern_conformance!(
78 unsafe impl NSObjectProtocol for FSResource {}
79);
80
81extern_conformance!(
82 unsafe impl NSSecureCoding for FSResource {}
83);
84
85impl FSResource {
86 extern_methods!(
87 /// A Boolean value that indicates whether the resource is revoked.
88 ///
89 /// If this is a proxy resource, the value of this property is always `true` (Swift) or `YES` (Objective-C).
90 #[unsafe(method(isRevoked))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn isRevoked(&self) -> bool;
93
94 #[unsafe(method(init))]
95 #[unsafe(method_family = init)]
96 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
97
98 /// Creates a proxy object of this resource.
99 ///
100 /// If you create a proxy from a proxy resource, this method returns a copy of the proxy.
101 #[unsafe(method(makeProxy))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn makeProxy(&self) -> Retained<Self>;
104
105 /// Revokes the resource.
106 ///
107 /// This method works by stripping away any underlying privileges associated with the resource.
108 /// This effectively disconnects this object from its underlying resource.
109 #[unsafe(method(revoke))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn revoke(&self);
112 );
113}
114
115/// Methods declared on superclass `NSObject`.
116impl FSResource {
117 extern_methods!(
118 #[unsafe(method(new))]
119 #[unsafe(method_family = new)]
120 pub unsafe fn new() -> Retained<Self>;
121 );
122}
123
124extern_class!(
125 /// A range that describes contiguous metadata segments on disk.
126 ///
127 /// This type represents a range that begins at `startOffset` and ends at `startOffset + segmentLength * segmentCount`.
128 /// Each segment in the range represents a single block in the resource's buffer cache.
129 ///
130 /// For example, given an `FSMetadataRange` with the following properties:
131 ///
132 /// * `startOffset = 0`
133 /// * `segmentLength = 512`
134 /// * `segmentCount = 8`
135 ///
136 /// The range represents eight segments: from 0 to 511, then from 512 to 1023, and so on until a final segment of 3584 to 4095.
137 ///
138 /// Ensure that each metadata segment represents a range that's already present in the resource's buffer cache.
139 /// Similarly, ensure that each segment's offset and length matches the offset and length of the corresponding block in the buffer cache.
140 ///
141 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsmetadatarange?language=objc)
142 #[unsafe(super(NSObject))]
143 #[derive(Debug, PartialEq, Eq, Hash)]
144 pub struct FSMetadataRange;
145);
146
147extern_conformance!(
148 unsafe impl NSObjectProtocol for FSMetadataRange {}
149);
150
151impl FSMetadataRange {
152 extern_methods!(
153 #[cfg(feature = "libc")]
154 /// The start offset of the range in bytes.
155 ///
156 /// Ensure this value is a multiple of the corresponding resource's ``FSBlockDeviceResource-c.class/blockSize``.
157 #[unsafe(method(startOffset))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn startOffset(&self) -> libc::off_t;
160
161 /// The segment length in bytes.
162 ///
163 /// Ensure this value is a multiple of the corresponding resource's ``FSBlockDeviceResource-c.class/blockSize``.
164 #[unsafe(method(segmentLength))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn segmentLength(&self) -> u64;
167
168 /// The number of segments in the range.
169 #[unsafe(method(segmentCount))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn segmentCount(&self) -> u64;
172
173 #[cfg(feature = "libc")]
174 /// Initializes a metadata range with the given properties.
175 ///
176 /// - Parameters:
177 /// - startOffset: The start offset of the range in bytes. Ensure this value is a multiple of the corresponding resource's ``FSBlockDeviceResource-c.class/blockSize``.
178 /// - segmentLength: The segment length in bytes. Ensure this value is a multiple of the corresponding resource's ``FSBlockDeviceResource-c.class/blockSize``.
179 /// - segmentCount: The number of segments in the range.
180 #[unsafe(method(initWithOffset:segmentLength:segmentCount:))]
181 #[unsafe(method_family = init)]
182 pub unsafe fn initWithOffset_segmentLength_segmentCount(
183 this: Allocated<Self>,
184 start_offset: libc::off_t,
185 segment_length: u64,
186 segment_count: u64,
187 ) -> Retained<Self>;
188
189 #[cfg(feature = "libc")]
190 /// Creates a metadata range with the given properties.
191 /// - Parameters:
192 /// - startOffset: The start offset of the range in bytes. Ensure this value is a multiple of the corresponding resource's ``FSBlockDeviceResource-c.class/blockSize``.
193 /// - segmentLength: The segment length in bytes. Ensure this value is a multiple of the corresponding resource's ``FSBlockDeviceResource-c.class/blockSize``.
194 /// - segmentCount: The number of segments in the range.
195 #[unsafe(method(rangeWithOffset:segmentLength:segmentCount:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn rangeWithOffset_segmentLength_segmentCount(
198 start_offset: libc::off_t,
199 segment_length: u64,
200 segment_count: u64,
201 ) -> Retained<Self>;
202
203 #[unsafe(method(init))]
204 #[unsafe(method_family = init)]
205 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
206 );
207}
208
209/// Methods declared on superclass `NSObject`.
210impl FSMetadataRange {
211 extern_methods!(
212 #[unsafe(method(new))]
213 #[unsafe(method_family = new)]
214 pub unsafe fn new() -> Retained<Self>;
215 );
216}
217
218extern_class!(
219 /// A resource that represents a block storage disk partition.
220 ///
221 /// A `FSBlockDeviceResource` can exist in either a proxied or nonproxied version.
222 /// Only the `fskitd` daemon creates "real" (nonproxied) instances of this class.
223 /// Client applications and daemons create proxy objects for requests, and `fskitd` opens the underlying device during the processing of the request.
224 ///
225 /// This class wraps a file descriptor for a disk device or partition.
226 /// Its fundamental identifier is the BSD disk name (``bsdName``) for the underlying IOMedia object.
227 /// However, ``FSBlockDeviceResource-c.class`` doesn't expose the underlying file descriptor.
228 /// Instead, it provides accessor methods that can read from and write to the partition, either directly or using the kernel buffer cache.
229 ///
230 /// When you use a `FSBlockDeviceResource`, your file system implementation also conforms to a maintenance operation protocol.
231 /// These protocols add support for checking, repairing, and optionally formatting file systems.
232 /// The system doesn't mount block device file systems until they pass a file system check.
233 /// For an ``FSUnaryFileSystem`` that uses `FSBlockDeviceResource`, conform to `FSManageableResourceMaintenanceOperations`.
234 ///
235 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsblockdeviceresource?language=objc)
236 #[unsafe(super(FSResource, NSObject))]
237 #[derive(Debug, PartialEq, Eq, Hash)]
238 pub struct FSBlockDeviceResource;
239);
240
241extern_conformance!(
242 unsafe impl NSCoding for FSBlockDeviceResource {}
243);
244
245extern_conformance!(
246 unsafe impl NSObjectProtocol for FSBlockDeviceResource {}
247);
248
249extern_conformance!(
250 unsafe impl NSSecureCoding for FSBlockDeviceResource {}
251);
252
253impl FSBlockDeviceResource {
254 extern_methods!(
255 /// The device name of the resource.
256 #[unsafe(method(BSDName))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn BSDName(&self) -> Retained<NSString>;
259
260 /// A Boolean property that indicates whether the resource can write data to the device.
261 #[unsafe(method(isWritable))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn isWritable(&self) -> bool;
264
265 /// The logical block size, the size of data blocks used by the file system.
266 ///
267 /// This is equivalent to the `DKIOCGETBLOCKSIZE` device parameter.
268 #[unsafe(method(blockSize))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn blockSize(&self) -> u64;
271
272 /// The block count on this resource.
273 #[unsafe(method(blockCount))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn blockCount(&self) -> u64;
276
277 /// The sector size of the device.
278 ///
279 /// This is equivalent to the `DKIOCGETPHYSICALBLOCKSIZE` device parameter.
280 #[unsafe(method(physicalBlockSize))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn physicalBlockSize(&self) -> u64;
283
284 #[unsafe(method(init))]
285 #[unsafe(method_family = init)]
286 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
287
288 #[cfg(all(feature = "block2", feature = "libc"))]
289 /// Reads data from the resource into a buffer and executes a block afterwards.
290 ///
291 /// For the read to succeed, requests must conform to any transfer requirements of the underlying resource.
292 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
293 ///
294 /// - Parameters:
295 /// - buffer: A buffer to receive the data.
296 /// - offset: The offset into the resource from which to start reading.
297 /// - length: A maximum number of bytes to read. The completion handler receives a parameter with the actual number of bytes read.
298 /// - completionHandler: A block that executes after the read operation completes. If successful, the first parameter contains the number of bytes actually read. In the case of an error, the second parameter contains a non-`nil` error. This value is `EFAULT` if `buffer` is `NULL`, or `errno` if reading from the resource failed.
299 #[unsafe(method(readInto:startingAt:length:completionHandler:))]
300 #[unsafe(method_family = none)]
301 pub unsafe fn readInto_startingAt_length_completionHandler(
302 &self,
303 buffer: NonNull<c_void>,
304 offset: libc::off_t,
305 length: usize,
306 completion_handler: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
307 );
308
309 #[cfg(all(feature = "block2", feature = "libc"))]
310 /// Writes data from from a buffer to the resource and executes a block afterwards.
311 ///
312 /// For the write to succeed, requests must conform to any transfer requirements of the underlying resource.
313 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
314 ///
315 /// - Parameters:
316 /// - buffer: A buffer to provide the data.
317 /// - offset: The offset into the resource from which to start writing.
318 /// - length: A maximum number of bytes to write. The completion handler receives a parameter with the actual number of bytes write.
319 /// - completionHandler: A block that executes after the write operation completes. If successful, the first parameter contains the number of bytes actually written. In the case of an error, the second parameter contains a non-`nil` error. This value is `EFAULT` if `buffer` is `NULL`, or `errno` if writing to the resource failed.
320 #[unsafe(method(writeFrom:startingAt:length:completionHandler:))]
321 #[unsafe(method_family = none)]
322 pub unsafe fn writeFrom_startingAt_length_completionHandler(
323 &self,
324 buffer: NonNull<c_void>,
325 offset: libc::off_t,
326 length: usize,
327 completion_handler: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
328 );
329
330 #[cfg(feature = "libc")]
331 /// Synchronously reads file system metadata from the resource into a buffer.
332 ///
333 /// This method provides access to the Kernel Buffer Cache, which is the primary system cache for file system metadata.
334 /// Unlike equivalent kernel APIs, this method doesn't hold any kernel-level claim to the underlying buffers.
335 ///
336 /// For the read to succeed, requests must conform to any transfer requirements of the underlying resource.
337 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
338 ///
339 /// This method doesn't support partial reading of metadata.
340 ///
341 /// - Parameters:
342 /// - buffer: A buffer to receive the data.
343 /// - offset: The offset into the resource from which to start reading.
344 /// - length: The number of bytes to read.
345 /// - error: On return, any error encountered while reading data, or `nil` if no error occurred.
346 ///
347 /// - Returns: A Boolean value indicating whether the metadata read succeeded.
348 #[unsafe(method(metadataReadInto:startingAt:length:error:_))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn metadataReadInto_startingAt_length_error(
351 &self,
352 buffer: NonNull<c_void>,
353 offset: libc::off_t,
354 length: usize,
355 ) -> Result<(), Retained<NSError>>;
356
357 #[cfg(feature = "libc")]
358 /// Synchronously writes file system metadata from a buffer to the resource.
359 ///
360 /// This method provides access to the Kernel Buffer Cache, which is the primary system cache for file system metadata.
361 /// Unlike equivalent kernel APIs, this method doesn't hold any kernel-level claim to the underlying buffers.
362 ///
363 /// For the write to succeed, requests must conform to any transfer requirements of the underlying resource.
364 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
365 ///
366 /// This method doesn't support partial writing of metadata.
367 ///
368 /// - Parameters:
369 /// - buffer: A buffer to provide the data.
370 /// - offset: The offset into the resource from which to start writing.
371 /// - length: The number of bytes to writing.
372 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred.
373 ///
374 /// - Returns: A Boolean value indicating whether the metadata write succeeded.
375 #[unsafe(method(metadataWriteFrom:startingAt:length:error:_))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn metadataWriteFrom_startingAt_length_error(
378 &self,
379 buffer: NonNull<c_void>,
380 offset: libc::off_t,
381 length: usize,
382 ) -> Result<(), Retained<NSError>>;
383
384 #[cfg(feature = "libc")]
385 /// Writes file system metadata from a buffer to a cache, prior to flushing it to the resource.
386 ///
387 /// This method provides access to the Kernel Buffer Cache, which is the primary system cache for file system metadata.
388 /// Unlike equivalent kernel APIs, this method doesn't hold any kernel-level claim to the underlying buffers.
389 ///
390 /// This method is equivalent to ``metadataWriteFrom:startingAt:length:error:``, except that it writes data to the resource's buffer cache instead of writing to disk immediately.
391 /// To ensure writing data to disk, the client must flush the metadata by calling ``metadataFlushWithError:`` or ``asynchronousMetadataFlushWithError:``.
392 ///
393 /// Delayed writes offer two significant advantages:
394 /// - Delayed writes are more performant, since the file system can avoid waiting for the actual write, reducing I/O latency.
395 /// - When writing to a specific range repeatedly, delayed writes allow the file system to flush data to the disk only when necessary. This reduces disk usage by eliminating unnecessary writes.
396 ///
397 /// For the write to succeed, requests must conform to any transfer requirements of the underlying resource.
398 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
399 ///
400 /// This method doesn't support partial writing of metadata.
401 ///
402 /// - Parameters:
403 /// - buffer: A buffer to provide the data.
404 /// - offset: The offset into the resource from which to start writing.
405 /// - length: The number of bytes to writing.
406 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred.
407 ///
408 /// - Returns: A Boolean value indicating whether the metadata write succeeded.
409 #[unsafe(method(delayedMetadataWriteFrom:startingAt:length:error:_))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn delayedMetadataWriteFrom_startingAt_length_error(
412 &self,
413 buffer: NonNull<c_void>,
414 offset: libc::off_t,
415 length: usize,
416 ) -> Result<(), Retained<NSError>>;
417
418 /// Synchronously flushes the resource's buffer cache.
419 ///
420 /// This method flushes data previously written with ``delayedMetadataWriteFrom:startingAt:length:error:`` to the resource.
421 ///
422 /// - Parameter error: On return, any error encountered while writing data, or `nil` if no error occurred.
423 ///
424 /// - Returns: A Boolean value indicating whether the metadata flush succeeded.
425 #[unsafe(method(metadataFlushWithError:_))]
426 #[unsafe(method_family = none)]
427 pub unsafe fn metadataFlushWithError(&self) -> Result<(), Retained<NSError>>;
428
429 /// Asynchronously flushes the resource's buffer cache.
430 ///
431 /// This method schedules a flush of data previously written with ``delayedMetadataWriteFrom:startingAt:length:error:`` to the resource and returns immediately without blocking.
432 /// This method doesn't wait to check the flush's status.
433 /// If an error prevents the flush from being scheduled, the error is indicated by the in-out `error` parameter.
434 ///
435 /// - Parameter error: On return, any error encountered while writing data, or `nil` if no error occurred.
436 ///
437 /// - Returns: A Boolean value indicating whether scheduling the metadata flush succeeded.
438 #[unsafe(method(asynchronousMetadataFlushWithError:_))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn asynchronousMetadataFlushWithError(&self) -> Result<(), Retained<NSError>>;
441
442 /// Clears the given ranges within the buffer cache.
443 ///
444 /// This method clears the specified ranges in the resource’s buffer cache by writing zeroes into them.
445 ///
446 /// - Parameters:
447 /// - rangesToClear: The metadata ranges to clear.
448 /// - withDelayedWrites: A Boolean value that determines whether to perform the clear operation with delayed writes. The delay works in the same manner as ``delayedMetadataWriteFrom:startingAt:length:error:``. When using delayed writes, the client can flush the metadata with ``metadataFlushWithError:`` or ``asynchronousMetadataFlushWithError:``. The system also flushes stale data in the buffer cache periodically.
449 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred. This value is `EINVAL` if `rangesToClear` is invalid.
450 ///
451 /// - Returns: A Boolean value indicating whether clearing the metadata succeeded.
452 #[unsafe(method(metadataClear:withDelayedWrites:error:_))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn metadataClear_withDelayedWrites_error(
455 &self,
456 ranges_to_clear: &NSArray<FSMetadataRange>,
457 with_delayed_writes: bool,
458 ) -> Result<(), Retained<NSError>>;
459
460 /// Synchronously purges the given ranges from the buffer cache.
461 ///
462 /// This method removes the given ranges from the resource's buffer cache.
463 /// This process drops any dirty data in the cache, preventing the data from reaching the device.
464 ///
465 /// - Parameters:
466 /// - rangesToPurge: The metadata ranges to purge.
467 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred. This value is `EINVAL` if `rangesToPurge` is invalid.
468 ///
469 /// - Returns: A Boolean value indicating whether purging the metadata succeeded.
470 #[unsafe(method(metadataPurge:error:_))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn metadataPurge_error(
473 &self,
474 ranges_to_purge: &NSArray<FSMetadataRange>,
475 ) -> Result<(), Retained<NSError>>;
476 );
477}
478
479/// Methods declared on superclass `NSObject`.
480impl FSBlockDeviceResource {
481 extern_methods!(
482 #[unsafe(method(new))]
483 #[unsafe(method_family = new)]
484 pub unsafe fn new() -> Retained<Self>;
485 );
486}
487
488extern_protocol!(
489 /// Maintenance operations for a file system's resources.
490 ///
491 /// This protocol includes operations to check and format a resource for an ``FSUnaryFileSystem``.
492 /// Conform to this protocol if you implement a ``FSUnaryFileSystem`` that uses an ``FSBlockDeviceResource-c.class``.
493 ///
494 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsmanageableresourcemaintenanceoperations?language=objc)
495 pub unsafe trait FSManageableResourceMaintenanceOperations: NSObjectProtocol {
496 #[cfg(all(feature = "FSTask", feature = "FSTaskOptions"))]
497 /// Starts checking the file system with the given options.
498 ///
499 /// - Parameters:
500 /// - task: A task object you use to communicate back to the client.
501 /// - options: Options for performing the check.
502 /// - error: In Objective-C, a pointer to an
503 /// <doc
504 /// ://com.apple.documentation/documentation/Foundation/NSError>. Populate this with any error that occurs when starting the check. In Swift, throw an
505 /// <doc
506 /// ://com.apple.documentation/documentation/Swift/Error> instead.
507 /// - Returns: An
508 /// <doc
509 /// ://com.apple.documentation/documentation/Foundation/NSProgress> object that you use to update progress as the check operation progresses. Return `nil` if starting the file system check encountered an error.
510 #[unsafe(method(startCheckWithTask:options:error:_))]
511 #[unsafe(method_family = none)]
512 unsafe fn startCheckWithTask_options_error(
513 &self,
514 task: &FSTask,
515 options: &FSTaskOptions,
516 ) -> Result<Retained<NSProgress>, Retained<NSError>>;
517
518 #[cfg(all(feature = "FSTask", feature = "FSTaskOptions"))]
519 /// Starts formatting the file system with the given options.
520 ///
521 /// - Parameters:
522 /// - task: A task object you use to communicate back to the client.
523 /// - options: Options for performing the format.
524 /// - error: In Objective-C, a pointer to an
525 /// <doc
526 /// ://com.apple.documentation/documentation/Foundation/NSError>. Populate this with any error that occurs when starting the format. In Swift, throw an
527 /// <doc
528 /// ://com.apple.documentation/documentation/Swift/Error> instead.
529 /// - Returns: An
530 /// <doc
531 /// ://com.apple.documentation/documentation/Foundation/NSProgress> object that you use to update progress as the format operation progresses. Return `nil` if starting to format the file system encountered an error.
532 #[unsafe(method(startFormatWithTask:options:error:_))]
533 #[unsafe(method_family = none)]
534 unsafe fn startFormatWithTask_options_error(
535 &self,
536 task: &FSTask,
537 options: &FSTaskOptions,
538 ) -> Result<Retained<NSProgress>, Retained<NSError>>;
539 }
540);
541
542extern_class!(
543 /// An object that represents the results of a specific probe.
544 ///
545 /// For any ``result`` value other than ``FSMatchResult/notRecognized``, ensure the ``name`` and ``containerID`` values are non-`nil`.
546 /// When a container or volume format doesn't use a name, return an empty string.
547 /// Also use an empty string in the case in which the format supports a name, but the value isn't set yet.
548 ///
549 /// Some container or volume formats may lack a durable UUID on which to base a container identifier.
550 /// This situation is only valid for unary file systems.
551 /// In such a case, return a random UUID.
552 ///
553 /// With a block device resource, a probe operation may successfully get a result but encounter an error reading the name or UUID.
554 /// If this happens, use whatever information is available, and provide an empty string or random UUID for the name or container ID, respectively.
555 ///
556 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsproberesult?language=objc)
557 #[unsafe(super(NSObject))]
558 #[derive(Debug, PartialEq, Eq, Hash)]
559 pub struct FSProbeResult;
560);
561
562extern_conformance!(
563 unsafe impl NSCoding for FSProbeResult {}
564);
565
566extern_conformance!(
567 unsafe impl NSObjectProtocol for FSProbeResult {}
568);
569
570extern_conformance!(
571 unsafe impl NSSecureCoding for FSProbeResult {}
572);
573
574impl FSProbeResult {
575 extern_methods!(
576 /// The match result, representing the recognition and usability of a probed resource.
577 #[unsafe(method(result))]
578 #[unsafe(method_family = none)]
579 pub unsafe fn result(&self) -> FSMatchResult;
580
581 /// The resource name, as found during the probe operation.
582 ///
583 /// This value is non-`nil` unless the ``FSProbeResult/result`` is ``FSMatchResult/notRecognized`.
584 /// For formats that lack a name, this value may be an empty string.
585 /// This value can also be an empty string if the format supports a name, but the value isn't set yet.
586 #[unsafe(method(name))]
587 #[unsafe(method_family = none)]
588 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
589
590 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
591 /// The container identifier, as found during the probe operation.
592 ///
593 /// This value is non-`nil` unless the ``FSProbeResult/result`` is ``FSMatchResult/notRecognized`.
594 /// For formats that lack a durable UUID on which to base a container identifier --- which is only legal for a ``FSUnaryFileSystem`` --- this value may be a random UUID.
595 #[unsafe(method(containerID))]
596 #[unsafe(method_family = none)]
597 pub unsafe fn containerID(&self) -> Option<Retained<FSContainerIdentifier>>;
598
599 #[unsafe(method(init))]
600 #[unsafe(method_family = init)]
601 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
602
603 /// A probe result for an unrecognized file system.
604 ///
605 /// An unrecognized probe result contains `nil` for its ``FSProbeResult/name`` and ``FSProbeResult/containerID`` properties.
606 #[unsafe(method(notRecognizedProbeResult))]
607 #[unsafe(method_family = none)]
608 pub unsafe fn notRecognizedProbeResult() -> Retained<FSProbeResult>;
609
610 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
611 /// Creates a probe result for a recognized file system.
612 ///
613 /// - Parameters:
614 /// - name: The resource name, as found during the probe operation. If the file system doesn't support names, or is awaiting naming, use an empty string.
615 /// - containerID: The container identifier, as found during the probe operation. If the file system doesn't support durable identifiers, use a random UUID.
616 #[unsafe(method(recognizedProbeResultWithName:containerID:))]
617 #[unsafe(method_family = none)]
618 pub unsafe fn recognizedProbeResultWithName_containerID(
619 name: &NSString,
620 container_id: &FSContainerIdentifier,
621 ) -> Retained<Self>;
622
623 /// A probe result for a recognized file system that is usable, but with limited capabilities.
624 ///
625 /// This kind of probe result lacks the ``FSProbeResult/name``, ``FSProbeResult/containerID``, or both.
626 /// Don't return this result from probing a resource that isn't limited.
627 #[unsafe(method(usableButLimitedProbeResult))]
628 #[unsafe(method_family = none)]
629 pub unsafe fn usableButLimitedProbeResult() -> Retained<FSProbeResult>;
630
631 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
632 /// Creates a probe result for a recognized file system that is usable, but with limited capabilities.
633 ///
634 /// - Parameters:
635 /// - name: The resource name, as found during the probe operation. If the file system doesn't support names, or is awaiting naming, use an empty string.
636 /// - containerID: The container identifier, as found during the probe operation. If the file system doesn't support durable identifiers, use a random UUID.
637 #[unsafe(method(usableButLimitedProbeResultWithName:containerID:))]
638 #[unsafe(method_family = none)]
639 pub unsafe fn usableButLimitedProbeResultWithName_containerID(
640 name: &NSString,
641 container_id: &FSContainerIdentifier,
642 ) -> Retained<Self>;
643
644 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
645 /// Creates a probe result for a recognized and usable file system.
646 ///
647 /// - Parameters:
648 /// - name: The resource name, as found during the probe operation. If the file system doesn't support names, or is awaiting naming, use an empty string.
649 /// - containerID: The container identifier, as found during the probe operation. If the file system doesn't support durable identifiers, use a random UUID.
650 #[unsafe(method(usableProbeResultWithName:containerID:))]
651 #[unsafe(method_family = none)]
652 pub unsafe fn usableProbeResultWithName_containerID(
653 name: &NSString,
654 container_id: &FSContainerIdentifier,
655 ) -> Retained<Self>;
656 );
657}
658
659/// Methods declared on superclass `NSObject`.
660impl FSProbeResult {
661 extern_methods!(
662 #[unsafe(method(new))]
663 #[unsafe(method_family = new)]
664 pub unsafe fn new() -> Retained<Self>;
665 );
666}