pub struct IOEvent<C: CbArgs> {
pub action: IOAction,
pub offset: i64,
pub fd: RawFd,
/* private fields */
}Fields§
§action: IOAction§offset: i64§fd: RawFdImplementations§
Source§impl<C: CbArgs> IOEvent<C>
impl<C: CbArgs> IOEvent<C>
Sourcepub fn new(fd: RawFd, buf: Buffer, action: IOAction, offset: i64) -> Self
pub fn new(fd: RawFd, buf: Buffer, action: IOAction, offset: i64) -> Self
For IOAction::Read / IOAction::Write
Sourcepub fn new_no_buf(fd: RawFd, action: IOAction, offset: i64, len: u64) -> Self
pub fn new_no_buf(fd: RawFd, action: IOAction, offset: i64, len: u64) -> Self
For IOAction::Alloc / IOAction::Fsync
pub fn set_fd(&mut self, fd: RawFd)
Sourcepub fn set_args(&mut self, args: C)
pub fn set_args(&mut self, args: C)
Set callback for IOEvent, might be closure or a custom struct
pub fn get_size(&self) -> u64
pub fn get_write_result(self) -> Result<(), Errno>
Sourcepub fn get_result(&self) -> Result<usize, Errno>
pub fn get_result(&self) -> Result<usize, Errno>
Get the result of the IO operation (bytes read/written or error). Returns the number of bytes successfully transferred.
Sourcepub fn get_read_result(self) -> Result<Buffer, Errno>
pub fn get_read_result(self) -> Result<Buffer, Errno>
Get the buffer from a read operation.
Note: The buffer length is NOT modified. Use get_result() to get actual bytes read.
Sourcepub fn callback<F, B>(
self: Box<Self>,
check_short_read: F,
cb: B,
) -> Result<(), Box<Self>>
pub fn callback<F, B>( self: Box<Self>, check_short_read: F, cb: B, ) -> Result<(), Box<Self>>
For writing custom callback workers
Callback worker should always call this function on receiving IOEvent from Driver
parameter: check_short_read(offset: u64) should be checking the offset exceed file end.
If check_short_read() return true, the callback function will return Err(IOEvent) for I/O resubmit.
NOTE: you should always use a weak reference in check_short_read closure and
re-submission.