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 ///
300 /// # Safety
301 ///
302 /// `buffer` must be a valid pointer.
303 #[unsafe(method(readInto:startingAt:length:completionHandler:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn readInto_startingAt_length_completionHandler(
306 &self,
307 buffer: NonNull<c_void>,
308 offset: libc::off_t,
309 length: usize,
310 completion_handler: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
311 );
312
313 #[cfg(feature = "libc")]
314 /// Synchronously reads data from the resource into a buffer.
315 ///
316 /// This is a synchronous version of ``readInto:startingAt:length:completionHandler:``.
317 ///
318 /// > Note: In some cases, this method performs a partial read. In this case, the return value is shorter than the requested length, and the `error` is set to `nil`.
319 ///
320 /// - Parameters:
321 /// - buffer: A buffer to receive the data.
322 /// - offset: The offset into the resource from which to start reading.
323 /// - length: A maximum number of bytes to read. The method's return value contains the actual number of bytes read.
324 /// - error: On return, any error encountered while reading data, or `nil` if no error occurred.
325 ///
326 /// - Returns: The actual number of bytes read.
327 ///
328 /// # Safety
329 ///
330 /// `buffer` must be a valid pointer.
331 #[unsafe(method(readInto:startingAt:length:error:))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn readInto_startingAt_length_error(
334 &self,
335 buffer: NonNull<c_void>,
336 offset: libc::off_t,
337 length: usize,
338 error: Option<&mut Option<Retained<NSError>>>,
339 ) -> usize;
340
341 #[cfg(all(feature = "block2", feature = "libc"))]
342 /// Writes data from from a buffer to the resource and executes a block afterwards.
343 ///
344 /// For the write to succeed, requests must conform to any transfer requirements of the underlying resource.
345 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
346 ///
347 /// - Parameters:
348 /// - buffer: A buffer to provide the data.
349 /// - offset: The offset into the resource from which to start writing.
350 /// - length: A maximum number of bytes to write. The completion handler receives a parameter with the actual number of bytes write.
351 /// - 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.
352 ///
353 /// # Safety
354 ///
355 /// `buffer` must be a valid pointer.
356 #[unsafe(method(writeFrom:startingAt:length:completionHandler:))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn writeFrom_startingAt_length_completionHandler(
359 &self,
360 buffer: NonNull<c_void>,
361 offset: libc::off_t,
362 length: usize,
363 completion_handler: &block2::DynBlock<dyn Fn(usize, *mut NSError)>,
364 );
365
366 #[cfg(feature = "libc")]
367 /// Synchronously writes data from from a buffer to the resource and executes a block afterwards.
368 ///
369 /// This is a synchronous version of ``writeFrom:startingAt:length:completionHandler:``.
370 ///
371 /// > Note: In some cases, this method performs a partial write. In this case, the return value is shorter than the requested length, and the `error` is set to `nil`.
372 ///
373 /// - Parameters:
374 /// - buffer: A buffer to provide the data.
375 /// - offset: The offset into the resource from which to start writing.
376 /// - length: A maximum number of bytes to write. The completion handler receives a parameter with the actual number of bytes write.
377 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred.
378 ///
379 /// - Returns: The actual number of bytes written.
380 ///
381 /// # Safety
382 ///
383 /// `buffer` must be a valid pointer.
384 #[unsafe(method(writeFrom:startingAt:length:error:))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn writeFrom_startingAt_length_error(
387 &self,
388 buffer: NonNull<c_void>,
389 offset: libc::off_t,
390 length: usize,
391 error: Option<&mut Option<Retained<NSError>>>,
392 ) -> usize;
393
394 #[cfg(feature = "libc")]
395 /// Synchronously reads file system metadata from the resource into a buffer.
396 ///
397 /// This method provides access to the Kernel Buffer Cache, which is the primary system cache for file system metadata.
398 /// Unlike equivalent kernel APIs, this method doesn't hold any kernel-level claim to the underlying buffers.
399 ///
400 /// For the read to succeed, requests must conform to any transfer requirements of the underlying resource.
401 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
402 ///
403 /// This method doesn't support partial reading of metadata.
404 ///
405 /// - Parameters:
406 /// - buffer: A buffer to receive the data.
407 /// - offset: The offset into the resource from which to start reading.
408 /// - length: The number of bytes to read.
409 /// - error: On return, any error encountered while reading data, or `nil` if no error occurred.
410 ///
411 /// - Returns: A Boolean value indicating whether the metadata read succeeded.
412 ///
413 /// # Safety
414 ///
415 /// `buffer` must be a valid pointer.
416 #[unsafe(method(metadataReadInto:startingAt:length:error:_))]
417 #[unsafe(method_family = none)]
418 pub unsafe fn metadataReadInto_startingAt_length_error(
419 &self,
420 buffer: NonNull<c_void>,
421 offset: libc::off_t,
422 length: usize,
423 ) -> Result<(), Retained<NSError>>;
424
425 #[cfg(feature = "libc")]
426 /// Synchronously writes file system metadata from a buffer to the resource.
427 ///
428 /// This method provides access to the Kernel Buffer Cache, which is the primary system cache for file system metadata.
429 /// Unlike equivalent kernel APIs, this method doesn't hold any kernel-level claim to the underlying buffers.
430 ///
431 /// For the write to succeed, requests must conform to any transfer requirements of the underlying resource.
432 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
433 ///
434 /// This method doesn't support partial writing of metadata.
435 ///
436 /// - Parameters:
437 /// - buffer: A buffer to provide the data.
438 /// - offset: The offset into the resource from which to start writing.
439 /// - length: The number of bytes to writing.
440 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred.
441 ///
442 /// - Returns: A Boolean value indicating whether the metadata write succeeded.
443 ///
444 /// # Safety
445 ///
446 /// `buffer` must be a valid pointer.
447 #[unsafe(method(metadataWriteFrom:startingAt:length:error:_))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn metadataWriteFrom_startingAt_length_error(
450 &self,
451 buffer: NonNull<c_void>,
452 offset: libc::off_t,
453 length: usize,
454 ) -> Result<(), Retained<NSError>>;
455
456 #[cfg(feature = "libc")]
457 /// Writes file system metadata from a buffer to a cache, prior to flushing it to the resource.
458 ///
459 /// This method provides access to the Kernel Buffer Cache, which is the primary system cache for file system metadata.
460 /// Unlike equivalent kernel APIs, this method doesn't hold any kernel-level claim to the underlying buffers.
461 ///
462 /// 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.
463 /// To ensure writing data to disk, the client must flush the metadata by calling ``metadataFlushWithError:`` or ``asynchronousMetadataFlushWithError:``.
464 ///
465 /// Delayed writes offer two significant advantages:
466 /// - Delayed writes are more performant, since the file system can avoid waiting for the actual write, reducing I/O latency.
467 /// - 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.
468 ///
469 /// For the write to succeed, requests must conform to any transfer requirements of the underlying resource.
470 /// Disk drives typically require sector (`physicalBlockSize`) addressed operations of one or more sector-aligned offsets.
471 ///
472 /// This method doesn't support partial writing of metadata.
473 ///
474 /// - Parameters:
475 /// - buffer: A buffer to provide the data.
476 /// - offset: The offset into the resource from which to start writing.
477 /// - length: The number of bytes to writing.
478 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred.
479 ///
480 /// - Returns: A Boolean value indicating whether the metadata write succeeded.
481 ///
482 /// # Safety
483 ///
484 /// `buffer` must be a valid pointer.
485 #[unsafe(method(delayedMetadataWriteFrom:startingAt:length:error:_))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn delayedMetadataWriteFrom_startingAt_length_error(
488 &self,
489 buffer: NonNull<c_void>,
490 offset: libc::off_t,
491 length: usize,
492 ) -> Result<(), Retained<NSError>>;
493
494 /// Synchronously flushes the resource's buffer cache.
495 ///
496 /// This method flushes data previously written with ``delayedMetadataWriteFrom:startingAt:length:error:`` to the resource.
497 ///
498 /// - Parameter error: On return, any error encountered while writing data, or `nil` if no error occurred.
499 ///
500 /// - Returns: A Boolean value indicating whether the metadata flush succeeded.
501 #[unsafe(method(metadataFlushWithError:_))]
502 #[unsafe(method_family = none)]
503 pub unsafe fn metadataFlushWithError(&self) -> Result<(), Retained<NSError>>;
504
505 /// Asynchronously flushes the resource's buffer cache.
506 ///
507 /// This method schedules a flush of data previously written with ``delayedMetadataWriteFrom:startingAt:length:error:`` to the resource and returns immediately without blocking.
508 /// This method doesn't wait to check the flush's status.
509 /// If an error prevents the flush from being scheduled, the error is indicated by the in-out `error` parameter.
510 ///
511 /// - Parameter error: On return, any error encountered while writing data, or `nil` if no error occurred.
512 ///
513 /// - Returns: A Boolean value indicating whether scheduling the metadata flush succeeded.
514 #[unsafe(method(asynchronousMetadataFlushWithError:_))]
515 #[unsafe(method_family = none)]
516 pub unsafe fn asynchronousMetadataFlushWithError(&self) -> Result<(), Retained<NSError>>;
517
518 /// Clears the given ranges within the buffer cache.
519 ///
520 /// This method clears the specified ranges in the resource’s buffer cache by writing zeroes into them.
521 ///
522 /// - Parameters:
523 /// - rangesToClear: The metadata ranges to clear.
524 /// - 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.
525 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred. This value is `EINVAL` if `rangesToClear` is invalid.
526 ///
527 /// - Returns: A Boolean value indicating whether clearing the metadata succeeded.
528 #[unsafe(method(metadataClear:withDelayedWrites:error:_))]
529 #[unsafe(method_family = none)]
530 pub unsafe fn metadataClear_withDelayedWrites_error(
531 &self,
532 ranges_to_clear: &NSArray<FSMetadataRange>,
533 with_delayed_writes: bool,
534 ) -> Result<(), Retained<NSError>>;
535
536 /// Synchronously purges the given ranges from the buffer cache.
537 ///
538 /// This method removes the given ranges from the resource's buffer cache.
539 /// This process drops any dirty data in the cache, preventing the data from reaching the device.
540 ///
541 /// - Parameters:
542 /// - rangesToPurge: The metadata ranges to purge.
543 /// - error: On return, any error encountered while writing data, or `nil` if no error occurred. This value is `EINVAL` if `rangesToPurge` is invalid.
544 ///
545 /// - Returns: A Boolean value indicating whether purging the metadata succeeded.
546 #[unsafe(method(metadataPurge:error:_))]
547 #[unsafe(method_family = none)]
548 pub unsafe fn metadataPurge_error(
549 &self,
550 ranges_to_purge: &NSArray<FSMetadataRange>,
551 ) -> Result<(), Retained<NSError>>;
552 );
553}
554
555/// Methods declared on superclass `NSObject`.
556impl FSBlockDeviceResource {
557 extern_methods!(
558 #[unsafe(method(new))]
559 #[unsafe(method_family = new)]
560 pub unsafe fn new() -> Retained<Self>;
561 );
562}
563
564extern_class!(
565 /// A resource representing an abstract URL
566 ///
567 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsgenericurlresource?language=objc)
568 #[unsafe(super(FSResource, NSObject))]
569 #[derive(Debug, PartialEq, Eq, Hash)]
570 pub struct FSGenericURLResource;
571);
572
573extern_conformance!(
574 unsafe impl NSCoding for FSGenericURLResource {}
575);
576
577extern_conformance!(
578 unsafe impl NSObjectProtocol for FSGenericURLResource {}
579);
580
581extern_conformance!(
582 unsafe impl NSSecureCoding for FSGenericURLResource {}
583);
584
585impl FSGenericURLResource {
586 extern_methods!(
587 #[unsafe(method(url))]
588 #[unsafe(method_family = none)]
589 pub unsafe fn url(&self) -> Retained<NSURL>;
590
591 #[unsafe(method(initWithURL:))]
592 #[unsafe(method_family = init)]
593 pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
594
595 #[unsafe(method(init))]
596 #[unsafe(method_family = init)]
597 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
598 );
599}
600
601/// Methods declared on superclass `NSObject`.
602impl FSGenericURLResource {
603 extern_methods!(
604 #[unsafe(method(new))]
605 #[unsafe(method_family = new)]
606 pub unsafe fn new() -> Retained<Self>;
607 );
608}
609
610extern_class!(
611 /// A resource representing a path
612 ///
613 /// Represents a file path (possibly security scoped URL).
614 ///
615 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fspathurlresource?language=objc)
616 #[unsafe(super(FSResource, NSObject))]
617 #[derive(Debug, PartialEq, Eq, Hash)]
618 pub struct FSPathURLResource;
619);
620
621extern_conformance!(
622 unsafe impl NSCoding for FSPathURLResource {}
623);
624
625extern_conformance!(
626 unsafe impl NSObjectProtocol for FSPathURLResource {}
627);
628
629extern_conformance!(
630 unsafe impl NSSecureCoding for FSPathURLResource {}
631);
632
633impl FSPathURLResource {
634 extern_methods!(
635 #[unsafe(method(url))]
636 #[unsafe(method_family = none)]
637 pub unsafe fn url(&self) -> Retained<NSURL>;
638
639 #[unsafe(method(initWithURL:writable:))]
640 #[unsafe(method_family = init)]
641 pub unsafe fn initWithURL_writable(
642 this: Allocated<Self>,
643 url: &NSURL,
644 writable: bool,
645 ) -> Retained<Self>;
646
647 #[unsafe(method(init))]
648 #[unsafe(method_family = init)]
649 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
650
651 #[unsafe(method(isWritable))]
652 #[unsafe(method_family = none)]
653 pub unsafe fn isWritable(&self) -> bool;
654 );
655}
656
657/// Methods declared on superclass `NSObject`.
658impl FSPathURLResource {
659 extern_methods!(
660 #[unsafe(method(new))]
661 #[unsafe(method_family = new)]
662 pub unsafe fn new() -> Retained<Self>;
663 );
664}
665
666extern_protocol!(
667 /// Maintenance operations for a file system's resources.
668 ///
669 /// This protocol includes operations to check and format a resource for an ``FSUnaryFileSystem``.
670 /// Conform to this protocol if you implement a ``FSUnaryFileSystem`` that uses an ``FSBlockDeviceResource-c.class``.
671 ///
672 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsmanageableresourcemaintenanceoperations?language=objc)
673 pub unsafe trait FSManageableResourceMaintenanceOperations: NSObjectProtocol {
674 #[cfg(all(feature = "FSTask", feature = "FSTaskOptions"))]
675 /// Starts checking the file system with the given options.
676 ///
677 /// - Parameters:
678 /// - task: A task object you use to communicate back to the client.
679 /// - options: Options for performing the check.
680 /// - error: In Objective-C, a pointer to an
681 /// <doc
682 /// ://com.apple.documentation/documentation/Foundation/NSError>. Populate this with any error that occurs when starting the check. In Swift, throw an
683 /// <doc
684 /// ://com.apple.documentation/documentation/Swift/Error> instead.
685 /// - Returns: An
686 /// <doc
687 /// ://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.
688 #[unsafe(method(startCheckWithTask:options:error:_))]
689 #[unsafe(method_family = none)]
690 unsafe fn startCheckWithTask_options_error(
691 &self,
692 task: &FSTask,
693 options: &FSTaskOptions,
694 ) -> Result<Retained<NSProgress>, Retained<NSError>>;
695
696 #[cfg(all(feature = "FSTask", feature = "FSTaskOptions"))]
697 /// Starts formatting the file system with the given options.
698 ///
699 /// - Parameters:
700 /// - task: A task object you use to communicate back to the client.
701 /// - options: Options for performing the format.
702 /// - error: In Objective-C, a pointer to an
703 /// <doc
704 /// ://com.apple.documentation/documentation/Foundation/NSError>. Populate this with any error that occurs when starting the format. In Swift, throw an
705 /// <doc
706 /// ://com.apple.documentation/documentation/Swift/Error> instead.
707 /// - Returns: An
708 /// <doc
709 /// ://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.
710 #[unsafe(method(startFormatWithTask:options:error:_))]
711 #[unsafe(method_family = none)]
712 unsafe fn startFormatWithTask_options_error(
713 &self,
714 task: &FSTask,
715 options: &FSTaskOptions,
716 ) -> Result<Retained<NSProgress>, Retained<NSError>>;
717 }
718);
719
720extern_class!(
721 /// An object that represents the results of a specific probe.
722 ///
723 /// For any ``result`` value other than ``FSMatchResult/notRecognized``, ensure the ``name`` and ``containerID`` values are non-`nil`.
724 /// When a container or volume format doesn't use a name, return an empty string.
725 /// Also use an empty string in the case in which the format supports a name, but the value isn't set yet.
726 ///
727 /// Some container or volume formats may lack a durable UUID on which to base a container identifier.
728 /// This situation is only valid for unary file systems.
729 /// In such a case, return a random UUID.
730 ///
731 /// With a block device resource, a probe operation may successfully get a result but encounter an error reading the name or UUID.
732 /// If this happens, use whatever information is available, and provide an empty string or random UUID for the name or container ID, respectively.
733 ///
734 /// See also [Apple's documentation](https://developer.apple.com/documentation/fskit/fsproberesult?language=objc)
735 #[unsafe(super(NSObject))]
736 #[derive(Debug, PartialEq, Eq, Hash)]
737 pub struct FSProbeResult;
738);
739
740extern_conformance!(
741 unsafe impl NSCoding for FSProbeResult {}
742);
743
744extern_conformance!(
745 unsafe impl NSObjectProtocol for FSProbeResult {}
746);
747
748extern_conformance!(
749 unsafe impl NSSecureCoding for FSProbeResult {}
750);
751
752impl FSProbeResult {
753 extern_methods!(
754 /// The match result, representing the recognition and usability of a probed resource.
755 #[unsafe(method(result))]
756 #[unsafe(method_family = none)]
757 pub unsafe fn result(&self) -> FSMatchResult;
758
759 /// The resource name, as found during the probe operation.
760 ///
761 /// This value is non-`nil` unless the ``FSProbeResult/result`` is ``FSMatchResult/notRecognized`.
762 /// For formats that lack a name, this value may be an empty string.
763 /// This value can also be an empty string if the format supports a name, but the value isn't set yet.
764 #[unsafe(method(name))]
765 #[unsafe(method_family = none)]
766 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
767
768 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
769 /// The container identifier, as found during the probe operation.
770 ///
771 /// This value is non-`nil` unless the ``FSProbeResult/result`` is ``FSMatchResult/notRecognized`.
772 /// 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.
773 #[unsafe(method(containerID))]
774 #[unsafe(method_family = none)]
775 pub unsafe fn containerID(&self) -> Option<Retained<FSContainerIdentifier>>;
776
777 #[unsafe(method(init))]
778 #[unsafe(method_family = init)]
779 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
780
781 /// A probe result for an unrecognized file system.
782 ///
783 /// An unrecognized probe result contains `nil` for its ``FSProbeResult/name`` and ``FSProbeResult/containerID`` properties.
784 #[unsafe(method(notRecognizedProbeResult))]
785 #[unsafe(method_family = none)]
786 pub unsafe fn notRecognizedProbeResult() -> Retained<FSProbeResult>;
787
788 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
789 /// Creates a probe result for a recognized file system.
790 ///
791 /// - Parameters:
792 /// - 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.
793 /// - containerID: The container identifier, as found during the probe operation. If the file system doesn't support durable identifiers, use a random UUID.
794 #[unsafe(method(recognizedProbeResultWithName:containerID:))]
795 #[unsafe(method_family = none)]
796 pub unsafe fn recognizedProbeResultWithName_containerID(
797 name: &NSString,
798 container_id: &FSContainerIdentifier,
799 ) -> Retained<Self>;
800
801 /// A probe result for a recognized file system that is usable, but with limited capabilities.
802 ///
803 /// This kind of probe result lacks the ``FSProbeResult/name``, ``FSProbeResult/containerID``, or both.
804 /// Don't return this result from probing a resource that isn't limited.
805 #[unsafe(method(usableButLimitedProbeResult))]
806 #[unsafe(method_family = none)]
807 pub unsafe fn usableButLimitedProbeResult() -> Retained<FSProbeResult>;
808
809 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
810 /// Creates a probe result for a recognized file system that is usable, but with limited capabilities.
811 ///
812 /// - Parameters:
813 /// - 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.
814 /// - containerID: The container identifier, as found during the probe operation. If the file system doesn't support durable identifiers, use a random UUID.
815 #[unsafe(method(usableButLimitedProbeResultWithName:containerID:))]
816 #[unsafe(method_family = none)]
817 pub unsafe fn usableButLimitedProbeResultWithName_containerID(
818 name: &NSString,
819 container_id: &FSContainerIdentifier,
820 ) -> Retained<Self>;
821
822 #[cfg(all(feature = "FSContainer", feature = "FSEntityIdentifier"))]
823 /// Creates a probe result for a recognized and usable file system.
824 ///
825 /// - Parameters:
826 /// - 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.
827 /// - containerID: The container identifier, as found during the probe operation. If the file system doesn't support durable identifiers, use a random UUID.
828 #[unsafe(method(usableProbeResultWithName:containerID:))]
829 #[unsafe(method_family = none)]
830 pub unsafe fn usableProbeResultWithName_containerID(
831 name: &NSString,
832 container_id: &FSContainerIdentifier,
833 ) -> Retained<Self>;
834 );
835}
836
837/// Methods declared on superclass `NSObject`.
838impl FSProbeResult {
839 extern_methods!(
840 #[unsafe(method(new))]
841 #[unsafe(method_family = new)]
842 pub unsafe fn new() -> Retained<Self>;
843 );
844}