Trait FSVolumeReadWriteOperations

Source
pub unsafe trait FSVolumeReadWriteOperations: NSObjectProtocol {
    // Provided methods
    unsafe fn readFromFile_offset_length_intoBuffer_replyHandler(
        &self,
        item: &FSItem,
        offset: off_t,
        length: usize,
        buffer: &FSMutableFileDataBuffer,
        reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
    )
       where Self: Sized + Message { ... }
    unsafe fn writeContents_toFile_atOffset_replyHandler(
        &self,
        contents: &NSData,
        item: &FSItem,
        offset: off_t,
        reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
    )
       where Self: Sized + Message { ... }
}
Available on crate feature FSVolume only.
Expand description

Methods implemented for read and write operations that deliver data to and from the extension.

Most volumes conform to either this protocol or FSVolumeKernelOffloadedIOOperations. You can conform to both if you need to provide kernel-offloaded I/O only for certain files. In that case, files with the FSItem/Attribute/inhibitKernelOffloadedIO attribute set use this protocol, and those without it use FSVolumeKernelOffloadedIOOperations. A volume that doesn’t conform to either protocol can’t support any I/O operation.

See also Apple’s documentation

Provided Methods§

Source

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

Available on crate features FSItem and FSMutableFileDataBuffer and block2 and libc only.

Reads the contents of the given file item.

If the number of bytes requested exceeds the number of bytes available before the end of the file, then the call copies only those bytes to buffer. If offset points past the last valid byte of the file, don’t reply with an error but set actuallyRead to 0.

  • Parameters:
  • item: The item from which to read. FSKit guarantees this item will be of type FSItem/ItemType/file.
  • offset: The offset in the file from which to start reading.
  • length: The number of bytes to read.
  • buffer: A buffer to receive the bytes read from the file.
  • reply: A block or closure to indicate success or failure. If reading succeeds, pass the number of bytes read and a nil error. If reading fails, pass the number of bytes read prior to the error along with the relevant error. For an async Swift implementation, there’s no reply handler; simply return the byte count or throw an error.
Source

unsafe fn writeContents_toFile_atOffset_replyHandler( &self, contents: &NSData, item: &FSItem, offset: off_t, reply: &DynBlock<dyn Fn(usize, *mut NSError)>, )
where Self: Sized + Message,

Available on crate features FSItem and block2 and libc only.

Writes contents to the given file item.

FSKit expects this routine to allocate space in the file system to extend the file as necessary.

If the volume experiences an out-of-space condition, reply with an error of domain <doc ://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and code ENOSPC.

  • Parameters:
  • contents: A buffer containing the data to write to the file.
  • item: The item to which to write. FSKit guarantees this item will be of type FSItem/ItemType/file.
  • offset: The offset in the file from which to start writing.
  • reply: A block or closure to indicate success or failure. If writing succeeds, pass the number of bytes written and a nil error. If writing fails, pass the number of bytes written prior to the error along with the relevant error. For an async Swift implementation, there’s no reply handler; simply return the byte count or throw an error.

Trait Implementations§

Source§

impl ProtocolType for dyn FSVolumeReadWriteOperations

Source§

const NAME: &'static str = "FSVolumeReadWriteOperations"

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 FSVolumeReadWriteOperations

Implementations on Foreign Types§

Source§

impl<T> FSVolumeReadWriteOperations for ProtocolObject<T>

Implementors§