pub struct AioRead<'a> { /* private fields */ }
Expand description
Asynchronously reads from a file descriptor into a buffer
§References
§Examples
const INITIAL: &[u8] = b"abcdef123456";
const LEN: usize = 4;
let mut rbuf = vec![0; LEN];
let mut f = tempfile().unwrap();
f.write_all(INITIAL).unwrap();
{
let mut aior = Box::pin(
AioRead::new(
f.as_fd(),
2, //offset
&mut rbuf,
0, //priority
SigevNotify::SigevNone
)
);
aior.as_mut().submit().unwrap();
while (aior.as_mut().error() == Err(Errno::EINPROGRESS)) {
thread::sleep(time::Duration::from_millis(10));
}
assert_eq!(aior.as_mut().aio_return().unwrap(), LEN);
}
assert_eq!(rbuf, b"cdef");
Implementations§
source§impl<'a> AioRead<'a>
impl<'a> AioRead<'a>
sourcepub fn nbytes(&self) -> usize
pub fn nbytes(&self) -> usize
Returns the requested length of the aio operation in bytes
This method returns the requested length of the operation. To get the
number of bytes actually read or written by a completed operation, use
aio_return
instead.
sourcepub fn new(
fd: BorrowedFd<'a>,
offs: off_t,
buf: &'a mut [u8],
prio: i32,
sigev_notify: SigevNotify<'_>,
) -> Self
pub fn new( fd: BorrowedFd<'a>, offs: off_t, buf: &'a mut [u8], prio: i32, sigev_notify: SigevNotify<'_>, ) -> Self
Create a new AioRead
, placing the data in a mutable slice.
§Arguments
fd
: File descriptor to read fromoffs
: File offsetbuf
: A memory buffer. It must outlive theAioRead
.prio
: If POSIX Prioritized IO is supported, then the operation will be prioritized at the process’s priority level minusprio
sigev_notify
: Determines how you will be notified of event completion.
Trait Implementations§
source§impl<'a> Aio for AioRead<'a>
impl<'a> Aio for AioRead<'a>
source§type Output = usize
type Output = usize
The return type of
Aio::aio_return
.source§fn cancel(self: Pin<&mut Self>) -> Result<AioCancelStat>
fn cancel(self: Pin<&mut Self>) -> Result<AioCancelStat>
Cancels an outstanding AIO request. Read more
source§fn error(self: Pin<&mut Self>) -> Result<()>
fn error(self: Pin<&mut Self>) -> Result<()>
Retrieve error status of an asynchronous operation. Read more
source§fn fd(&self) -> BorrowedFd<'a>
fn fd(&self) -> BorrowedFd<'a>
Returns the underlying file descriptor associated with the operation.
source§fn in_progress(&self) -> bool
fn in_progress(&self) -> bool
Does this operation currently have any in-kernel state? Read more
source§fn set_sigev_notify(&mut self, sev: SigevNotify<'_>)
fn set_sigev_notify(&mut self, sev: SigevNotify<'_>)
Update the notification settings for an existing AIO operation that has
not yet been submitted.
Auto Trait Implementations§
impl<'a> Freeze for AioRead<'a>
impl<'a> RefUnwindSafe for AioRead<'a>
impl<'a> Send for AioRead<'a>
impl<'a> Sync for AioRead<'a>
impl<'a> !Unpin for AioRead<'a>
impl<'a> UnwindSafe for AioRead<'a>
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