pub struct FileReadTask { /* private fields */ }
Expand description
Handle to an asynchronous file reading operation.
Implementations§
Source§impl FileReadTask
impl FileReadTask
Sourcepub fn new(file: FileHandle, task_id: u64, buffer: Box<[u8]>) -> FileReadTask
pub fn new(file: FileHandle, task_id: u64, buffer: Box<[u8]>) -> FileReadTask
Creates a new FileReadTask
with the task id differentiating
different FileReadTask
s. The platform implementation should create
and keep track of these.
Sourcepub fn file(&self) -> FileHandle
pub fn file(&self) -> FileHandle
Returns the FileHandle
this task is using.
Sourcepub fn task_id(&self) -> u64
pub fn task_id(&self) -> u64
Returns the task id for this particular task, the same one passed into
FileReadTask::new
.
Sourcepub fn read_size(&self) -> usize
pub fn read_size(&self) -> usize
Returns the size of the buffer, i.e. the amount of bytes read by this task.
Sourcepub unsafe fn into_inner(self) -> Box<[u8]>
pub unsafe fn into_inner(self) -> Box<[u8]>
Deconstructs this into the inner buffer. Intended for platform layers
implementing
Platform::finish_file_read
.
§Safety
The platform may have shared a pointer to this buffer with e.g. the kernel for async writing. The caller must ensure that when calling this function, such a shared pointer will not be used anymore, as this function makes said memory writable again (not owned and hidden in this struct).