FSVolumePreallocateOperations

Trait FSVolumePreallocateOperations 

Source
pub unsafe trait FSVolumePreallocateOperations: NSObjectProtocol {
    // Provided methods
    unsafe fn isPreallocateInhibited(&self) -> bool
       where Self: Sized + Message { ... }
    unsafe fn setPreallocateInhibited(&self, preallocate_inhibited: bool)
       where Self: Sized + Message { ... }
    unsafe fn preallocateSpaceForItem_atOffset_length_flags_replyHandler(
        &self,
        item: &FSItem,
        offset: off_t,
        length: usize,
        flags: FSPreallocateFlags,
        reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
    )
       where Self: Sized + Message { ... }
}
Available on crate feature FSVolume only.
Expand description

Methods and properties implemented by volumes that want to offer preallocation functions.

A preallocation operation allocates space for a file without writing to it yet. A file system may use reallocation to avoid performing space allocation while in the midst of I/O; this strategy improves performance. Also, if the expected I/O pattern is many small writes, preallocating contiguous chunks may prevent fragmenting the file system. This process can improve performance later.

In a kernel-based file system, you typically preallocate space with the VNOP_ALLOCATE operation, called from fcntl(F_PREALLOCATE).

See also Apple’s documentation

Provided Methods§

Source

unsafe fn isPreallocateInhibited(&self) -> bool
where Self: Sized + Message,

A Boolean value that instructs FSKit not to call this protocol’s methods, even if the volume conforms to it.

FSKit reads this value after the file system replies to the loadResource message. Changing the returned value during the runtime of the volume has no effect.

Source

unsafe fn setPreallocateInhibited(&self, preallocate_inhibited: bool)
where Self: Sized + Message,

Source

unsafe fn preallocateSpaceForItem_atOffset_length_flags_replyHandler( &self, item: &FSItem, offset: off_t, length: usize, flags: FSPreallocateFlags, reply: &DynBlock<dyn Fn(usize, *mut NSError)>, )
where Self: Sized + Message,

Available on crate features FSItem and block2 and libc only.

Prealocates disk space for the given item.

  • Parameters:
  • item: The item for which to preallocate space.
  • offset: The offset from which to allocate.
  • length: The length of the space in bytes.
  • flags: Flags that affect the preallocation behavior.
  • reply: A block or closure to indicate success or failure. If preallocation succeeds, pass the amount of bytes allocated and a nil error. If preallocation fails, pass the relevant error as the second parameter; FSKit ignores any byte count in this case. For an async Swift implementation, there’s no reply handler; simply return the allocated byte count or throw an error.

Trait Implementations§

Source§

impl ProtocolType for dyn FSVolumePreallocateOperations

Source§

const NAME: &'static str = "FSVolumePreallocateOperations"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn FSVolumePreallocateOperations

Implementations on Foreign Types§

Source§

impl<T> FSVolumePreallocateOperations for ProtocolObject<T>

Implementors§