pub struct IOEvent<C: IOCallback> {
pub action: IOAction,
pub offset: i64,
pub fd: RawFd,
/* private fields */
}Fields§
§action: IOAction§offset: i64§fd: RawFdImplementations§
Source§impl<C: IOCallback> IOEvent<C>
impl<C: IOCallback> IOEvent<C>
pub fn new(fd: RawFd, buf: Buffer, action: IOAction, offset: i64) -> Self
pub fn new_no_buf(fd: RawFd, action: IOAction, offset: i64, len: u64) -> Self
pub fn set_fd(&mut self, fd: RawFd)
Sourcepub fn set_callback(&mut self, cb: C)
pub fn set_callback(&mut self, cb: 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>(
self: Box<Self>,
check_short_read: F,
) -> Result<(), Box<Self>>
pub fn callback<F>( self: Box<Self>, check_short_read: F, ) -> 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.
Sourcepub fn callback_unchecked(self, to_fix_short_io: bool)
pub fn callback_unchecked(self, to_fix_short_io: bool)
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for IOEvent<C>where
C: Freeze,
impl<C> RefUnwindSafe for IOEvent<C>where
C: RefUnwindSafe,
impl<C> Send for IOEvent<C>
impl<C> Sync for IOEvent<C>where
C: Sync,
impl<C> Unpin for IOEvent<C>
impl<C> UnsafeUnpin for IOEvent<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for IOEvent<C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more