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 { ... }
}
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§
Sourceunsafe fn readFromFile_offset_length_intoBuffer_replyHandler(
&self,
item: &FSItem,
offset: off_t,
length: usize,
buffer: &FSMutableFileDataBuffer,
reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
)
Available on crate features FSItem
and FSMutableFileDataBuffer
and block2
and libc
only.
unsafe fn readFromFile_offset_length_intoBuffer_replyHandler( &self, item: &FSItem, offset: off_t, length: usize, buffer: &FSMutableFileDataBuffer, reply: &DynBlock<dyn Fn(usize, *mut NSError)>, )
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 anasync
Swift implementation, there’s no reply handler; simply return the byte count or throw an error.
Sourceunsafe fn writeContents_toFile_atOffset_replyHandler(
&self,
contents: &NSData,
item: &FSItem,
offset: off_t,
reply: &DynBlock<dyn Fn(usize, *mut NSError)>,
)
Available on crate features FSItem
and block2
and libc
only.
unsafe fn writeContents_toFile_atOffset_replyHandler( &self, contents: &NSData, item: &FSItem, offset: off_t, reply: &DynBlock<dyn Fn(usize, *mut NSError)>, )
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 anasync
Swift implementation, there’s no reply handler; simply return the byte count or throw an error.